BASIC Reference
ABORT
ABS ACOS ADC AND ASCII ASIN ATAN BIN$ BOLD BSTR BYTE$ BYTESTR CHAR CHR$ CLREOL CLRSCR CONF$ COS COUNT DAC DELAY DIM ELSE END ENDIF ERC$ ERR EXP FOR GETTICK GOSUB GOTO HEX$ HI I2CBUSY I2CER$ I2CERR I2CINIT I2CRD$ |
I2CRDS
I2CTIME I2CWR IF IIF IN INADC IND INKEY INPLEN INPUT INSTR INT LEFT$ LEN LET LO LOCATE LOG LSL LSR MAP MAX MID$ MIN MOD NEXT NOT ONERROR OR OUT OUTD OUTDAC PEEK PI PINMODE PULSIN PULSOUT |
POKE
PORT PWM PWMPIN REM REPEAT RETURN RIGHT$ RND SERBNG SERINIT SERINP$ SEROUT SERSPI SETTICK SIN SQRT STEP SSTEP STR$ STRING$ TAB TAN THEN TIME$ TIMESET TO TONE TRIM$ UNTIL UPPER$ VAL VALLEN WAIT WEND WHILE |
Keyword Details
Operators in expressions
=, +, -, /, *, ** , &, |, ^, ~, LSL, LSR
Tests for equality
=, <, >, <=, >=, AND, OR
The BASIC key words:
ABORT <label:>
Jumps to line denoted by <label:>. Unwinds all GOSUB, REPEAT/UNTIL, and FOR/NEXT loops. Good for error recovery to ensure the program will continue to run.
x=ABS(<number>)
Takes the absolute value of number.
x=ASCII(<string>)
Returns an integer 0 to 255 giving the character code value of the first character of <string>. An alternative x=ASCII(<string>,n) gives the code of the nth character or -1 if the string does not an nth character.
x$=BIN$(x,<digits>)
Compute the string equivalent of the integer x. <digits> is the number of characters to put in x$. Negative <digits> is big-endian, positive <digits> is little endian. This is the inverse function of BSTR.
BOLD <value>
A non-zero value outputs a VT100/ANSI code to turn on bold type, a zero value turns off bold.
x=BSTR(x$,<digits>)
Return the integer equivalent of the binary value of x$. <digits> is the number of digits to use in x$. For a positive value of digits the binary is interpreted from right to left. For a negative value of digits the binary string is interpreted from left to right. Example:
x$="1101"
PRINT BSTR(x$, 4)
prints 13
and
x$="1101"
PRINT BSTR(x$, -4)
prints 11.
Negative <digits> is big-endian, positive <digits> is little endian. This is the inverse function of BIN$
x$=BYTE$(x,<bytes>)
Returns the string equivalent of x. <bytes> is the number of bytes to use in x$. For a positive value of bytes x is converted from right to left. For a negative value of bytes x is converted from left to right.
x= BYTESTR(x$, 4)
Returns an integer value when x$ is interpreted as a numerical value. <bytes> is the number of bytes to use in x$. For a positive value of bytes the string is converted from right to left. For a negative value of bytes the string is converted from left to right. BYTESTR is very useful in converting data read in the I2C or SPI bus to numerical values.
CHR$(<value>)
Returns a string with a single character with character code <value> (from 0 to 255).
CLREOL
Outputs a VT100/ANSI code to clear the current line from the cursor position to the end of the line.
CLRSCR
Outputs a VT100/ANSI code to clear the screen and place the cursor at the upper left corner.
x$=CONF$(<confstring>)
Reads the configuration variable out of the Configuration Flash and places it into x$. For example if there was a line in the Configuration Flash such as NAME=John Do then Name$=CONF$("NAME") places "John Do" into Name$. The configuration space is in Flash memory and is 4k byte in size. The space is organized as an array of strings in the form Identifier="Content String" CR LF where the CR LF characters mark the end of a string. The Configuration Flash is not intended as a general purpose EEPROM replacement and can not be written from within the BASIC program.
x=COUNT(< pin, duration>)
Counts the number of transitions on input pin in the number of 100us intervals specified by duration. For example x=COUNT(21, 10000) sets x to the number of edges on pin 21 in the next second. Pin 21 must be configured as a digital input with PINMODE before COUNT is called.
DAC
Used with PINMODE to configure a pin as the DAC output.
DELAY <100microseconds>
Waits an integer number of 100microsecond ticks. See WAIT
DIM A(<index 1>)
DIM A(<index 1>,<index 2>)
DIM A$(<index 1>)
DIM A$(<index 1>,<index 2>)
These commands create arrays of strings or numbers, either one,two or three dimensional. These can be initialized to particular values by using the =, e.g.
DIM A(10)=20,18,16,14,12,10,8,6,4,2
DIM NAME$(7)="Joe","Frank","John","Bill","Bert","George","Simon" or
x=0
y=1
z=2
DIM position(3)=x,y,z
declares an array that hold three numbers and initializes it to 0,1,2.
END
Terminates the program. An END instruction may be placed before the subroutine definition.
ENDIF
Terminates the IF statement.
x$=ERC$(<error code number>)
Return a string describing the error associated with error code number. If the number is negative, then the function returns the string representing the last error.
x=ERR(0)
The function retrieves the error code of the last error for ONERROR. Reading this clears the error code so subsequent accesses return 0 until another error occurs. x=ERR(1) This retrieves the line number of the last error for ONERROR. Reading this clears the line number of the error so subsequent access return 0 until another error is thrown. In the editor, the line number of a particular statement can be jumped to by using the CTRL-G command.
FOR <var>=<begin> TO <end> STEP <step>
Iterates <var> starting at <begin> until it reaches <end>, each time through the loop incrementing the step size the value <step>. <step> may be negative if <end> is smaller than <begin>. The end of the loop is NEXT <var>.
e.g.
FOR I=99 TO 1 STEP -1
PRINT I," days till Christmas."
NEXT I
GETTICK
Returns a number that increments every 100us. Very useful for doing timeouts.
start = GETTICK
REPEAT
REM Execute some code for a second
UNTIL GETTICK > ( start + 10000 )
Can also be used to determine how long a piece of code takes to execute. The number will eventually overflow, after a few days. See SETTICK
GOSUB <label:>
Calls a subroutine at the line labeled with <label:>. Control returns to the statement after the GOSUB command when a RETURN is encountered. Note that the destination label must end in a colon.
GOTO <label:>
Jumps program execution to the line labeled by <label:>. Note that the destination label must end in a colon. Use sparingly.
x$=HEX$(<number>)
Returns a string representation of the unsigned hexadecimal equivalent of <number>. Decimal can be returned with STR$.
HI <pin_no1>, <pin_no2>, ...
HI sets the digital output pins in the list of pins to a HIGH state. See LO.
x=I2CBUSY ( < slave address> )
I2C Routine, Return Slave Status
Some I2C devices such as EEPROM's need a variable time to complete commands. This instruction provides an easy way to poll the status of such a device.
I2CER$( <error code>)
I2C Routine, Return error or status string
This instruction is used in conjunction with the I2CERR function to print error messages when the I2C bus transactions fail. The I2CERR instruction is used to retrieve the error code from the I2C subsystem. That code is used as a parameter to the I2CER$ instruction to get an ASCII string that can be printed directly to indicate the source of trouble on the I2C bus.
x=I2CERR
I2C Routine, Return error or status code
The I2CERR function returns the last status or error code reported by the I2C controller function. The same numerical values are used as defined in the LPC2136 User Manual, Chapter 13, Table 167 and Table 168. This is for advanced debugging of bus problems. See the I2CER$ instruction for more readable error and status reporting. Returns 0 if there was no error.
I2CINIT( <clock speed> )
I2C Routine, Initialize the I2C subsystem before use
Sets Pin 4 and Pin 5 as Open Drain pins and sets the frequency of SCLK in Hz. I2CINIT( 100000 ) initializes the controller for 100kHz devices. The Pins are 5V tolerant and may be pulled up to 5V to directly drive 5V IC's.
I2CRD$ ( <slave address>, < register to read>, <number of bytes> )
I2C Routine, Random Read
Instruction to read data from register in a slave device. If the number of bytes to read is greater than one the read is from consecutive addresses (registers) in the slave device. The maximum number of bytes that can be read is 64 (limited by the internal buffer of the EZSBC1) or the number of bytes supported by the slave device.
I2CRDS$ ( <slave address>, <number of bytes> )
I2C Routine, Sequential Read
Instruction to read data from the I2C slave device starting from the byte following the previous address or register read by the I2CRD$ instruction.
I2CTIME( < time to wait > )
I2C Routine, Set Bus Timeout
When the I2C bus is accessed it is possible for the transaction to fail due to noise or protocol failure. <time to wait> specifies the time in units of milliseconds that the EZSBC1 allows before abandoning an I2C transaction.
I2CWR(<slave address>, < register to read>, <data string>, <number of bytes>)
I2C Routine, Write to one or more bytes to a slave device
This instruction write the data in <data string> to a register or consecutive registers or addresses of a slave device. The internal buffer of the EZSBC1 used for the write is 64 bytes.
IF <condition> THEN
<program lines>
ENDIF
IF <condition> THEN
<program lines>
ELSE
<program lines>
ENDIF
If the condition is true, then the program executes the program lines up to ENDIF. If ELSE is included, then execute the program lines between ELSE and ENDIF if the condition is false. IF statements may be nested.
<condiftion> may contain the following test for equality: =, <, >, <=, >= and they may be combined with AND and OR to form complex conditionals.
x=IIF(<condition>,<truevalue>,<falsevalue>)
If the condition is true, then return <truevalue> otherwise return <falsevalue>. Note that both <truevalue> and <falsevalue> are evaluated even though only one is used.
x=1
y=2
PRINT IIF (x<y,x,y)
PRINT IIF(x>y,x,y)
prints
1
2
x$=II$(<condition>,<truestring>,<falsestring>)
If the condition is true, then return <truestring>, otherwise return <falsestring>. Note that both <truestring> and <falsestring> are evaluated even though only one is used.
IN, INPIN
The IN or INPIN keyword is used to set the direction of an IO-pin. See the PINMODE, IND and OUTD keywords.
x=INADC(<ad #>)
Gets the analog value at analog to digital converter numbered from 0-15. The <ad #> from 0-7 corresponds to AD0.<ad #> and the <ad #> from 8-15 corresponds to AD1.<ad #>. Must do a PINMODE first to the appropriate pin to set up the ADC (see PINMODE examples).
x=IND(<pin #>)
Get the digital input at the pin number denoted by . The actual pin for the <pin #> is given in the following table:
Use the PINMODE <pin #>, IN command first to set up the pin as a GPIO input.
x=INKEY
Returns the character code of the currently entered character on the terminal UART0, or -1 if no character is available.
x=INPLEN(<length>)
Sets the maximum number of characters to accept for subsequent INPUT statements. Returns the old INPLEN value. The input length maximum defaults to 80 characters.
INPUT <numerical variable>
INPUT <string variable>
Takes input from the terminal UART0 and places a numerical representation in <numerical variable> of the number entered at the terminal, or into <string variable$> the string entered at the terminal. The entered strings have a maximum size set by the INPLEN commands, which defaults to 80 characters.
x=INSTR(<search string>,<substring>,<index>)
Searches for the first occurrence of string <substring> in the string <search string> that is at or after the character index <index>, with <index>=1 being the first character. If the substring is not found, zero is returned.
INT(<number>)
Returns the integer representation of the number <number>.
x$=LEFT$(<string>,<num characters>)
Returns the first <num characters> characters of string <string>.
x=LEN(<string>)
Returns the number of characters in <string>.
LET <variable>=<expression>
Assigns the variable <variable> to the expression <expression>. If the expression is a string, then the variable must be a string variable. or if the expression is a number then the variable must be a numeric variable. LET is optional, e.g.
X = 5
is a valid statement (the LET may be omitted).
LO <pin_no1>, <pin_no2>, ...
LO sets the digital output pins in the list of pins to a LOW state. See HI
LOCATE <y cursor position>,<x cursor position>
Sends the VT100/ANSI code to the terminal to position the cursor at y position <y cursor position> and x position <x cursor position>.
scaled_x= MAP( x, in_min, in_max, out_min, out_max )
This function maps x that lies in the interval ( in_min, in_max) to a scaled position on the new scale (out_min, out_max)
As an example; You have a sensor with an input range from 0.25V to 3.0V. If it is connected to an ADC channel you will get a range of values from (approximately) 77 to 930 instead of from 0 to 1023. With the MAP function you can scale it to 0 to 1023 like this:
x=INADC( Ch1 )
scaled_x= MAP( x, 77, 930, 0, 1023 )
or this function
scaled_x = MAP( x, 77, 930, 0.25, 3.3 )
PRINT scaled_x
will print the sensor reading directly in Volts.
Note that MAP can't improve accuracy, it just performs scaling.
x= MAX (expression1, expression2)
MAX evaluates both expressions and assigns the larger result to x.
x$=MID$(<string>,<index>,<num characters>)
Returns the <num characters> characters starting at index <index> in string <string> as a new string. If <num characters>=-1 or is omitted then the remainder of the string to the end is returned.
x=MIN( expression1, expression2)
MIN evaluates both expressions and assigns the smaller result to x.
MID$(<string>,<index>,<num characters>)=<substring>
Substitutes characters from <substring> into <string> starting at index <index>. If <num characters> is specified, then it substitutes only <num characters> into <string> (if that many are available), or if not specified, substitutes all the characters from <substring>. The string <string> is extended if the <substring> overwrites the end of <string>.
NEXT <variable>
Ends a FOR/NEXT loop (see FOR).
ONERROR <label:>
On an error, jump to the line labeled by <label:>. Note that after an error is trapped, ONERROR must be reissued to trap another error (to prevent a potential infinite loop). Omitting the label restores built-in error handling (which terminates program execution). This is useful with ERR() to get the error code, and ABORT to unwind the GOSUB/REPEAT-UNTIL/FOR-NEXT stacks. Note that the destination label must end in a colon.
OUT, OUTPIN
Used to set the direction of a general purpose pin to Output in preparation for using the OUTD keyword. See the PINMODE, IND and OUTD keywords.
OUTD <pin #>,<state>
Output a low for state=0, or a high for state=1 to the pin number denoted by <pin #>. The <pin #> refers to the pin number on the DIP40 module. Pin4 and Pin5 is normally used for I2C and is open drain, requiring external pull-ups for use as digital outputs. The actual port number corresponding to <pin #> is given in the following table:
TBD
Use the command PINMODE <pin #>, OUT first to set up the pin as a GPIO output.
OUTDAC <value>
Outputs an analog signal on the DAC proportional to <value>. Currently only DAC 0 is supported (there is only one DAC on the LPC2136). Must do PINMODE 24, DAC on LPC2136 to set up the DAC as an output pin first. For an alternative "analog" output signal, see PWM.
x=PEEK(<address>)
Reads the memory location <address> and returns the 32-bit value. PEEK and POKE to addresses that don't exist causes a 'bus fault' requiring a reset to recover from the fault state. If you want only a byte you can do bitwise-AND for example:
x=PEEK(<address>) & 0xFF
PINMODE <pin #>,<function>
PINMODE sets up the pin <pin #> to have function denoted by number <function>. The <pin #> is the pin on the 40 pin DIP module. The actual port address corresponding to <pin #> is given in the following table:
If <pin #> is not available as an IO pin the interpreter will print an error message.
The meaning of the function number depends on the pin. Here are the examples of how to use PINMODE, for the LPC2136:
PINMODE x,IN - set up any pin as digital input
PINMODE x,INPIN - set up any pin as digital input
PINMODE x,OUT - set up any pin as digital output
PINMODE 21,PWMPIN - sets pin 21 as a PWM output
PINMODE 7,ADC - set up pin 7 as ADC input
PINMODE 25, DAC - set up pin 25 as DAC output
The phantom 'pin' numbers 41, 42, 43 and 44 give access to the on board LED's. The mapping is as follows:
Pin 41 Red LED
Pin 42 Yellow LED
Pin 43 Green LED
Pin 44 Blue LED
To turn the Blue LED on use these two commands:
PINMODE 44, OUT
OUTD 44, 0
To turn the BLUE LED off use this command:
OUTD 44, 1
PORT( <port number>)
x=PORT(0) returns the value of all the pins of Port 0. Legal values for <port number> is 0 and 1.
Bit 0 in PORT(0) corresponds to P0.0 ... Bit 31 in PORT(0) corresponds to P0.31.
Bit 0 in PORT(1) corresponds to P1.0 ... Bit 31 in PORT(1) corresponds to P1.31.
PORT0, PORT1 = <bits to set>
PORT0 and PORT1 gives direct access to the register controlling the digital output pin values.
POKE <address>,<value>
Writes the memory location at location <address> with the 32-bit value <value>.
PEEK and POKE to addresses that don't exist causes a 'bus fault' requiring a reset to recover from the fault state.
x=PORT( <0 | 1>)
Reads all 32 bits of input port 0 or 1 at once. Pin direction must still be set with PINMODE
PORT0 ( <pins> )
PORT1 ( <pins> )
Write pins to the register that controls the digital output pins on port 0 or port 1. Pin direction must still be set with PINMODE
PRINT <number>
PRINT <string>
PRINT <v1>,<v2>,...
PRINT <v1>,<v2>,TAB(20),... ;
? "X= ", x
Writes characters to the terminal. The ASCII representation of a number in decimal is output for a number, or the characters of a string for a string. Multiple values can be output to the terminal in the same PRINT statement if separated by commas. By placing a semicolon at the end of the line, no linefeed is output at the end of the PRINT statement. The "?" character can be used as an alias for PRINT. TAB(x) produces space characters until the cursor is at column x.
PULSIN( pinno, level, timeout)
The PULSIN instruction measures the duration of a pulse on the specified pin. The instruction waits for the pin to go to the opposite of the specified level and starts counting on the next edge and keeps counting till the edge of the opposite polarity appears. If the edges take to long to appear then the instruction will return with a value of zero. Timeout is specified in increments of 100us i.e.,
pulsewidth=PULSIN( 20, 1, 10000)
will measure the positive width of the pulse on pin 20 and return 0 if it did not find a pulse within 1 second. The value returned is in microseconds. The resolution of the measurement is 2us but the accuracy is +- 4us or +-0.5% whichever is bigger.
PULSOUT pin,duration, level
The PULSOUT instruction generates a pulse on the specified pin with a duration specified in microseconds. The instruction will leave the pin in the opposite state of level but will not change it before the pulse is generated. The pin must be configured as a digital output pin before using the PULSOUT instruction. The minimum pulse width is around 5us, the maximum is 2100 seconds. Increments of 2us in the duration causes a change in duration of about 2us, 1us increments may not produce an increment in pulse width but may affect the jitter in pulsewidth. Pulses produced by this instruction is always slighty longer than the specified length. Very precise signals can be generated by the PWM instruction on a limited number of pins.
PWM <pin #>,<total count>,<fractional count>
Outputs a pulse width modulated output signal on PWM <pin #>. <pin #> is 9,21,36 or 37 LPC2136 DIP module. PWM Must prepare the pin first using the appropriate PINMODE command. The duty cycle set up on the pin is given by <fractional count> divided by <total count>. The <total count> divides a frequency of 30MHz to get the PWM frequency. By using a low pass filter on the pin one can obtain an analog signal proportional to the duty cycle. NOTE: all of the PWM channels have the same <total count>, so changing the <total count> for one channel changes <total count> for the rest of them. Therefore one should usually pass the same total count value to all pins when using the PWM command.
REM <remark>
Allows a comment to be placed in the code. If the comment is not in quotes, it will be tokenized e.g.: REM I want to print the value will turn into REM I want to PRINT the value Alternatively, REM "I want to print the value" is not changed. Use ' instead.
' <remark>
Allows a comment to be placed in the code. The comment ends at the end of the line.
REPEAT
Repeats a section of code until a corresponding UNTIL condition is satisfied. Do not GOTO or IF/THEN out of a REPEAT/UNTIL loop. If you skip over the UNTIL the loop with not be properly unwound. Always use the UNTIL to exit the REPEAT/UNTIL loop.
x$=RIGHT$(<string>,<num characters>)
Returns the last <num characters> characters of string <string>.
x=RND(<number>)
Returns a pseudorandom number between 0 and <number>-1 if <number> is positive. If <number> is negative, the value -<number> is used to seed the random number generator. See http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html for the algorithm employed.
RETURN
Return to the statement after the calling GOSUB command.
SERBNG <ercode>=SERBNG(<pin #>,<speed>,<string>)
Outputs a RS232 compliant serial stream on the <pin #> pin with 8 bits, 1 stop bit, no parity. This is bit-banged so any pin can be used to output data. The <speed> is how long each bit should be delayed. For a 60 MHz controller, speed=367 corresponds to 9600 bps. For example, speed=92 would correspond roughly to 38400 bps. The <string> is the string data to output to the pin as serial data.
SERINIT <port #>,<baud rate>,<databits>,<stopbits>,<parity>
Initializes the serial port denoted by <port #>. Currently two serial ports are supported denoted by <port #>=0 and <port #>=1. <baud rate> is in bps. <databits>=7 or 8 for the number of data bits, <stopbits>=1 or 2 for the number of stop bits, and <parity>=0 for no parity, <parity>=1 for odd parity, and <parity>=2 for even parity.
<instring>=SERINP$(<port #>,<numchars>,<endchar>,<timeout>)
Reads up to <numchars> from serial port <port #>. If <numchars> is negative, then -<numchars> characters will be read, but discarded, which is useful for clearing the receive queue. It will stop receiving characters if the character denoted by <endchar> is received and <endchar> is not a negative number. The number <timeout> is proportional to the amount of time to wait for the characters to arrive before the SERINP$ function terminates. Currently its about <timeout>=50000 per second. Set <timeout>=1 to return with only the queued characters. A string is returned with the characters received. See SERINIT to set the serial port parameters.
x=SEROUT(<port #>,<string>)
Send the characters in <string> out serial port number <port #>. The return code currently is zero, but would be negative for an error code. See SERINIT to set the serial port parameters.
SERSPI <spibytein>=SERSPI(<MOSI pin>,<MISO pin>,<CLK pin>,<output data>, <delay>)
Clocks out an 8-bit byte using the SPI master protocol with CPOL=0 and CPHA=0 (Type 0). <MOSI pin> is used as the MOSI pin (must be an output pin), <MISO pin> is used as the MISO pin (must be set as an input pin), <CLK pin> is the clock pin (an output pin), and <output data> is a byte to output. <delay> controls the speed at which the clock is toggled, larger values result in lower clock rates. The data received on MISO is returned by the function. The chip select lines must be controlled by OUTD commands.
STEP
See the FOR keyword.
SSTEP
Breaks program execution and Invokes the single stepping function. Can be used anywhere in the program where an instruction is allowed. To break into the debugger when a variable, lets say x, has a particular value is easy: Place this code where the value of x is changed:
IF x=10 THEN
SSTEP 'Breakpoint
ENDIF
and when x=10 the program will start in single step mode.
TAB(x) produces space characters until the cursor is at column x. Only useful in the PRINT command.
x$=STRING$(<repeats>,<string>)
Return a string with the string <string> repeated <repeats> times.
x$=TIME$
Gets the current time from the RTC to a string in the format "YYYY-MM-DD HH:MM:SS" where YYYY is the year, MM is the month, DD is the day, HH is the hour (in 24 hour format), MM is the minute, and SS is the second. For the RTC to maintain the date and time when the main power is removed a Lithium coin cell must be connected between pin 38 and ground. There is an on board switch over circuit and the battery will only be used to power the RTC when the main power is unavailable or below 3V.
x=TIMESET(<setstring>)
Sets the time, with a string in the format "YYYY-MM-DD HH:MM:SS"
Returns zero for no error, or a negative number for error (improperly formatted string).
TONE <pin #>,<duration>,<frequency>
Toggle the pin <pin #> high and low for a duration of <duration> milliseconds at a frequency of <frequency> cycles per second (Hz). The pin must be set as a GPIO output first, e.g. PINMODE <pin #>, OUT. The frequency is not very accurate.
x$=TRIM$(<string>,<mode>)
Returns a new string with the spaces, tabs, newlines, and carriage returns removed from the end of the string if mode=0, or the beginning of the string if mode=1. If mode is omitted, mode=0 is assumed.
UNTIL <condition>
If the <condition> is false, return to the last REPEAT, otherwise continue with the next statement. Do not skip over an UNTIL with a GOTO/b statement, the UNTIL must always evaluate to true to remove UNTIL from REPEAT/UNTIL stack.
<condiftion> may contain the following test for equality: =, <, >, <=, >= and they may be combined with AND and OR to form complex conditionals.
x$=UPPER$(<string>,<mode>)
Returns a new string with the letters A-Z converted to uppercase if mode=0, or lowercase if mode=1. If mode is omitted, uppercase conversion is assumed.
x=VAL(<string>)
Returns a numerical representation of the string <string>.
x=VALLEN(<string>)
Returns the number of characters in the numerical representation of the string <string>. e.g.
x=VALLEN("100")
assigns 3 to x.
x=VALLEN("100blah")
assigns 3 to x
WAIT <milliseconds>
Waits a certain number of milliseconds. Also see DELAY.
WEND
End of a WHILE loop. See WHILE.
WHILE <condition>
If the <condition> is true then the instructions between the WHILE and the matching WEND keyword is executed. If the <condition> is false then the program execution resumes at the line following the matching WEND keyword. WHILE can be nested inside other WHILE blocks. <condiftion> may contain the following test for equality: =, <, >, <=, >= and they may be combined with AND and OR to form complex conditionals.
=, +, -, /, *, ** , &, |, ^, ~, LSL, LSR
Tests for equality
=, <, >, <=, >=, AND, OR
The BASIC key words:
ABORT <label:>
Jumps to line denoted by <label:>. Unwinds all GOSUB, REPEAT/UNTIL, and FOR/NEXT loops. Good for error recovery to ensure the program will continue to run.
x=ABS(<number>)
Takes the absolute value of number.
x=ASCII(<string>)
Returns an integer 0 to 255 giving the character code value of the first character of <string>. An alternative x=ASCII(<string>,n) gives the code of the nth character or -1 if the string does not an nth character.
x$=BIN$(x,<digits>)
Compute the string equivalent of the integer x. <digits> is the number of characters to put in x$. Negative <digits> is big-endian, positive <digits> is little endian. This is the inverse function of BSTR.
BOLD <value>
A non-zero value outputs a VT100/ANSI code to turn on bold type, a zero value turns off bold.
x=BSTR(x$,<digits>)
Return the integer equivalent of the binary value of x$. <digits> is the number of digits to use in x$. For a positive value of digits the binary is interpreted from right to left. For a negative value of digits the binary string is interpreted from left to right. Example:
x$="1101"
PRINT BSTR(x$, 4)
prints 13
and
x$="1101"
PRINT BSTR(x$, -4)
prints 11.
Negative <digits> is big-endian, positive <digits> is little endian. This is the inverse function of BIN$
x$=BYTE$(x,<bytes>)
Returns the string equivalent of x. <bytes> is the number of bytes to use in x$. For a positive value of bytes x is converted from right to left. For a negative value of bytes x is converted from left to right.
x= BYTESTR(x$, 4)
Returns an integer value when x$ is interpreted as a numerical value. <bytes> is the number of bytes to use in x$. For a positive value of bytes the string is converted from right to left. For a negative value of bytes the string is converted from left to right. BYTESTR is very useful in converting data read in the I2C or SPI bus to numerical values.
CHR$(<value>)
Returns a string with a single character with character code <value> (from 0 to 255).
CLREOL
Outputs a VT100/ANSI code to clear the current line from the cursor position to the end of the line.
CLRSCR
Outputs a VT100/ANSI code to clear the screen and place the cursor at the upper left corner.
x$=CONF$(<confstring>)
Reads the configuration variable out of the Configuration Flash and places it into x$. For example if there was a line in the Configuration Flash such as NAME=John Do then Name$=CONF$("NAME") places "John Do" into Name$. The configuration space is in Flash memory and is 4k byte in size. The space is organized as an array of strings in the form Identifier="Content String" CR LF where the CR LF characters mark the end of a string. The Configuration Flash is not intended as a general purpose EEPROM replacement and can not be written from within the BASIC program.
x=COUNT(< pin, duration>)
Counts the number of transitions on input pin in the number of 100us intervals specified by duration. For example x=COUNT(21, 10000) sets x to the number of edges on pin 21 in the next second. Pin 21 must be configured as a digital input with PINMODE before COUNT is called.
DAC
Used with PINMODE to configure a pin as the DAC output.
DELAY <100microseconds>
Waits an integer number of 100microsecond ticks. See WAIT
DIM A(<index 1>)
DIM A(<index 1>,<index 2>)
DIM A$(<index 1>)
DIM A$(<index 1>,<index 2>)
These commands create arrays of strings or numbers, either one,two or three dimensional. These can be initialized to particular values by using the =, e.g.
DIM A(10)=20,18,16,14,12,10,8,6,4,2
DIM NAME$(7)="Joe","Frank","John","Bill","Bert","George","Simon" or
x=0
y=1
z=2
DIM position(3)=x,y,z
declares an array that hold three numbers and initializes it to 0,1,2.
END
Terminates the program. An END instruction may be placed before the subroutine definition.
ENDIF
Terminates the IF statement.
x$=ERC$(<error code number>)
Return a string describing the error associated with error code number. If the number is negative, then the function returns the string representing the last error.
x=ERR(0)
The function retrieves the error code of the last error for ONERROR. Reading this clears the error code so subsequent accesses return 0 until another error occurs. x=ERR(1) This retrieves the line number of the last error for ONERROR. Reading this clears the line number of the error so subsequent access return 0 until another error is thrown. In the editor, the line number of a particular statement can be jumped to by using the CTRL-G command.
FOR <var>=<begin> TO <end> STEP <step>
Iterates <var> starting at <begin> until it reaches <end>, each time through the loop incrementing the step size the value <step>. <step> may be negative if <end> is smaller than <begin>. The end of the loop is NEXT <var>.
e.g.
FOR I=99 TO 1 STEP -1
PRINT I," days till Christmas."
NEXT I
GETTICK
Returns a number that increments every 100us. Very useful for doing timeouts.
start = GETTICK
REPEAT
REM Execute some code for a second
UNTIL GETTICK > ( start + 10000 )
Can also be used to determine how long a piece of code takes to execute. The number will eventually overflow, after a few days. See SETTICK
GOSUB <label:>
Calls a subroutine at the line labeled with <label:>. Control returns to the statement after the GOSUB command when a RETURN is encountered. Note that the destination label must end in a colon.
GOTO <label:>
Jumps program execution to the line labeled by <label:>. Note that the destination label must end in a colon. Use sparingly.
x$=HEX$(<number>)
Returns a string representation of the unsigned hexadecimal equivalent of <number>. Decimal can be returned with STR$.
HI <pin_no1>, <pin_no2>, ...
HI sets the digital output pins in the list of pins to a HIGH state. See LO.
x=I2CBUSY ( < slave address> )
I2C Routine, Return Slave Status
Some I2C devices such as EEPROM's need a variable time to complete commands. This instruction provides an easy way to poll the status of such a device.
I2CER$( <error code>)
I2C Routine, Return error or status string
This instruction is used in conjunction with the I2CERR function to print error messages when the I2C bus transactions fail. The I2CERR instruction is used to retrieve the error code from the I2C subsystem. That code is used as a parameter to the I2CER$ instruction to get an ASCII string that can be printed directly to indicate the source of trouble on the I2C bus.
x=I2CERR
I2C Routine, Return error or status code
The I2CERR function returns the last status or error code reported by the I2C controller function. The same numerical values are used as defined in the LPC2136 User Manual, Chapter 13, Table 167 and Table 168. This is for advanced debugging of bus problems. See the I2CER$ instruction for more readable error and status reporting. Returns 0 if there was no error.
I2CINIT( <clock speed> )
I2C Routine, Initialize the I2C subsystem before use
Sets Pin 4 and Pin 5 as Open Drain pins and sets the frequency of SCLK in Hz. I2CINIT( 100000 ) initializes the controller for 100kHz devices. The Pins are 5V tolerant and may be pulled up to 5V to directly drive 5V IC's.
I2CRD$ ( <slave address>, < register to read>, <number of bytes> )
I2C Routine, Random Read
Instruction to read data from register in a slave device. If the number of bytes to read is greater than one the read is from consecutive addresses (registers) in the slave device. The maximum number of bytes that can be read is 64 (limited by the internal buffer of the EZSBC1) or the number of bytes supported by the slave device.
I2CRDS$ ( <slave address>, <number of bytes> )
I2C Routine, Sequential Read
Instruction to read data from the I2C slave device starting from the byte following the previous address or register read by the I2CRD$ instruction.
I2CTIME( < time to wait > )
I2C Routine, Set Bus Timeout
When the I2C bus is accessed it is possible for the transaction to fail due to noise or protocol failure. <time to wait> specifies the time in units of milliseconds that the EZSBC1 allows before abandoning an I2C transaction.
I2CWR(<slave address>, < register to read>, <data string>, <number of bytes>)
I2C Routine, Write to one or more bytes to a slave device
This instruction write the data in <data string> to a register or consecutive registers or addresses of a slave device. The internal buffer of the EZSBC1 used for the write is 64 bytes.
IF <condition> THEN
<program lines>
ENDIF
IF <condition> THEN
<program lines>
ELSE
<program lines>
ENDIF
If the condition is true, then the program executes the program lines up to ENDIF. If ELSE is included, then execute the program lines between ELSE and ENDIF if the condition is false. IF statements may be nested.
<condiftion> may contain the following test for equality: =, <, >, <=, >= and they may be combined with AND and OR to form complex conditionals.
x=IIF(<condition>,<truevalue>,<falsevalue>)
If the condition is true, then return <truevalue> otherwise return <falsevalue>. Note that both <truevalue> and <falsevalue> are evaluated even though only one is used.
x=1
y=2
PRINT IIF (x<y,x,y)
PRINT IIF(x>y,x,y)
prints
1
2
x$=II$(<condition>,<truestring>,<falsestring>)
If the condition is true, then return <truestring>, otherwise return <falsestring>. Note that both <truestring> and <falsestring> are evaluated even though only one is used.
IN, INPIN
The IN or INPIN keyword is used to set the direction of an IO-pin. See the PINMODE, IND and OUTD keywords.
x=INADC(<ad #>)
Gets the analog value at analog to digital converter numbered from 0-15. The <ad #> from 0-7 corresponds to AD0.<ad #> and the <ad #> from 8-15 corresponds to AD1.<ad #>. Must do a PINMODE first to the appropriate pin to set up the ADC (see PINMODE examples).
x=IND(<pin #>)
Get the digital input at the pin number denoted by . The actual pin for the <pin #> is given in the following table:
Use the PINMODE <pin #>, IN command first to set up the pin as a GPIO input.
x=INKEY
Returns the character code of the currently entered character on the terminal UART0, or -1 if no character is available.
x=INPLEN(<length>)
Sets the maximum number of characters to accept for subsequent INPUT statements. Returns the old INPLEN value. The input length maximum defaults to 80 characters.
INPUT <numerical variable>
INPUT <string variable>
Takes input from the terminal UART0 and places a numerical representation in <numerical variable> of the number entered at the terminal, or into <string variable$> the string entered at the terminal. The entered strings have a maximum size set by the INPLEN commands, which defaults to 80 characters.
x=INSTR(<search string>,<substring>,<index>)
Searches for the first occurrence of string <substring> in the string <search string> that is at or after the character index <index>, with <index>=1 being the first character. If the substring is not found, zero is returned.
INT(<number>)
Returns the integer representation of the number <number>.
x$=LEFT$(<string>,<num characters>)
Returns the first <num characters> characters of string <string>.
x=LEN(<string>)
Returns the number of characters in <string>.
LET <variable>=<expression>
Assigns the variable <variable> to the expression <expression>. If the expression is a string, then the variable must be a string variable. or if the expression is a number then the variable must be a numeric variable. LET is optional, e.g.
X = 5
is a valid statement (the LET may be omitted).
LO <pin_no1>, <pin_no2>, ...
LO sets the digital output pins in the list of pins to a LOW state. See HI
LOCATE <y cursor position>,<x cursor position>
Sends the VT100/ANSI code to the terminal to position the cursor at y position <y cursor position> and x position <x cursor position>.
scaled_x= MAP( x, in_min, in_max, out_min, out_max )
This function maps x that lies in the interval ( in_min, in_max) to a scaled position on the new scale (out_min, out_max)
As an example; You have a sensor with an input range from 0.25V to 3.0V. If it is connected to an ADC channel you will get a range of values from (approximately) 77 to 930 instead of from 0 to 1023. With the MAP function you can scale it to 0 to 1023 like this:
x=INADC( Ch1 )
scaled_x= MAP( x, 77, 930, 0, 1023 )
or this function
scaled_x = MAP( x, 77, 930, 0.25, 3.3 )
PRINT scaled_x
will print the sensor reading directly in Volts.
Note that MAP can't improve accuracy, it just performs scaling.
x= MAX (expression1, expression2)
MAX evaluates both expressions and assigns the larger result to x.
x$=MID$(<string>,<index>,<num characters>)
Returns the <num characters> characters starting at index <index> in string <string> as a new string. If <num characters>=-1 or is omitted then the remainder of the string to the end is returned.
x=MIN( expression1, expression2)
MIN evaluates both expressions and assigns the smaller result to x.
MID$(<string>,<index>,<num characters>)=<substring>
Substitutes characters from <substring> into <string> starting at index <index>. If <num characters> is specified, then it substitutes only <num characters> into <string> (if that many are available), or if not specified, substitutes all the characters from <substring>. The string <string> is extended if the <substring> overwrites the end of <string>.
NEXT <variable>
Ends a FOR/NEXT loop (see FOR).
ONERROR <label:>
On an error, jump to the line labeled by <label:>. Note that after an error is trapped, ONERROR must be reissued to trap another error (to prevent a potential infinite loop). Omitting the label restores built-in error handling (which terminates program execution). This is useful with ERR() to get the error code, and ABORT to unwind the GOSUB/REPEAT-UNTIL/FOR-NEXT stacks. Note that the destination label must end in a colon.
OUT, OUTPIN
Used to set the direction of a general purpose pin to Output in preparation for using the OUTD keyword. See the PINMODE, IND and OUTD keywords.
OUTD <pin #>,<state>
Output a low for state=0, or a high for state=1 to the pin number denoted by <pin #>. The <pin #> refers to the pin number on the DIP40 module. Pin4 and Pin5 is normally used for I2C and is open drain, requiring external pull-ups for use as digital outputs. The actual port number corresponding to <pin #> is given in the following table:
TBD
Use the command PINMODE <pin #>, OUT first to set up the pin as a GPIO output.
OUTDAC <value>
Outputs an analog signal on the DAC proportional to <value>. Currently only DAC 0 is supported (there is only one DAC on the LPC2136). Must do PINMODE 24, DAC on LPC2136 to set up the DAC as an output pin first. For an alternative "analog" output signal, see PWM.
x=PEEK(<address>)
Reads the memory location <address> and returns the 32-bit value. PEEK and POKE to addresses that don't exist causes a 'bus fault' requiring a reset to recover from the fault state. If you want only a byte you can do bitwise-AND for example:
x=PEEK(<address>) & 0xFF
PINMODE <pin #>,<function>
PINMODE sets up the pin <pin #> to have function denoted by number <function>. The <pin #> is the pin on the 40 pin DIP module. The actual port address corresponding to <pin #> is given in the following table:
If <pin #> is not available as an IO pin the interpreter will print an error message.
The meaning of the function number depends on the pin. Here are the examples of how to use PINMODE, for the LPC2136:
PINMODE x,IN - set up any pin as digital input
PINMODE x,INPIN - set up any pin as digital input
PINMODE x,OUT - set up any pin as digital output
PINMODE 21,PWMPIN - sets pin 21 as a PWM output
PINMODE 7,ADC - set up pin 7 as ADC input
PINMODE 25, DAC - set up pin 25 as DAC output
The phantom 'pin' numbers 41, 42, 43 and 44 give access to the on board LED's. The mapping is as follows:
Pin 41 Red LED
Pin 42 Yellow LED
Pin 43 Green LED
Pin 44 Blue LED
To turn the Blue LED on use these two commands:
PINMODE 44, OUT
OUTD 44, 0
To turn the BLUE LED off use this command:
OUTD 44, 1
PORT( <port number>)
x=PORT(0) returns the value of all the pins of Port 0. Legal values for <port number> is 0 and 1.
Bit 0 in PORT(0) corresponds to P0.0 ... Bit 31 in PORT(0) corresponds to P0.31.
Bit 0 in PORT(1) corresponds to P1.0 ... Bit 31 in PORT(1) corresponds to P1.31.
PORT0, PORT1 = <bits to set>
PORT0 and PORT1 gives direct access to the register controlling the digital output pin values.
POKE <address>,<value>
Writes the memory location at location <address> with the 32-bit value <value>.
PEEK and POKE to addresses that don't exist causes a 'bus fault' requiring a reset to recover from the fault state.
x=PORT( <0 | 1>)
Reads all 32 bits of input port 0 or 1 at once. Pin direction must still be set with PINMODE
PORT0 ( <pins> )
PORT1 ( <pins> )
Write pins to the register that controls the digital output pins on port 0 or port 1. Pin direction must still be set with PINMODE
PRINT <number>
PRINT <string>
PRINT <v1>,<v2>,...
PRINT <v1>,<v2>,TAB(20),... ;
? "X= ", x
Writes characters to the terminal. The ASCII representation of a number in decimal is output for a number, or the characters of a string for a string. Multiple values can be output to the terminal in the same PRINT statement if separated by commas. By placing a semicolon at the end of the line, no linefeed is output at the end of the PRINT statement. The "?" character can be used as an alias for PRINT. TAB(x) produces space characters until the cursor is at column x.
PULSIN( pinno, level, timeout)
The PULSIN instruction measures the duration of a pulse on the specified pin. The instruction waits for the pin to go to the opposite of the specified level and starts counting on the next edge and keeps counting till the edge of the opposite polarity appears. If the edges take to long to appear then the instruction will return with a value of zero. Timeout is specified in increments of 100us i.e.,
pulsewidth=PULSIN( 20, 1, 10000)
will measure the positive width of the pulse on pin 20 and return 0 if it did not find a pulse within 1 second. The value returned is in microseconds. The resolution of the measurement is 2us but the accuracy is +- 4us or +-0.5% whichever is bigger.
PULSOUT pin,duration, level
The PULSOUT instruction generates a pulse on the specified pin with a duration specified in microseconds. The instruction will leave the pin in the opposite state of level but will not change it before the pulse is generated. The pin must be configured as a digital output pin before using the PULSOUT instruction. The minimum pulse width is around 5us, the maximum is 2100 seconds. Increments of 2us in the duration causes a change in duration of about 2us, 1us increments may not produce an increment in pulse width but may affect the jitter in pulsewidth. Pulses produced by this instruction is always slighty longer than the specified length. Very precise signals can be generated by the PWM instruction on a limited number of pins.
PWM <pin #>,<total count>,<fractional count>
Outputs a pulse width modulated output signal on PWM <pin #>. <pin #> is 9,21,36 or 37 LPC2136 DIP module. PWM Must prepare the pin first using the appropriate PINMODE command. The duty cycle set up on the pin is given by <fractional count> divided by <total count>. The <total count> divides a frequency of 30MHz to get the PWM frequency. By using a low pass filter on the pin one can obtain an analog signal proportional to the duty cycle. NOTE: all of the PWM channels have the same <total count>, so changing the <total count> for one channel changes <total count> for the rest of them. Therefore one should usually pass the same total count value to all pins when using the PWM command.
REM <remark>
Allows a comment to be placed in the code. If the comment is not in quotes, it will be tokenized e.g.: REM I want to print the value will turn into REM I want to PRINT the value Alternatively, REM "I want to print the value" is not changed. Use ' instead.
' <remark>
Allows a comment to be placed in the code. The comment ends at the end of the line.
REPEAT
Repeats a section of code until a corresponding UNTIL condition is satisfied. Do not GOTO or IF/THEN out of a REPEAT/UNTIL loop. If you skip over the UNTIL the loop with not be properly unwound. Always use the UNTIL to exit the REPEAT/UNTIL loop.
x$=RIGHT$(<string>,<num characters>)
Returns the last <num characters> characters of string <string>.
x=RND(<number>)
Returns a pseudorandom number between 0 and <number>-1 if <number> is positive. If <number> is negative, the value -<number> is used to seed the random number generator. See http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html for the algorithm employed.
RETURN
Return to the statement after the calling GOSUB command.
SERBNG <ercode>=SERBNG(<pin #>,<speed>,<string>)
Outputs a RS232 compliant serial stream on the <pin #> pin with 8 bits, 1 stop bit, no parity. This is bit-banged so any pin can be used to output data. The <speed> is how long each bit should be delayed. For a 60 MHz controller, speed=367 corresponds to 9600 bps. For example, speed=92 would correspond roughly to 38400 bps. The <string> is the string data to output to the pin as serial data.
SERINIT <port #>,<baud rate>,<databits>,<stopbits>,<parity>
Initializes the serial port denoted by <port #>. Currently two serial ports are supported denoted by <port #>=0 and <port #>=1. <baud rate> is in bps. <databits>=7 or 8 for the number of data bits, <stopbits>=1 or 2 for the number of stop bits, and <parity>=0 for no parity, <parity>=1 for odd parity, and <parity>=2 for even parity.
<instring>=SERINP$(<port #>,<numchars>,<endchar>,<timeout>)
Reads up to <numchars> from serial port <port #>. If <numchars> is negative, then -<numchars> characters will be read, but discarded, which is useful for clearing the receive queue. It will stop receiving characters if the character denoted by <endchar> is received and <endchar> is not a negative number. The number <timeout> is proportional to the amount of time to wait for the characters to arrive before the SERINP$ function terminates. Currently its about <timeout>=50000 per second. Set <timeout>=1 to return with only the queued characters. A string is returned with the characters received. See SERINIT to set the serial port parameters.
x=SEROUT(<port #>,<string>)
Send the characters in <string> out serial port number <port #>. The return code currently is zero, but would be negative for an error code. See SERINIT to set the serial port parameters.
SERSPI <spibytein>=SERSPI(<MOSI pin>,<MISO pin>,<CLK pin>,<output data>, <delay>)
Clocks out an 8-bit byte using the SPI master protocol with CPOL=0 and CPHA=0 (Type 0). <MOSI pin> is used as the MOSI pin (must be an output pin), <MISO pin> is used as the MISO pin (must be set as an input pin), <CLK pin> is the clock pin (an output pin), and <output data> is a byte to output. <delay> controls the speed at which the clock is toggled, larger values result in lower clock rates. The data received on MISO is returned by the function. The chip select lines must be controlled by OUTD commands.
STEP
See the FOR keyword.
SSTEP
Breaks program execution and Invokes the single stepping function. Can be used anywhere in the program where an instruction is allowed. To break into the debugger when a variable, lets say x, has a particular value is easy: Place this code where the value of x is changed:
IF x=10 THEN
SSTEP 'Breakpoint
ENDIF
and when x=10 the program will start in single step mode.
TAB(x) produces space characters until the cursor is at column x. Only useful in the PRINT command.
x$=STRING$(<repeats>,<string>)
Return a string with the string <string> repeated <repeats> times.
x$=TIME$
Gets the current time from the RTC to a string in the format "YYYY-MM-DD HH:MM:SS" where YYYY is the year, MM is the month, DD is the day, HH is the hour (in 24 hour format), MM is the minute, and SS is the second. For the RTC to maintain the date and time when the main power is removed a Lithium coin cell must be connected between pin 38 and ground. There is an on board switch over circuit and the battery will only be used to power the RTC when the main power is unavailable or below 3V.
x=TIMESET(<setstring>)
Sets the time, with a string in the format "YYYY-MM-DD HH:MM:SS"
Returns zero for no error, or a negative number for error (improperly formatted string).
TONE <pin #>,<duration>,<frequency>
Toggle the pin <pin #> high and low for a duration of <duration> milliseconds at a frequency of <frequency> cycles per second (Hz). The pin must be set as a GPIO output first, e.g. PINMODE <pin #>, OUT. The frequency is not very accurate.
x$=TRIM$(<string>,<mode>)
Returns a new string with the spaces, tabs, newlines, and carriage returns removed from the end of the string if mode=0, or the beginning of the string if mode=1. If mode is omitted, mode=0 is assumed.
UNTIL <condition>
If the <condition> is false, return to the last REPEAT, otherwise continue with the next statement. Do not skip over an UNTIL with a GOTO/b statement, the UNTIL must always evaluate to true to remove UNTIL from REPEAT/UNTIL stack.
<condiftion> may contain the following test for equality: =, <, >, <=, >= and they may be combined with AND and OR to form complex conditionals.
x$=UPPER$(<string>,<mode>)
Returns a new string with the letters A-Z converted to uppercase if mode=0, or lowercase if mode=1. If mode is omitted, uppercase conversion is assumed.
x=VAL(<string>)
Returns a numerical representation of the string <string>.
x=VALLEN(<string>)
Returns the number of characters in the numerical representation of the string <string>. e.g.
x=VALLEN("100")
assigns 3 to x.
x=VALLEN("100blah")
assigns 3 to x
WAIT <milliseconds>
Waits a certain number of milliseconds. Also see DELAY.
WEND
End of a WHILE loop. See WHILE.
WHILE <condition>
If the <condition> is true then the instructions between the WHILE and the matching WEND keyword is executed. If the <condition> is false then the program execution resumes at the line following the matching WEND keyword. WHILE can be nested inside other WHILE blocks. <condiftion> may contain the following test for equality: =, <, >, <=, >= and they may be combined with AND and OR to form complex conditionals.
basic language reference, basic keywords, pbasic keywords, basic syntax, basic instructions, basic reserved words, basic functions, basic commands , pbasic syntax