ScripticXLearn programming visually
Platform
Problems
Community
Leaderboard
Learn
Docs
BasicsVariablesLoopsInput / Output
Examples
BasicsLoopsConditionsAlgorithms
What's newHelpContact
Loading…

Documentation

MiniScript+

DocumentationMiniScript+
Getting started
MiniScript+ basics
Language basics
VariablesLoopsInput and output
Documentation/Variables

Variables

Store, update, and reuse values with clear MiniScript+ variable names.

On this page
Assign a valueUpdate a variableNaming variablesExpressionsCommon mistakes

A variable gives a name to a value. Once assigned, that value can be read again or replaced later in the program.

Assign a value#

Use = to assign the expression on the right to the name on the left.

MS+MiniScript+
1score = 1002playerName = "Alex"3finished = FALSE

Assignment does not print anything by itself. Use PRINT when you want to inspect a value.

MS+MiniScript+
1score = 1002PRINT score

Update a variable#

The right-hand side is evaluated first, then the result replaces the old value.

MS+MiniScript+
1score = 102score = score + 53PRINT score  # 15

This pattern is especially useful for counters and totals.

Naming variables#

Choose names that describe the value they contain.

PreferAvoidReason
studentCountxThe purpose stays clear
maximumScorethingThe stored value is explicit
isFinishedflag1Boolean intent is visible

Variable names should begin with a letter or underscore and may contain digits after the first character.

Consistent style

camelCase is used throughout these guides, but consistency matters more than a particular naming convention.

Expressions#

Variables can participate in any expression just like literal values.

MS+MiniScript+
1width = 82height = 53area = width * height4​5PRINT "Area:"6PRINT area

Common mistakes#

  1. Reading a variable before assigning it.
  2. Using a quoted name when you meant the stored value.
  3. Reusing one vague name for unrelated values.
MS+MiniScript+
1points = 252PRINT "points"  # prints the text points3PRINT points    # prints 25

Next, use variables to control loops.

PreviousMiniScript+ basicsNextLoops

On this page

Assign a valueUpdate a variableNaming variablesExpressionsCommon mistakes