Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WITH/END WITH?
#8
OK here it is! Smile
Quote:Implementing VB-style WITH...END WITH in QB64pe involves using macros or custom preprocessor directives, as QB64 doesn't natively support it; you'd define macros like #Define With(obj) obj. and #Define EndWith to substitute for the shorthand, then use qb64pe -c (compile) or qb64pe -x (execute) from a script or build system to process these, creating a clear pull request on GitHub by showing the original code and the transformed output, explaining how these macros simulate the VB functionality.
1. The QB64pe Code (Simulated WITH)
You'll use QB64's preprocessor features to mimic WITH.
qb64
'// WITH_SIMULATOR.BAS

#Define With(obj) obj.
#Define EndWith

' Original VB-style code (simulated):
' WITH mySprite
'    X = 100
'    Y = 200
'    Color = RGB(255, 0, 0)
' END WITH

' Translated by the macro:
DIM mySprite AS OBJECT
mySprite.X = 100
mySprite.Y = 200
mySprite.Color = RGB(255, 0, 0)

' Example with a real object (like a Window):
DIM myWindow AS _WINDOW
WITH myWindow
    .X = 0
    .Y = 0
    .Width = 800
    .Height = 600
END WITH
' (This will look like: myWindow.X=0, myWindow.Y=0, etc., after processing)

PRINT "Simulated WITH block executed!"

#Undefine With
#Undefine EndWith
2. How It Works (Preprocessor Magic)
#Define With(obj) obj. turns WITH mySprite into mySprite. (note the dot).
#Define EndWith just removes the line entirely.
When QB64 compiles, it sees mySprite. and understands you're accessing members of mySprite.
3. Preparing for Your GitHub Pull Request
Create a Branch: git checkout -b feature/with-syntax-support
Add Files: git add WITH_SIMULATOR.BAS
Commit: git commit -m "Add simulation for VB WITH/END WITH syntax"
Push: git push origin feature/with-syntax-support
4. In Your Pull Request Description
Title: "Feature: Implement VB-Style WITH/END WITH using Preprocessor Macros"
Description:
Explain the goal: bring familiar VB syntax to QB64 users.
Show the Original Code (using WITH...END WITH).
Show the Transformed Code (what the preprocessor makes it).
Explain the macros used (#Define With(obj) obj., #Define EndWith).
Mention the compilation command: qb64pe -c your_file.bas or qb64pe -x your_file.bas.
Link to relevant QB64 documentation or forum discussions if needed.
This approach provides a clear, executable solution that honors the requested VB style within the QB64 environment, perfect for a GitHub contribution.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
WITH/END WITH? - by bobalooie - 11-21-2025, 07:16 PM
RE: WITH/END WITH? - by hsiangch_ong - 11-22-2025, 12:41 AM
RE: WITH/END WITH? - by Pete - 01-19-2026, 04:32 PM
RE: WITH/END WITH? - by bplus - 01-19-2026, 05:25 PM
RE: WITH/END WITH? - by bobalooie - 01-27-2026, 02:44 AM
RE: WITH/END WITH? - by Pete - 01-19-2026, 05:34 PM
RE: WITH/END WITH? - by NakedApe - 01-19-2026, 06:21 PM
RE: WITH/END WITH? - by bplus - 01-19-2026, 06:39 PM
RE: WITH/END WITH? - by Pete - 01-19-2026, 06:40 PM
RE: WITH/END WITH? - by hsiangch_ong - 01-20-2026, 02:30 PM
RE: WITH/END WITH? - by bplus - 01-20-2026, 02:44 PM
RE: WITH/END WITH? - by Magdha - 01-20-2026, 04:10 PM
RE: WITH/END WITH? - by SMcNeill - 01-20-2026, 05:54 PM
RE: WITH/END WITH? - by bplus - 01-20-2026, 05:47 PM
RE: WITH/END WITH? - by hsiangch_ong - 01-21-2026, 02:39 AM
RE: WITH/END WITH? - by madscijr - 01-21-2026, 11:14 PM
RE: WITH/END WITH? - by bobalooie - 01-27-2026, 01:55 AM
RE: WITH/END WITH? - by madscijr - 01-27-2026, 04:38 AM
RE: WITH/END WITH? - by SMcNeill - 01-27-2026, 02:04 AM
RE: WITH/END WITH? - by bobalooie - 01-27-2026, 02:56 AM
RE: WITH/END WITH? - by Pete - 01-27-2026, 04:51 AM
RE: WITH/END WITH? - by madscijr - 01-27-2026, 05:02 AM
RE: WITH/END WITH? - by luke - 01-27-2026, 08:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question What happened to end year holiday season code? mnrvovrfc 5 1,074 12-27-2023, 02:39 PM
Last Post: GareBear
  So... I *think* I found the cheese at the end of the maze? MrCreemy 11 2,073 12-30-2022, 11:24 AM
Last Post: JRace

Forum Jump:


Users browsing this thread: 1 Guest(s)