Changes

Jump to: navigation, search

Locomotive BASIC

1,457 bytes added, 10:21, 20 March 2019
/* Functions */
run
</pre>
==== <code><big>VAL(se<string expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the numeric VALue, (including any negative sign and decimal point) of the first character(s) in the specified <string expression>. :If the first character is not a number, then 0 is returned. If the first character is a negative sign or decimal point followed by non-numeric characters, a 'Type mismatch' error (13) will be reported.
:Returns the numeric value (including signs) of first numeric character(s) in se. Returns 0 if se starts with a non-number. '''Associated keywords''': STR$ :'''1. Example''':<pre>PRINT VAL("-12.34x"),VAL("A-12") - prints -12.34 0
</pre>
:'''Exception''': if <se> starts with "&amp;" + character (and it's between "A" and "F") the whole character will be handled like a hexadezimal numeric character (...often used in DATA Loaders). The returning numeric value is a &nbsp;signed&nbsp;integer (16-Bit Word). : '''2. Example''':<pre>PRINT&nbsp;VAL("&amp;A") - returns a 10
PRINT&nbsp;VAL("&amp;7FFF") - returns a 32767
PRINT&nbsp;VAL("&amp;8000") - returns a -32768</pre>: '''3. Example''':<pre>10 CLS: PRINT "I know my times tables!"20 PRINT:PRINT "Press a key (1 to 9)"30 a$=INKEY$:IF a$="" THEN 3040 n=VAL(a$):if n<1 or n>9 then 3050 FOR x=1 to 1260 PRINT n;"X";x;"=";n*x70 NEXT:GOTO 20run</pre>==== <code><big>VPOS (#<stream expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the current vertical POSition of the text cursor relative to the top of the text window. The <stream expression> MUST be specified, and does NOT default to #0.
==== <code>VPOS (#st)</code> ====: Reports the current row (line) position of the text cursor relative to the top of the text windows of the specified stream.'''Associated keywords''': POS, WINDOW
: '''Example''':<pre>10 MODE 1:BORDER 0:LOCATE 8,220 PRINT "use cursor up/down keys"30 WINDOW 39,39,1,25:CURSOR 1,140 LOCATE 1,350 IF INKEY(0)<>-1 THEN PRINT CHR$(11);60 IF INKEY(2)<>-1 THEN PRINT CHR$(10);70 LOCATE #1,3,2480 PRINT #1,"text cursor ";90 PRINT #1,"vertical position =";100 PRINT #1,VPOS(#0):GOTO 50run</pre>==== <code><big>XPOS</big></code> ====: Returns ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the current horizontal (xX) position POSition of the graphics cursor.
: '''Associated keywords''': MOVE, MOVER, ORIGIN, YPOS : '''Example''':<pre>10 MODE 1:DRAW 320,20020 PRINT "graphics cursor X position = ";30 PRINT XPOS</pre>==== <code><big>YPOS</big></code> ====: Returns ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the current vertical (yY) position POSition of the graphics graphic cursor. : '''Associated keywords''': MOVE, MOVER, ORIGIN, XPOS : '''Example''':<pre>10 MODE 1:DRAW 320,20020 PRINT "graphics cursor Y position = ";30 PRINT YPOS</pre>
== Other Basic Dialects available for the CPC ==
205
edits