IPCI Language Reference

IPCI — the Introductory Programming Concept Illustrator — is a small teaching language for learning programming fundamentals. Programs are written as a plain sequence of statements, and the browser-based editor runs them one step at a time so you can watch each variable change as it happens. This page documents the whole language: its three data types, its statements, its control flow, and every operator.

Data Types

Every variable is declared with its type before use. IPCI has three.

KeywordHoldsDeclaration
IntegerWhole numberInteger count
StringText valueString name
BooleanTRUE or FALSEBoolean flag

Statements

Set

Set varName value

Assign a value to a variable. Value can be a literal, variable, or expression.

Set x 42
Set y ADD(x, 10)

Accept

Accept varName

Prompt the user for input and store it in the variable.

Accept age

Display

Display expr...

Output text. Use "quotes" for strings, [brackets] for variables, or bare names.

Display "Hello " [name] "!"

Control Flow

IF / Else / EndIF

Run one branch or the other depending on whether a condition holds.

IF GT(x, 5)
  Display "x is big"
Else
  Display "x is small"
EndIF

IF / ElseIF / Else / EndIF

Test conditions in order and run the first branch that holds. A chain has one EndIF, however many ElseIF branches it contains.

IF GE(score, 70)
  Display "A"
ElseIF GE(score, 60)
  Display "B"
Else
  Display "F"
EndIF

While / EndWhile

Repeat a block for as long as a condition stays true.

While LT(i, 10)
  Display i
  Set i ADD(i, 1)
EndWhile

Functions

Function / EndFunction

Define a reusable calculation. A function declares a return type and must return a value, so it can be used anywhere an expression can.

Function Integer Area(Integer w, Integer h)
  Integer result
  Set result MUL(w, h)
  Return result
EndFunction

Integer a
Set a Area(3, 4)

Procedure / EndProcedure

Define a reusable action. A procedure returns nothing, so it is run with Call rather than used in an expression.

Procedure Greet(String name)
  Display "Hello, " [name] "!"
EndProcedure

Call Greet("Saint")

Return

Send a value back to the caller and exit the function immediately, even from inside a loop or an IF. A procedure may use Return on its own to exit early.

Function Integer Bigger(Integer a, Integer b)
  IF GT(a, b)
    Return a
  EndIF
  Return b
EndFunction
  • Each call gets its own private set of variables. A function cannot see or change the caller's variables — values go in through parameters and come back through Return.
  • Because each call has its own variables, a function can call itself. Step through the recursive factorial sample to watch the call stack grow and unwind.
  • Functions and procedures are declared at the top level, and may be called before the line they are declared on.
  • Display takes text and variable names only — it does not evaluate expressions or function calls, so a result must be assigned to a variable first: Set result Area(3, 4) then Display [result].

Comparison Operators

Comparisons are written as calls rather than symbols. They are what an IF or While tests.

GT(a,b)
a > b
GE(a,b)
a >= b
LT(a,b)
a < b
LE(a,b)
a <= b
EQ(a,b)
a == b
NE(a,b)
a != b
BC(a,b)
Boolean compare

Arithmetic and String Operators

ADD(a,b)
a + b
SUB(a,b)
a - b
MUL(a,b)
a * b
DIV(a,b)
a / b (integer)
APPEND(a,b)
concat with space
CONCAT(a,b)
concat no space

Division is integer division. Operators nest, so an expression can be built out of other expressions:

Set x ADD(MUL(2,3),4)

Logical Operators

Logical operators take two conditions separated by a pipe. Note that NOT is an exclusive or — it is true when exactly one of its two conditions holds.

AND(c1|c2)
Both conditions true
OR(c1|c2)
At least one true
NOT(c1|c2)
Exactly one true (XOR)
IF AND(GT(a,0)|LT(b,100))
  Display "Both true"
EndIF

Comments

Anything after // is ignored by the interpreter.

// This is a comment
Display "Comments are ignored by the interpreter"

Keyboard Shortcuts

Shortcuts available in the editor.

Ctrl + Enter
Run program
Ctrl + Shift + Enter
Step through
Ctrl + .
Continue to breakpoint
Escape
Stop execution
Ctrl + L
Clear output
Ctrl + S
Download .ipci file
Ctrl + H
Toggle the language reference