Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BYVAL in the wiki jumps to DECLARE LIBRARY
#5
(12-05-2023, 01:35 PM)FellippeHeitor Wrote: Wrap variables in parenthesis when passing to a sub. That makes it go byval rather than byref.

Just be warned -- there are a few instances where doing this will cause issues with your program.  (I think it's with strings, or arrays of strings, or some such similar which errors out and doesn't work, and we haven't came up with a fix for the issue yet.)

The best practice, if you know you're always going to be passing into a sub BYVAL, is just to pass to temp variables first:

Code: (Select All)
SUB foo (tempX, tempY)
    x = tempX
    y = tempY

With the above, you'll never pass values back and forth, so you never have to worry about corrupting your original variables.
Reply


Messages In This Thread
RE: BYVAL in the wiki jumps to DECLARE LIBRARY - by SMcNeill - 12-05-2023, 01:43 PM



Users browsing this thread: 2 Guest(s)