Algol 68 supports event handlers to catch (and handle) mismatchesAssociate a file to the string and use file procs/event handlers.
of read-in values WRT the target variable's type. This works fine
with all the standard I/O ("transput") with the Genie interpreter,
e.g. in contexts like
-a FILE in; REAL k; CHAR c;
-a get (in, k);
-a get (in, c);
where the input data doesn't match (e.g.) the syntax of a 'real'.
Genie now also supports a 'gets' procedure to read in (and parse)
values of arbitrary types from a string instead of a file, like
-a STRING str := "..."; REAL k; CHAR c;
-a gets (str, k);
-a gets (str, c);
The event handlers (that may be used in the first case) require a
FILE parameter to work with. Though there seems to be no comparable
event handler function to catch and handle such value syntax errors
in the second case (when reading from a string).
Any suggestions?
On 08/09/2026 22:54, Janis Papanagnou wrote:
Algol 68 supports event handlers to catch (and handle) mismatches
of read-in values WRT the target variable's type. This works fine
with all the standard I/O ("transput") with the Genie interpreter,
e.g. in contexts like
-a-a FILE in; REAL k; CHAR c;
-a-a get (in, k);
-a-a get (in, c);
where the input data doesn't match (e.g.) the syntax of a 'real'.
Genie now also supports a 'gets' procedure to read in (and parse)
values of arbitrary types from a string instead of a file, like
-a-a STRING str := "..."; REAL k; CHAR c;
-a-a gets (str, k);
-a-a gets (str, c);
The event handlers (that may be used in the first case) require a
FILE parameter to work with. Though there seems to be no comparable
event handler function to catch and handle such value syntax errors
in the second case (when reading from a string).
Any suggestions?
Associate a file to the string and use file procs/event handlers.
On 2026-09-17 16:29, Carlos H wrote:
On 08/09/2026 22:54, Janis Papanagnou wrote:
Algol 68 supports event handlers to catch (and handle) mismatches
of read-in values WRT the target variable's type. This works fine
with all the standard I/O ("transput") with the Genie interpreter,
e.g. in contexts like
-a-a FILE in; REAL k; CHAR c;
-a-a get (in, k);
-a-a get (in, c);
where the input data doesn't match (e.g.) the syntax of a 'real'.
Genie now also supports a 'gets' procedure to read in (and parse)
values of arbitrary types from a string instead of a file, like
-a-a STRING str := "..."; REAL k; CHAR c;
-a-a gets (str, k);
-a-a gets (str, c);
The event handlers (that may be used in the first case) require a
FILE parameter to work with. Though there seems to be no comparable
event handler function to catch and handle such value syntax errors
in the second case (when reading from a string).
Any suggestions?
Associate a file to the string and use file procs/event handlers.
Thanks. That's a good idea! Actually I used 'associate' for the first
time just yesterday in another project (to obtain some "string-stream" functionality as in C++) and it had occurred to me that it might serve
for that purpose; though yet I haven't tried whether it works, so also
thanks for the confirmation - I'll now get back to that other project
and try it.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 55:41:10 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,687 |