Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Question on Calls to Subroutines
#3
OK, I actually tested out the following code:

Code: (Select All)

DIM SHARED test AS LONG

test = 4
PRINT test
callthisthing test
PRINT test
PRINT "End of my tests!"
END

SUB callthisthing (u AS LONG)
STATIC test AS INTEGER
test = test + 1
u = u * 2
END SUB

First it prints 4 then 8. The "test" variable inside the subprogram is "protected", of type INTEGER which is two bytes. Although there is a variable named just like it which is supposed to be accessible inside that subprogram which is twice as large.

Without STATIC declaration line the second PRINT test would give 10.



On Spiral Linux KDE (Debian "Bullseye" clone), I compile this program:

Code: (Select All)

SCREEN _NEWIMAGE(640, 480, 12)
setmyfont
PRINT "Print this for me in different letters!"
END

SUB setmyfont ()
DIM afont AS STRING, han AS LONG
afont = "/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf"
han = _LOADFONT(afont, 24)
_FONT han
END SUB

to get this executable file:

Code: (Select All)
-rwxr-xr-x 1 fc fc    1734368 Nov 22 16:33 nd22-2

Commenting out "setmyfont" line just below SCREEN statement will not do anything about it. Must remove "setmyfont" call and definition entirely from the program, if that's the only thing that will have anything to do with fonts.
Reply


Messages In This Thread
A Question on Calls to Subroutines - by Dimster - 11-22-2023, 04:43 PM
RE: A Question on Calls to Subroutines - by mnrvovrfc - 11-22-2023, 09:37 PM



Users browsing this thread: 1 Guest(s)