Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What extra features does VARPTR provide?
#3
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
Reply


Messages In This Thread
RE: What extra features does VARPTR provide? - by a740g - 06-22-2023, 01:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Must an extra value be provided on DATA statement? dakra137 11 1,064 09-30-2025, 05:38 PM
Last Post: ahenry3068
  Using VarPtr in Play staement PhilOfPerth 3 819 12-06-2024, 12:26 PM
Last Post: grymmjack
  Extra Commas james2464 7 1,430 11-20-2022, 06:31 AM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)