Changes

#This data defines the tokenised BASIC program line and exists if the length of line data in bytes is not "0". The length is dependant on the BASIC program line contents.
#This value defines the end of the tokenised BASIC line data and exists if the length of line data in bytes is not "0". The BASIC interpreter looks for this token during the processing of this line, and if found, will stop execution and continue to the next line.
 
== BASIC GOSUB Subroutines ==
 
When Subroutines are used through the use of GOSUB, it's very important for that Subroutine to exit through the use of RETURN or if a Subroutine needs to GOTO somewhere else that, that place can RETURN. When a RETURN isn't found though, an area located at &AE8C in BASIC 1.0 or &AE70 in BASIC 1.1 then proceeds to fill with data from GOSUB calls and grows to the point over &1FF bytes have been used causing a MEMORY FULL error.
 
The Following example demonstrates how to Trap this error:
 
<pre>
100 DEFINT a-z:MODE 2
110 GOSUB 130
120 c=1:GOSUB 130:c=0:GOTO 110
130 IF c=0 THEN PRINT"*";:GOTO 120
140 RETURN
</pre>
 
When the MEMORY FULL is reached and MEMORY FULL occurs, the user can reveal the situation by executing a RETURN immediately following MEMORY FULL, in the example from above instead of getting Unexpected RETURN, the Code Prints a Star before returning to a MEMORY FULL state. In that example it doesn't take very long to reach a MEMORY FULL, though more substancial may take longer to reveal this error.
 
If a BASIC game should issue a MEMORY FULL error, the easiest test is to say RETURN. If Unexpected RETURN doesn't occur and the code tries to continue, it will be a sign of Subroutines not being able to RETURN after a GOSUB ia issued. The easiest course is to remove Subroutines. A game for example may have a series of GOSUBs going to a line checking IF something is true, and if so GOTO somewhere else where a RETURN may not be found. In those situations a GOSUB should be replaced with an IF...THEN..[line number] thus removing the Subroutine.
 
IF you wish to konw more about this please see my ammended correction of the [[Amstrad Action December 1990 Type-Ins|Amstrad Action Issue 63 Type-Ins Game Madballs]]. The original game which was nicely coded, eventually ran into the problem of MEMORY FULL, though to fully reveal this error the game needed to be played for over 20 minutes. Another way to test for this error is to inspect the area of &AE8C to &B08B or &AE70 to &B06F depending on which version of BASIC is used.
== BASIC tokens ==
The sign is represented by bit 7 of byte 3. The value of the sign bit indicates the sign of the floating point number.
#*If the sign bit is "1", then the number is negative. #*If the sign bit is "0", then the number is positive.
=== Mantissa ===
The exponent is 8-bit and is stored in byte 4. It is stored with a bias of 128.
#*128-255 are positive exponents, #*1-127 are negative exponents.#*0 means, the number is zero
To obtain the signed exponent, you must subtract 128 from the stored exponent. The minimum exponent is 1 and this describes a number of 2^-127. The maximum exponent is 255 and this describes a number of 2^127.
A floating point (real) variable describes a number with integer and fractional parts. The biggest figure which can be stored correctly in RAM by a variable is 2^32-1 = 4294967295.
#*A real variable is defined with a "!" character postfix.
e.g.
<pre>a! = 3.141592654
</pre>
#*A real number uses 5 bytes of memory as storage. The format is described above. #*The address of a real variable can be found in BASIC by:
<pre>PRINT @a!
</pre>
<br> NOTES:
#*A integer variable is defined with a "%" character postfix.
e.g.
<pre>a% = 3
</pre>
#*A integer variable has a range of -32768 to 32767 #*A integer variable always uses two bytes of memory as storage with the following format:
{| border="1"
|}
#*The address of the integer variable can be found in BASIC by:
<pre>PRINT @a%
</pre>
|}
*The address of the "string descriptor block" for the string variable can be found in BASIC by typing: <pre>PRINT @a$
</pre>
430
edits