---
id: fn-arg
name: arg
category: builtins
kind: builtin
tokens: arg
sig: arg(i) -> string
tip: The i-th command-line argument as a string.
order: 50
---
Returns the command-line argument at index i as a string. Index 0 is conventionally the program's own name or path, so the first user-supplied argument is at index 1. Use it together with arg_count to write configurable command-line tools in Ludic — reading an input filename, a mode flag, or a numeric option. Guard the index against arg_count() before reading so you never ask for an argument that was not passed.
Parameters:
- `i` — the argument index (`0` is the program name)
```ludic
program EchoFirstArg {
handler ShowArg phase Start {
if arg_count() > 1 {
print(arg(1))
} else {
print("no argument")
}
}
}
```