Address of a variable: Difference between revisions

Content added Content deleted
Line 552: Line 552:
=={{header|Commodore BASIC}}==
=={{header|Commodore BASIC}}==
{{works with|BASIC|7.0 (C-128)}}
{{works with|BASIC|7.0 (C-128)}}
The address of a variable in BASIC is readonly, but accessible via the `POINTER` function.
The address of a variable in BASIC is readonly, but accessible via the <pre>POINTER</pre> function.


<syntaxhighlight lang="basic">100 REM ALLOCATE ALL VARS FIRST SO THEY DON'T MOVE
<syntaxhighlight lang="basic">100 REM ALLOCATE ALL VARS FIRST SO THEY DON'T MOVE
110 X=123:Y=456:PX=0:PY=0:I=0:T=0
110 X=123:Y=456:PX=0:PY=0:I=0:T=0
120 PRINT "X="X", Y="Y
120 PRINT "X ="XCHR$(20)", Y ="Y
130 PX=POINTER(X):PY=POINTER(Y)
130 PX=POINTER(X):PY=POINTER(Y)
140 REM VARS ARE STORED IN RAM BANK 1
140 REM VARS ARE STORED IN RAM BANK 1
Line 565: Line 565:
190 : POKE PX+I,T
190 : POKE PX+I,T
200 NEXT I
200 NEXT I
210 PRINT "NOW X="X", Y="Y</syntaxhighlight>
210 PRINT "NOW X ="XCHR$(20)", Y ="Y</syntaxhighlight>


{{Out}}
{{Out}}
<pre>X= 123 , Y= 456
<pre>X = 123, Y = 456
NOW X= 456 , Y= 123</pre>
NOW X = 456, Y = 123</pre>


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==