When Stril starts up, it finds the name of the script, opens it and stores the script name in the variable |0. The rest of the command line is stored in |1. Then Stril sets some important values. The buffer that is used to store variables, is filled with deletes, the only peculiar thing in this part of the program. In many programming languages, a string is null-terminated, a feature that can make it difficult to handle the null-character. Internally in Stril, the delete-character (ASCII value 127) is used instead. Stril can delete characters, but it cannot handle the delete-character. That doesn't matter much. Stril can only count to 126!
The switching between standard input and open input files is accomplished through file pointer trickery. At start-up the file pointer "input" refers to standard input. When you switch to an open file, the number in the relevant file pointer is copied into "input". When you switch back, the number of standard input is copied into "input". The readline function always reads from "input". The same kind of trickery is used to switch between different output files and program files.
When Stril switches to a new program source, it enters the parse loop immediately. Values and variables are not re-initialized. They are shared between all program sources within an instance of Stril. If a new main program file is opened, it inherits existing variables and values. If the x-command is used to run a Stril script, it becomes a new instance with a clean slate of variables and values.
In Stril, there are no labels and only a single loop statement. It is an eternal loop, so it has to be combined with control statements. You can never jump to a point that has not been visited before. It would not be hard to implement such a feature, but it would require parsing the program files twice, thereby reducing execution speed. Stril is slow enough as it is. The absence of a ready-made for-loop and a ready-made while-loop, does not mean that those loops are unavailable in Stril, but you have to make them yourself.
The internal variable "current" is an invention that I am fairly happy with. "Invention" is perhaps not the right word. The concept of pointers is central to most programming languages, and "current" is only my own implementation of that concept. Current points to another variable in user space. If you increase or decrease current, it will point to a different variable. This feature rests on the fact that Stril variables are single letter ones and correspond to the numerical values 48-57 (|0-|9) and 97-122 (|a-|z) in the ASCII chart.
In ancient Pilot, a line could be no longer than 127 bytes. That is part of the reason why Stril's mathematical capabilities is limited to the range of numbers between 0 and 126, The ASCII chart is another reason. With a line limit of 127 bytes, the numbers between 0 and 126 are sufficient to cover all the positions in the line and the characters in the ASCII-range. How the characters above the ASCII range are encoded, depends on the text format. On my system, I use utf-8. Each of the characters above the ASCII range spans two bytes. If you use iso-latin, each of those characters is encoded as a single byte with a numerical value between 128 and 255. For an iso-latin based system, a buffer length of 255 bytes might be a better choice. The advantage of a buffer length and number ceiling of 127 is that it works with both utf-8 and iso-latin.
The first 33 values (0-32) refer to whitespace characters and non-printable ones. Many programming languages use backslash codes to request some of these characters. In C, you can for example use "\n" to request a newline. I wanted backslash codes that could refer to the entire range between 0 and 32, so I had to deviate from the customary notation. In Stril, \0-\9 are used to refer to the first ten values in the ASCII chart, while \a-\w cover the rest of the values up to 32. It is logical enough since it starts out the same way as the hexadecimal system, but I also chose it because it enabled me to save a few bytes. I didn't have to program each of the backslash-codes separately, but could cover the whole range with two simple mathematical operations.
Backslash codes are immediately converted to corresponding values whether they are used in a definition or in the text option of a command. Expansion of variables, however, is handled by the write command. If you print a variable, Stril looks inside it and expands the variables it finds there. If you use the text option of the write command, only the variables in the text option are expanded. This distinction is a rather important one when Stril is used to generate code for Stril or other programming languages.
The verity-command has no parallel in most programming languages. It sets the truth level and may be counted as a fake news command. I will not disclose my source of inspiration, but you are allowed to guess! If the truth level is 0, match, less and greater are inverted. If it is 2, all comparisons are true.Stril is primarily a tool for text processing, much like Awk, so the complete absence of substitution commands may come as a surprise. Stril contains eight different split commands if the effect of the verity-command is taken into consideration. Substitutions are accomplished through manipulation of the parts resulting from split operations. If you want to change a part, you replace it with a different variable or a piece of text. If you want to delete a part, you don't print it!
An even greater surprise is perhaps the complete lack of control statements. Stril doesn't contain a single control statement, but it contains 11 statements that double as control statements. They all work the same way. If an operation is successful, the next command is skipped. On failure, it is executed.
Stril is intended to be a general text processing language. One of the things that I wanted to use it for, was the creation of experimental text readers. That is why it contains some unusual commands for navigation in text files.
Jon-Egil Korsvold, September 16th 2018.