## Core Statements

These are the "core" statements, very similar to the other BASIC dialects.

BEEP [v|n1[, v|n2]]

Generates a beep sound.

Notes:

- the v|n1 parameter is the number of beeps to play. If not set, beep once
- the v|n2 parameter is the type of sound to play (if not set, the Info beep is played):
  1=Info 2=Warning 3=Error 4=StartUp
  5=Alarm 6=Confirmation 7=Click
- For more than just a beep see SOUND and PLAYWAVE

BEGIN
Statement(s)
END

Entry point and last instruction of the program.

Notes:

- both BEGIN and END must be defined
- only the last BEGIN is taken into account by iziBasic if you input several of them, but you can have several END instructions.

BREAK

Break program execution (for debugging purposes...)

CALL v|n

Call an assembler-like subroutine at address v|n in the code stack.

Notes:

- not to be used until I provide a documentation of how to build assembler-like routines in the Code Stack
- meanwhile, you can use PEEK and POKE to store [0...65535] values in the Code Stack, making sure you do not override the used Code Stack (see FRE function)

$ CHAIN t

The program execution will chain to the "NameOfProgram.ibas" given in t, starting at the BEGIN statement of "NameOfProgram".

Notes:

- the Code Stack will be emptied and refilled with the new program code which will start at its BEGIN point
- Numbers and Texts Stacks are not emptied, so values are passed to the new code. Would you wish to empty them too, just use the CLEAR statement.
- But the MegaString is emptied, so, if you need it in the new code segment, you should save its content to a temporary file before chaining and reload it from this file in the new code segment.

CLEAR [v-v|c-c]

Clear all A-Z NumVars (set to 0) and A$-Z$ CharVars (set to empty text string ""), a range of Numvars only, or a range of CharVars only

CONST c=t

Define c as a text constant.

Notes:

- Doing C$="Some text" will reserve 1 space in the Text stack, when CONST C$="Some text" will only require no extra space but C$ which is always reserved.

CONST v=n

Define v as a numerical constant.

Notes:

- Doing C=123 will reserve 1 space in the Number stack, when CONST C=123 will only require no extra space but C which is always reserved.

DEC v

Decrements v by one unit (equivalent to v=v-1).

$ DIM %var%|%var$[, %var%|%var$] [...]

Defines one or several custom Number or Text variable(s), in addition to A-Z and A$-Z$ which are automatically defined.

Notes:

- A user defined variable must be prefixed with the % character and end with the % character for Number variables or the $ character for Text variables
- A user defined variable should not have more than 20 characters, including the prefix character (%) and the ending character (% or $)
- User defined variables are not case sensitive, therefore %MyVar$ is the same thing as %MYVAR$ or %myvar$
- You can put up to 255 user defined variables and labels in one source code
- DIM must be defined before the iziBasic compiler reserves some space in the Numbers stack for its use, so you should place your DIM at the top of your program, just after the Compiling Directives

DO
Statement(s)
LOOP v|n/c|t TestOper v|n/c|t

DO implements a number of loops. The program will exit from the loop when the condition after the LOOP statement is met.

Notes:

- equivalent to REPEAT/UNTIL
- the statement in loop will be executed at least once (on the difference of WHILE/WEND which check the condition before looping)

GOTO label

GOTO branches program execution to the specified label

GOSUB label

GOSUB initiates a subroutine call to the specified label. The subroutine must end with RETURN. It will then carry on with the statement following the GOSUB one.

label:
Statement(s)
RETURN

FOR v = v|n1 [DOWN]TO v|n2 [STEP v|n3]
Statement(s)
NEXT

FOR initiates a FOR/NEXT loop with the variable v initially set to v|n1 and incrementing (TO) or decrementing (DOWNTO) in v|n3 steps (default is 1 for TO and -1 for DOWNTO) until v equals v|n2.

IF v|n/c|t TestOper v|n/c|t Statement

IF evaluates the given expression and performs the Statement if it is true.

Notes:

