Skip to reading
PCA Script Programming

7. Assignment and arithmetic

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
Source table from 7. Assignment and arithmetic, page 14
MeaningReadable formCompact form
Assignset score to 10score = 10
Addadd 5 to scorescore += 5
Subtractsubtract 1 from scorescore -= 1
MultiplyUse compact formscore *= 2
DivideUse compact formscore /= 2
Reverse a Booleantoggle readyready = not ready
Code example
function run()
    let score = 10
    add 5 to score
    score *= 2
    let average = score / 4
    let remainder = 11 % 3
    return [score, average, remainder, -score]
end

+, -, *, / and % mean add, subtract, multiply, divide and integer remainder. Division returns a number with a fractional part when necessary. % works with integer values. Avoid a zero divisor. There are no

++, --, exponentiation or bitwise operators in PCA Script 1.0.

+ also joins text, and joins two arrays into a new array. If either operand is text, the other is converted to text. Add parentheses when a line mixes text and arithmetic: "Score: " + str(score +

bonus) makes your intention clear.

Assignment uses =. Equality uses == or is. Accidentally writing an assignment where you meant a test is a good reason to validate before you press Run.

Page 14 of 357Permalink
Go to page