In order for this site to work correctly, and for us to improve the site, we need to store a small file (called a cookie) on your computer.
By continuing to use this website, you agree to our cookies and privacy policy.
  
Home page Home page Home page Home page
Pixel
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
Pixel

Reader's Letters - Jim Owen

"I've discovered something that might be of interest to some AREV programmers regarding the calling of homemade functions. I had a function called SPC which padded blank spaces onto a variable. For example


0001            X = 65
0002            Y = SPC(X,5,"R")

would return Y = ' 65'. (Unsure as to why this differs from Y = 65 "R#5" - Ed).

However I discovered that this function also changed X!

I wanted my function to work like INT() which does not change the value of the variable inside the parens, only the value to the left of the '='.

RTI told me that the C-esque use of local vs global variables doesn't apply to RBASIC. One way to solve it was to make parameter 1 a literal string. This was done by calling the function thus


0001            X = 65
0002            Y = SPC(X:" ",5,"R")

Concatenating a null to the variable changes it to a string and does NOT change X. Another way around the problem was to immediately stuff some other variable with X on entering the function then operating on, and returning, this new variable.

Incidentally the INT() function is in assembler and avoids the problem altogether".

(Volume 2, Issue 6, Page 3)
Pixel
Pixel Footer R1 C1 Pixel
Pixel
Pixel
Pixel