Quantcast
Channel: stardot.org.uk
Viewing all articles
Browse latest Browse all 5552

8-bit acorn software: other • RFH: Losing 'global pointer' variable in PROC...?

$
0
0
Hey y'all ;-)

I'm aware that BBC Basic heap management isn't the best, so rather than allocate new space for a string every time I redefine it, I thought I'd just define 256 bytes as a string buffer and work in that when appropriate (indirecting with $strBuff%="...." or similar)

This was initially working fine, but I've now run in to a situation where I am getting 'No Such Variable' errors when trying to indirect into this buffer inside a PROC.

I'm assigning the buffer _after_ MODE change, I've tried DIMing and directly assigning an address, and ensured HIMEM and TOP aren't interfering, but to no avail.

Here's my code; lines 40-70 are my initial test case, but the problems arrive at line 630...

Code:

   10REM>SpdAtLat   20MODE1   30VDU19,1,4;0;   40REM DIM strBuff% 255   41strBuff%=&900   60$strBuff%="TEST"   70PROCshwHlt(2,1)   80   90REMPROCsetVars    100REMPROCtitle  110REMPROCscrLayout  120PROCshwUnits  130REMPROCshowVars  140  150END  160  170DEF FNgetArsyOSCol(N%)  180IFN%=0 =0  190IFN%=15 =1  200IFN%=240 =2  210IFN%=255 =3  220=129  230  240DEF PROCshwHlt(P%,C%)  250LOCAL N%,F%  260F%=FNgetArsyOSCol(?&357)  270FOR N%=1 TO LEN($strBuff%)  280IFP%=N% THEN COLOUR C% ELSE COLOUR F%  290PRINTMID$($strBuff%,N%,1);  300NEXT  310ENDPROC  320  330DEF PROCtitle  340COLOUR 131:COLOUR0  350PRINT"Speed At Latitude"  360PRINT"================="  370COLOUR128:COLOUR2  380PRINTTAB(17,0);" Calculate speed for a"  390PRINTTAB(17,1);" planetary latitude"  400ENDPROC  410  420DEF PROCscrLayout  430GCOL0,3  440MOVE0,0  450DRAW0,960  460DRAW1279,960  470DRAW1279,0  480DRAW0,0  490ENDPROC  500  510DEF PROCshwHlt(P%,C%)  520LOCAL N%,F%  530REM F%=FNgetArsyOSCol(?&357)  540FOR N%=1 TO LEN($strBuff%)  550IFP%=N% THEN COLOUR 3 ELSE COLOUR F%  560PRINTMID$($strBuff%,N%,1);  570NEXT  580ENDPROC  590  600DEF PROCshwUnits  610COLOUR131:COLOUR0  620PRINTTAB(0,2)"Units: ";  630$scrBuff%="units: "  640PROCshwHlt(0,1)  650ENDPROC
Which gives me "No such variable at line 630" and sure enough, when I get the prompt back 'P. strBuff%' says 'No such variable' (although I'm kinda sure that I've had the 'No such variable' error but been able to 'P. strBuff%' successfully on occasion - I might be wrong though)

I'm obviously doing something incredibly stupid here; would any of you be good enough to point out my mistake? ;-)

Many Thanks In Advance,
Neal

Statistics: Posted by NealC — Mon Feb 02, 2026 6:04 pm



Viewing all articles
Browse latest Browse all 5552

Trending Articles