Scriptic
Knowledge Center
ScripticX / Learn

MiniScript+ basics

Learn the core syntax of the language used on ScripticX.

Updated September 1, 202613 min read

MiniScript+ (.msp) is the teaching language built into ScripticX. It keeps syntax intentionally compact so beginners can focus on reasoning and problem solving instead of punctuation.

The whole language is seven statements: PRINT, INPUT, assignment, IF, ELSE, END, WHILE, plus expressions. There are no arrays and no user-defined functions (coming soon :>).

How a program runs

A program is a list of lines, read top to bottom. One source line is always exactly one instruction, including blank lines and comment lines. The interpreter keeps a pointer to the current line, executes it, and moves on. Loops and conditionals work by moving that pointer somewhere else.

MiniScript+
1total = 02total = total + 53PRINT total
text
15

Assignment produces no output on its own. Only PRINT writes to the console.

The editor gives you two ways to run this:

ActionWhat it does
RunExecutes until the program ends, an error is thrown, or INPUT asks for a value
StepExecutes exactly one instruction, then stops so you can inspect the variables panel

Stepping is the fastest way to understand a loop: watch the pointer jump from END back up to WHILE, and watch the counter change as it goes.

Syntax rules

One statement per line. There is no statement separator. x = 1 PRINT x is not two statements, but it is an error.

Keywords must be UPPERCASE. PRINT, INPUT, IF, THEN, ELSE, END, WHILE, AND, OR, NOT, DIV, MOD. Writing print x fails with Unknown instruction "print x". Two things are case-insensitive: the literals TRUE/FALSE, and built-in function names, abs(-4) works. Variable names are case-sensitive, so total, Total, and TOTAL are three different variables.

END is always bare. END IF and END WHILE are not valid.

Comments start with #, either on their own line or after code. // is not a comment (x = 5 // 2 fails).

MiniScript+
1# Work out the final score2base = 803bonus = 10  # awarded for speed4PRINT base + bonus
text
190

Values and variables

There are three types, and no way to declare one: a variable springs into existence on first assignment and takes the type of whatever it holds.

TypeExamplesNotes
Number42, 3.14, -7One numeric type; / can produce decimals
Text"hello"Straight double quotes only
BooleanTRUE, FALSEAlso produced by every comparison
MiniScript+
1name = "Ana"2score = 103passed = score >= 545PRINT name6PRINT score7PRINT passed
text
1Ana2103true

Booleans print lowercase as true and false, which is why they read differently from the TRUE you type.

Names must start with a letter or _ and may contain letters, digits, and _ after that. Reading a variable you never assigned stops the program with Variable "x" is not defined.

A variable can change type freely. The right-hand side is evaluated first, then the result replaces the old value, which is what makes counters work:

MiniScript+
1count = 12count = count + 13count = "done"4PRINT count
text
1done

Expressions and operators

Operators are listed from loosest to tightest binding. Anything higher in the table is evaluated later than anything below it.

LevelOperatorsNotes
1OR
2AND
3< > <= >= == !=
4+ -
5* / % DIV MOD
6NOT - + (unary)

Parentheses override all of it, so 2 + 3 * 4 is 14 but (2 + 3) * 4 is 20.

Arithmetic. / is ordinary division and can give decimals. DIV is integer division that truncates toward zero, and MOD (or %) is the remainder.

MiniScript+
1PRINT 7 / 22PRINT 7 DIV 23PRINT 7 MOD 24PRINT -7 DIV 2
text
13.523314-3

Dividing or taking a remainder by zero stops the program with Division by zero is not allowed or Modulo by zero is not allowed.

+ does double duty. If either side is text, both sides become text and are joined. Otherwise it is addition. Every other arithmetic operator is numbers-only and reports Operator - can only be used with numbers.

MiniScript+
1PRINT "Score " + 102PRINT 3 + 4
text
1Score 1027

Comparisons. <, >, <=, and >= work on numbers only! Comparing text with them fails. == and != work on any two values and compare both value and type, so 1 == "1" is false.

Logic. AND, OR, and NOT treat their operands as true or false and always return a boolean. Empty text and 0 count as false.

Built-in functions

Five functions exist. Arguments must be numbers, and names are case-insensitive.

