October 2024
Intermediate to advanced
272 pages
6h 54m
English
The indirect reference operator $ (dollar sign) turns a string str into a namesake variable or label. The str might be a direct string literal, an outcome of a string concatenation, or a string produced by a string function (refer to the section Understanding Functions and Predicates). In the following program, the operator concatenates the label prefix “L” and the numerical user input, directing the program flow to the designated label.
| | * Display the menu |
| | OUTPUT = "Menu:" |
| | OUTPUT = "Press 1 for action, 2 for help, 3 for panic" :($("L" INPUT)) |
| | * Invoke a menu item |
| | L1 OUTPUT = "Thank you for using Snobol!" :(END) |
| | L2 OUTPUT = "Help is on the way!" :(END) |
| | L3 OUTPUT ... |
Read now
Unlock full access