Reference

Appendix E: QF Code at a Glance

A quick reminder of how to write something, not an explanation of why. For the full explanation, see the chapter listed, or Appendix A for every built-in in detail.

Comments

QF Code example 1
// a comment, skipped entirely

Variables and Constants

QF Code example 2
var name = "Alice"        // can change later
const maxAttempts = 3     // cannot be reassigned

The Three Common Value Kinds

QF Code example 3
var score = 0          // number
var name = "Alice"     // string
var isReady = true     // boolean (true / false)

Input and Output

QF Code example 4
write("A")             // no new line after
writeln("Hello.")       // completes its own line
var answer = input("Prompt: ")   // always returns a string

Comparison Operators

QF Code example 5
==   !=   <   >   <=   >=

Logical Operators

QF Code example 6
and   or   xor   not

Type Conversion

QF Code example 7
str(value)      // to text
num(value)      // to number
bool(value)     // to boolean

if / else if / else

QF Code example 8
if condition then
    statements
else if other_condition then
    statements
else
    statements
end if

while

QF Code example 9
while condition
    statements
end while

for (counted)

QF Code example 10
for i = 1 to 5
    statements
end for

for i = 10 to 1 step -1
    statements
end for

for each

QF Code example 11
for each item in collection
    statements
end for

break and continue

QF Code example 12
break       // exit the loop now
continue    // skip to the next iteration

match

QF Code example 13
match subject
    when value
        statements
    when other_value
    when another_value
        statements
    when 1 to 10
        statements
    when else
        statements
end match

Functions

QF Code example 14
function name(parameter1, parameter2)
    statements
    return value
end function

name(argument1, argument2)

Arrays

QF Code example 15
var items = ["a", "b", "c"]   // literal
var items = array()           // empty
var items = array(10)         // pre-sized, filled with empty

items[0]                      // read, zero-based
items[0] = "z"                 // assign

append(items, "d")
insert(items, 0, "first")
remove(items, 2)
length(items)
contains(items, "a")
reverse(items)
sort(items)
erase(items)

Error Handling

QF Code example 16
attempt
    statements
error message
    handler_statements
end attempt

signal("custom error message")
QF Code example 17
last_error.message
last_error.line
last_error.code

String Functions

QF Code example 18
upper(s)   lower(s)   trim(s)
replace(s, old, new)
split(s, delimiter)
substring(s, start, length)
startswith(s, prefix)   endswith(s, suffix)
contains(s, value)
length(s)

Math Functions

QF Code example 19
abs(n)   round(n)   floor(n)   ceiling(n)   sqrt(n)
min(a, b)   max(a, b)   pow(base, exponent)
random()               // 0 up to (not including) 1
randomint(min, max)    // whole number, inclusive both ends

Sound

QF Code example 20
sound(pitch, duration_ms)   // hertz or note name like "C4"
bell()                       // fixed short tone

Scope, in One Line

Global at the top level, local inside each function call. if, while, for, for each, and match do not create their own scope.

Reserved Words

TEXT
var const
if then else end if
while end while
for for each to step next in end for
match when when else end match
break continue
function return end function
attempt error end attempt signal
true false empty
and or not xor

Copyright © 2026 Edison Mooers. Published by Gibidda Press. Free for personal learning and qualifying noncommercial educational use. Commercial training, organizational use, redistribution, and adaptation require written permission. Full use terms.