SAIL (programming language): Difference between revisions

Content deleted Content added
String scanner: still working...
Line 50:
 
To build a new table, one first called {{code|GETBREAK}} which returned the next free slot in the table, or "table number". This would be followed by a {{code|SETBREAK}}, which took the table number, a string with the break characters, another string of "omit characters" which were simply ignored during reading (as if they were not in the string) and finally the "modes", flags that indicated how the system should work. Once set, the program could then repeatedly call {{code|SCAN}} or {{code|INPUT}} and be returned complete strings.{{sfn|Smith|1976|p=28}} This included a reference parameter, normally brkchar, that contained the character that caused the break, allowing one to test, for instance, for end-of-file characters. The system is conceptually similar to C's {{code|strtok}} functionality, which is part of [[stdlib]]<ref>{{cite web |url=https://www.geeksforgeeks.org/strtok-strtok_r-functions-c-examples/ |title=strtok() and strtok_r() functions in C with examples}}</ref> as opposed to being part of the language itself as in SAIL.
 
===Input/Output===
SAIL's [[input/output]] system was based on the idea of numbered "channels" in a fashion somewhat similar to the scanner entries. To open a file, one first called {{code|GETCHAN}} to return a value of a free channel, and then {{code|OPEN}}ed it with various parameters to describe the file and modes of operation. {{code|RELEASE}} was equivalent to close. Once opened, the file could be read, subject to the scanning rules noted above, by calling {{code|INPUT}} and looking for the end-of-file. Files did not have names as part of the OPEN, instead, {{code|LOOKUP}} could be used to point a channel at a given file, {{code|ENTER}} made a new file associated with a channel, and {{code|RENAME}} allowed an existing file name to be changed.{{sfn|Smith|1976|p=32}} One can open an existing file for writing using {{code|GETCHAN... OPEN... LOOKUP... ENTER}}.{{sfn|Smith|1976|p=33}}
 
There were numerous special handlers and variables that were used during I/O. For instance, the {{code|INCHWL}} function was an INPUT hard-wired to the user terminal and always open, and it returns its break character in the system variable {{code|!SKIP!}}.{{sfn|Smith|1976|p=30}} The {{code|PRINT}} function normally output to the same terminal channel, but could also be directed at any other opened channel.{{sfn|Smith|1976|pp=2, 38}}
 
==Example==