Language Reference
$input System
Read user input interactively or via inline values and files.
Syntax Forms
| Syntax | Description |
|---|---|
$input | Read a value, auto-detect type |
$input as number | Read and convert to number |
$input as string | Read as string |
$input as list | Read as list |
$input as bool | Read as boolean |
$input("prompt") | Show prompt, then read |
$input("prompt") as number | Show prompt with typed input |
Type keywords accepted
number, string, list, bool, int, float, text
Examples
pseudo
name = $input("Enter your name:")
age = $input("Enter age:") as number
print "Hello, {name}! You are {age} years old."Output
? Enter your name: → Alice
? Enter age: → 25
Hello, Alice! You are 25 years old.
Auto Type Detection
When no type is specified, $input auto-detects:
| Input received | Detected type |
|---|---|
"42" | number → 42 |
"true" | bool → true |
"hello" | string → "hello" |
Inline Input (-i flag)
Pass inputs without interactive prompts:
bash
# Single value
pseudo run greet.pseudo -i "Alice"
# Multiple values (\n separates them)
pseudo run greet.pseudo -i "Alice\n25\nengineer"
# From a file
pseudo run greet.pseudo -i inputs.txtEach $input call consumes the next value in order.
inputs.txt example
inputs.txt
Alice
25
engineerRepeatable -i
bash
pseudo run program.pseudo -i "Alice" -i "25" -i "engineer"Input Exhaustion Error
If $input is called but no more inputs are available:
text
✗ Runtime Error: Expected input #4 but no more inputs available.
Line 12: score = $input