CallResultExample
INT(x)Truncates toward zeroINT(-2.7)-2
TRUNC(x)Identical to INTTRUNC(2.7)2
FLOOR(x)Rounds downFLOOR(-2.7)-3
ROUND(x)Nearest integer, halves go upROUND(2.5)3
ROUND(x, d)Rounds to d decimalsROUND(2 / 3, 2)0.67
ABS(x)Absolute valueABS(-4)4

Calls nest and combine with operators like any other expression, so PRINT ABS(INT(-9.7) + 2) prints 7.

Output and input

PRINT takes exactly one expression and writes one line per call. To label a value, join it with +.

MiniScript+
1total = 122PRINT "Total " + total
text
1Total 12

INPUT name pauses the program and stores what you type. The editor converts what looks like a number into a number and true/false into a boolean; anything else stays text. Submitting an empty box gives 0.

MiniScript+
1INPUT age2IF age >= 18 THEN3PRINT "Adult"4ELSE5PRINT "Minor"6END

With 20 typed in, this prints Adult.

Conditions

An IF block runs its body only when the condition is true, and always closes with END. THEN is required, leaving it out fails with Missing THEN in IF statement.

MiniScript+
1score = 8023IF score >= 50 THEN4PRINT "Passed"5ELSE6PRINT "Try again"7END
text
1Passed

ELSE is optional, and a block may contain at most one. Indentation is purely for readability. The interpreter matches IF to END by counting blocks, not by looking at spaces.

Conditions nest freely, which is how you build a multi-way choice:

MiniScript+
1grade = 723IF grade >= 9 THEN4PRINT "Excellent"5ELSE6IF grade >= 5 THEN7  PRINT "Pass"8ELSE9  PRINT "Fail"10END11END
text
1Pass

Loops

WHILE checks its condition before every pass. When the condition is false the pointer jumps past the matching END; when the body finishes, END sends the pointer back up to re-check.

MiniScript+
1number = 123WHILE number <= 54PRINT number5number = number + 16END
text
1122334455

Three things have to line up for a loop to finish: a counter that starts somewhere, a condition that can become false, and a body that actually changes the counter. Forgetting the third is the usual cause of a loop that never ends.

Loops nest, and the inner loop runs completely for every single pass of the outer one:

MiniScript+
1row = 123WHILE row <= 34column = 15WHILE column <= 36  PRINT row * column7  column = column + 18END9row = row + 110END

A loop can also read until it sees a marker value, rather than counting:

MiniScript+
1total = 02INPUT value34WHILE value != 05total = total + value6INPUT value7END89PRINT "Sum " + total

Note the shape: read once before the loop, then read again at the end of the body. That way the condition always has a fresh value to test.

Errors and limits

A program may execute at most 1000 instructions. Passing that stops the run with Possible infinite loop detected. A simple counting loop spends about three instructions per pass, so roughly 330 iterations is the ceiling.

Errors report the line that failed. The most common ones:

MessageCause
Unknown instruction "…"A lowercase keyword, END IF, or two statements on one line
Variable "x" is not definedRead before it was ever assigned / check the spelling and the capitals
Missing THEN in IF statementTHEN left off the IF line
Missing END for IF statementA block was opened and never closed
END without matching blockOne END too many
ELSE without matching IFELSE outside a block, or after the END that closed it
Operator < can only be used with numbersComparing text with <, >, <=, or >=
Division by zero is not allowedA divisor reached 0! Guard it with an IF
Possible infinite loop detectedThe condition never became false
Unknown function "SQRT"Only INT, TRUNC, FLOOR, ROUND, and ABS exist

When a result is wrong but nothing errors, switch from Run to Step and watch the variables panel. Nearly every logic bug shows up as one variable holding a value you did not expect, one pass earlier than where you were looking.

Quick reference

StatementForm
OutputPRINT expression
InputINPUT variable
Assignmentvariable = expression
ConditionIF condition THENELSEEND
LoopWHILE conditionEND
Comment# text
Instead ofWrite
ELSE IFA nested IF inside ELSE
END IF, ENDWHILEBare END
// comments#
FUNCTION, RETURNInline the code
Arrays, FOR loopsA WHILE loop over a counter
SQRT, CEIL, MIN, MAXAn IF or a WHILE you write yourself