Skip to reading
BASIC Scripting

Read operators in a line of BASIC

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

THE BASIC LANGUAGE

The same equals sign can assign or compare. Read the whole line. In coins = 3 it sets a value. In IF coins = 3 THEN it asks a question.

Source table from Read operators in a line of BASIC, page 9
Arithmetic+ adds, − subtracts (type the plain minus key), * multiplies, / divides, and MOD gives the remainder. For 17 MOD 6 the answer is 5.
AssignmentUse =, +=, -=, *= and /= to update a variable. Use CONST if later reassignment should produce a validation error.
ComparisonUse = and <> for equal and unequal. Use <, <=, > and >= for ordered comparisons.
LogicAND needs both tests to succeed. OR needs either one. NOT reverses a test. ANDALSO and ORELSE are short-circuit aliases.
Join textUse & between pieces of text. Parentheses make the order clear when you mix arithmetic with concatenation.

Predict the result#

Code example
DIM coins = 3
DIM has_pass = FALSE
DIM admitted = coins >= 2 OR has_pass
PRINT "Admitted: " & admitted

This is a fragment for Run. The left half of OR is true because three is at least two. Admitted is therefore true. Set coins to 1 and has_pass to FALSE to reach the other result.

Page 9 of 86Permalink
Go to page