Changes

Jump to: navigation, search

Locomotive BASIC

899 bytes added, 08:47, 14 January 2019
/* Functions */
run
</pre>
==== <code>INP (‹address›‹port number›)</code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the INPut value from the I/O address specified in the <port number>. : '''Associated keywords''': OUT, WAIT
: Returns a value read from the defined I/O address
: Watch out http://cpcwiki.eu/index.php/I/O_Port_Summary
: '''Example''':
<pre>
PRINT INP(&FF00)
Ready
</pre>
==== <code>INSTR ([‹startposition›,]‹searched string›, ‹searched for string›)</code> ====
: ''BASIC 1.0 & 1.1''
: '''FUNCTION''': Searches the first <searched string> expression to find the first occurance of the <searched for string expression<, and reports the position of its occurance within the <searched string>. If the <searched for string> does not occur within the <searched string>, then 0 is reported.
: The position at which to start searching the <searched string> is optionally specifiable using the <start position> parameter which must yield an integer number in the range 1 to 255.
==== <code>INSTR ([‹startposition›,]‹explored string›,‹seeking string›)</code> ====: '''Associated keywords''': none
: This function looks inside "explored string" after "seeking string" and return a number where the found string appear for the first time.: Returns zero if not successfull.: Startposition could be a figure between '''1 and 255Example''': Example
<pre>
a$="ABCD":PRINT INSTR(a$,"C")
Ready
</pre>
: '''2. Example''':
<pre>
a$="Hello":IF INSTR(a$,"i")<>0 THEN PRINT "no" else a$
Ready
</pre>
: '''3. Example''':<pre>10 CLS20 alphabet$="ABCDEFGHIJKLMNOPQRSTUVWXYZ"30 INPUT "Enter a letter";a$40 b$=UPPER$(a$)50 PRINT b$;" is number";60 PRINT INSTR(alphabet$,b$);70 PRINT "in the alphabet.":PRINT80 GOTO 40run</pre>
==== <code>INT (n)</code> ====
: ''BASIC 1.0 & 1.1''
: '''FUNCTION''': Rounds the number to the nearest smaller INTeger, removing any fractional part. Returns then same value as FIX for positive number, but returns one less than FIX for negative numbers which are not already integers.
: As in '''Associated keyword''': CINT, FIX if n is positive; if n is negative, it rounds it down. : Example:ROUND
: '''Example''':
<pre>
PRINT INT(3.99), INT(-3.99) - prints 3 -4
</pre>
 
==== <code>JOY (i)</code> ====
205
edits