3 · Data & I/O
Arrays
name(n) allocates n zeroed integer slots:
scores(3) cmt allocate 3 slots
set scores, 0, 10 cmt write index 0
set scores, 1, 25
(firstScore.get scores, 0)
echo firstScore cmt 10
Out-of-bounds reads and writes halt the program with a line number.
String ops
msg"hello"
(n.len msg) cmt 5 (bytes; also works on arrays)
(c.char msg, 1) cmt 101, the code of 'e'
(greet.cat msg, " you") cmt "hello you"
(ok.cmp a, b) cmt -1 / 0 / 1
Strings compare with == / != (and ordering) in if conditions, and cat accepts numbers too.
Console I/O
| Form | Does |
|---|---|
echo "hi" / echo x | Print string or variable + newline (stdout) |
echow timer, 100 | Print value as a live overlay, refreshed in-place (FPS counters, status) |
in(key) | Read one stdin line into a variable (numeric input becomes int) |
File I/O
fopen fh, "notes.txt", "w" cmt modes: "r" read, "w" write (truncate)
fwrite fh, "hello vect" cmt strings written raw, ints as decimal
fclose fh
fopen fr, "notes.txt", "r"
(s.fread fr, 64) cmt up to 64 bytes into s, "" at EOF
fclose fr
echo s
Paths resolve relative to the folder you run vectc from. Using a closed or bad handle halts with a line number.
Next: 4 · System →