06-22-2023, 01:44 PM
VARPTR$ can come in handy when using DRAW or PLAY inside tight loops where you want to avoid the overhead and speed penalty of say string concatenation or other string ops.
Like in the example below, we avoid a string concatenation inside the FOR loop by using VARPTR$ for DRAW. This still works in QB64, thanks to the length Galleon went to emulate such things.
This is probably the only reason I'd use VARPTR$. Else, it is better to avoid such legacy commands.
Like in the example below, we avoid a string concatenation inside the FOR loop by using VARPTR$ for DRAW. This still works in QB64, thanks to the length Galleon went to emulate such things.
This is probably the only reason I'd use VARPTR$. Else, it is better to avoid such legacy commands.
Code: (Select All)
SCREEN 12
drawCmd$ = "TA=" + VARPTR$(angle) + "BU100"
FOR angle = 0 TO 360 STEP 30 ' 360/12 hour circles = 30 degrees apart
PSET (175, 250), 6 ' stay at center point of clock
DRAW drawCmd$ ' move invisibly to set next circle's center point
CIRCLE STEP(0, 0), 5, 12 ' circle placed at end of blind line
DRAW "P9, 12" ' paint inside of circle
SLEEP 1 ' slowed for demo only
NEXT