EMMA 02

BASIC

  • Home
  • Download
  • Change Log
  • Help
  • Compilation
    • Windows
    • OS X
    • Ubuntu
    • Fedora
    • openSUSE
  • Forums
  • Tape Conversion
  • Machine Code
    • SYSTEM00
    • CDP1801
    • CDP1802
    • CDP1804
    • CDP1805
    • Differences
  • Pseudo Code
    • AMVBAS
    • AM4KBAS
    • CARDTRAN
    • Chip-8, 8X, ETI-660 & Elf
    • FEL-1
    • FPA-1
    • FPL-2
    • FPL-4
    • GPL-2
    • GPL-3
    • GPL-4
    • GPL-A (2K RAM)
    • GPL-A (2K ROM)
    • ST2
    • ST4
    • STK
    • Test-Word
    • Super-chip
  • XML Code
    • Main Elements
    • I/O
    • System
    • A/D Convertor
    • BASIC
    • Batch wav
    • Bootstrap
    • Cassette
    • CD4536B
    • CDP1851
    • CDP1852
    • CDP1854
    • CDP1855
    • CDP1877
    • CDP1878
    • CDP1879
    • Debugger
    • COMX Diagnostic
    • Dip switch
    • Disk
    • EF Buttons
    • Flip Flop
    • Front Panel
    • GUI
    • HEX Modem
    • I/O Group
    • Keyboard
    • Keyfile
    • Locations
    • Memory
    • MM57109
    • Printer
    • RTC
    • Sound
    • Splash
    • USB
    • Video
    • Videodump
    • vt
    • X Modem
  • BASIC
    • General Information
    • COMX BASIC V1.00
    • Floating Point BASIC 2.2
    • Pecom 32 BASIC
    • Pecom 64 BASIC 1.0 & 4.0
    • Quest Super BASIC 1.4
    • Quest Super BASIC 3.0
    • Quest Super BASIC 5.0
    • Quest Super BASIC 6.0
    • RCA BASIC3 V1.1
    • Telmac SBASIC v24.3
    • Error Messages
  • Computer List

 

 

 

 

 

 

 

 

 

 

 

 

IF THEN

Format:
IF string reference <> string expr THEN statement
IF string reference = string expr THEN statement
IF expr (relational operator) expr THEN statement

Supported by: COMX BASIC V1.00, Floating Point BASIC 2.2, Pecom 32 BASIC, Pecom 64 BASIC 1.0 and 4.0, Quest Super BASIC 5.0 and 6.0, RCA BASIC3 V1.1, Telmac SBASIC v 24.3

Similar commands:
Quest Super BASIC 1.4 and 3.0: IF THEN

This statement is a conditional statement but it is not only a conditional branch. It tests for a condition, and if the condition is met, a statement or group of statements (separated by colons) is executed. If the condition is not met, then execution continues at the next line number. When string relations are compared, an equal or not equal sign is the only acceptable relation. In the case of arithmetic expressions, the following are acceptable relational operators:

=equal to
<>not equal to
>greater than
<less than
>=greater than or equal to
<=less than or equal to

The mode of the first expression defines the mode of the second expression. An example of a conditional statement follows.

10 IF A=B THEN PR A: WAIT (200): GOTO 200
20 PR B

In this case, if the value of A is equal to the value of B, then the value of A will be printed, a delay will occur and execution will continue at line #200. If A is not equal to B, then the value of B is printed and execution continues from line #20 onward.

One additional point to be made is that the keyword THEN is optional and need not be used. A common mistake to be avoided is the following.

IF A>N THEN 200

Anything to the right of THEN, if it appears, is to be an executable statement. The number 200 is not an executable statement. The correct version would be as follows.

IF A>B THEN GOTO 200

or

IF A>B GOTO 200

Some more examples of acceptable IF statements are given below. Note the multiple conditions in the last example. If any of the conditions are not met, execution continues at the next line number. If all of the conditions are met, execution will finally get transferred to line #500 by means of the GOTO statement. It follows that the GOTO statement could have been any executable statement.

10 IF A(2)*B(1) >= C*SIN (A) PR A: GOTO 50
10 IF A$(2) = "LIST" LET B=3: GOTO 100
10 IF B$(A+B) = MID$ (A$, 2, 4) PR "OK"
10 IF MID$(A$(5), 2, 4) = "EBCD" PR "MATCH": GOTO 500
10 IF A$=B$+C$ THEN GOSUB 200: CLS: PR "DONE"
10 IF A=INT(S/5) IF B>10 IF C<5 goto 500