06-22-2023, 11:49 PM
(06-22-2023, 01:44 PM)a740g Wrote: 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.
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
Thanks both.
It seems the consensus is that it's not likely to be useful in most cases.
I can see that it may shorten the coding in some cases, but this doesn't
seem likely to be of much use for my simple programming style.
Another "pothole" negotiated!
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
Please visit my Website at: http://oldendayskids.blogspot.com/