- the Statement can be any single statement or multiple statements (separated by the ":" character) but a non completed "block statement" (like IF THEN [ELSE] END IF, SELECT CASE/END SELECT statement, REPEAT/UNTIL, ...). Indeed this syntax of the IF statement is equivalent to this one: IF test THEN Statement : ENDIF (see below), so there is a risk of bad indentation of the quiet ENDIF of this syntax.
- Multiple IF statements can be imbricated this way: IF test1 IF test2 Statement. This is similar to: IF test1 AND test2 Statement (which is not valid in iziBasic’s syntax)

IF v|n/c|t TestOper v|n/c|t THEN Statement
[ELSE Statement]
END IF

IF evaluates the given and performs the THEN statement if it is true or (optionally) the ELSE statement if it is FALSE, ending with END IF.

Notes:

- Statements can be put on the next line after THEN and ELSE. Example:

  IF A=1 THEN B=2:C=3 ELSE B=3 END IF |  | IF A=1 THEN B=2:C=3 ELSE B=3 END IF

INC v

Increments v by one unit (equivalent to v=v+1).

[LET] c = c|t|s [+ c|t|s] [...]
[LET] v = v|n|f [MathOper v|n|f] [...]

LET assigns the value of the expression after the "=" sign to the variable c/v. iziBasic supports implied LET statements, meaning that the LET statement is optional.

Notes:

- s can also be a A$(v|n), please see Arrays
- f can also be a A(v|n), please see Arrays
- please see the PARSER compiling directive

POKE v|n1, v|n2

Puts value v|n2 at address v|n1 in the code stack

Notes:

- v|n1 should be in the [FRE(0)..FRE(3)] range. Be careful not to POKE under the address returned by the FRE(0).function as it will corrupt the compiled code by iziBasic and your program will behave in a strange manner if you do so!
- v|n2 has to be a [0...65535] value.

POP c|v

Returns top Text stack value in the c variable, or the top Number stack value in the v variable. The Text or Number stack is then decremented by one unit, meaning that it then points to the last but one top value.

PUSH c|t|v|n

Increments the Text or Number stack by one unit. It then puts the c|t value to the Text stack, or the v|n value to the Number stack.

REM or '

REM and ' allow remarks to be included in a program. As currently implemented, the entire remaining text on a line following REM (or ') is ignored by the iziBasic compiler.

Notes:

- A REM comment should be preceded by a statement delimiter (":") if not at the beginning of a line; this is not required for the ' format.
- It is a good habit to comment as much as possible your source code, it allows easier reading back and understanding of it later on!

REPEAT
Statement(s)
UNTIL v|n/c|t TestOper v|n/c|t

Equivalent to DO/LOOP.

SELECT CASE v|c
CASE n1|t1
Statement
[...]
[CASE nn|tn
Statement]
[CASE ELSE
Statement]
END SELECT

SELECT CASE introduces a multi-line conditional selection statement. The v (or c) variable given as the argument to SELECT CASE will be evaluated against numerical (or text) values by the CASE statements following. If no evaluation was successful, the CASE ELSE statement will be executed. The SELECT CASE statement concludes with an END SELECT statement

Notes:

- only the first true condition will be executed so make sure the conditions are unique
- you may have up to 255 CASE items in a SELECT CASE/END SELECT
- up to 89 SELECT CASE/END SELECT statements can, as from version 6.0 of iziBasic, be imbricated one into another, meaning that up to 89 successive CASE items may include themselves a full SELECT CASE/END SELECT group

SLEEP v|n

Does nothing during v|n seconds

Notes:

- would you wish to have your program wait for less than one second, then use a routine with the TICKS and TICKSPERSEC functions

SWAP v/c, v/c

As its name states it, SWAP swaps the values of two variables.

WHILE v|n/c|t TestOper v|n/c|t
Statement
WEND

WHILE implements a number of loops, delimitated with the WEND statement. The program will exit from the loop as soon as the condition after the WHILE statement is met.

Notes:

- on the difference of DO/LOOP and REPEAT/UNTIL the condition is checked before looping. So it might never be executed if the condition is met at the very beginning.