Continuing the discussion from A request for assistance: hyperlinks in lists (GEP probably?):
I’ve decided to try to track down this odd behavior from Glulx entry points and lists, where SAYing or REPEATing THROUGH a list of hyperlinked texts will work just fine, except that the final hyperlink will crash.
I tried removing all material from my extension to isolate what happens. I tried only copying and pasting the important bits of Glulx Entry Points to track down the behavior.
Most recently, I tried to determine exactly what Glulx event requests are happening when clicking on hyperlinks.
In the IDE, this is what we get:
But Quixe is more forgiving and lets us get away with some illegal events. This is what we get there:
To get this code dump, this is the code I inserted into Glulx Entry Points:
glk-event-list is a list of text that varies.
To decide what number is the value returned by glk event handling (this is the handle glk event rule):
now glulx replacement command is "";
add the substituted form of "[current glk event]" to glk-event-list;
follow the glulx input handling rules for the current glk event;
if the outcome of the rulebook is the replace player input outcome:
decide on input replacement;
if the outcome of the rulebook is the require input to continue outcome:
decide on input continuation;
follow the command-counting rules;
if the rule succeeded:
follow the input-cancelling rules;
follow the command-showing rules;
follow the command-pasting rules;
if the [command-pasting] rule succeeded:
decide on input replacement;
Every turn:
say "The glk event list is [glk-event-list]".
(my lines are those involving glk-event-list)
Interestingly, if instead of printing ‘every turn’ we print at the beginning or end of the ‘to decide’ phrase, we reproduce the crash for every hyperlink.
To be clear, I don’t believe this is code in Simple Multimedia Effects causing this. I included a large chunk of VM keyboard replacement code to handle ‘echoing’, but deleting all of that has no effect on crashing.
This is the full text of the hyperlink code (which I believe was originally written by Petter Sjölund, as that’s who I credit)
A glulx hyperlink rule (this is the default inline hyperlink handling rule):
now the current hyperlink ID is the link number of the selected hyperlink;
unless the current hyperlink ID is 0:
cancel glulx hyperlink request in main window;[just to be safe]
cancel glulx hyperlink request in status window;[just to be safe]
follow the hyperlink processing rules;
if the status window is the hyperlink source:
request glulx hyperlink event in status window;
otherwise:
request glulx hyperlink event in main window.
To request glulx hyperlink event in the/-- main window:
(- if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_request_hyperlink_event(gg_mainwin); -)
To cancel glulx hyperlink request in the/-- main window:
(- if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_cancel_hyperlink_event(gg_mainwin); -)
To request glulx hyperlink event in the/-- status window:
(- if (glk_gestalt(gestalt_Hyperlinks, 0) && gg_statuswin) glk_request_hyperlink_event(gg_statuswin); -)
To cancel glulx hyperlink request in the/-- status window:
(- if (glk_gestalt(gestalt_Hyperlinks, 0) && gg_statuswin) glk_cancel_hyperlink_event(gg_statuswin); -)
To decide whether the status window is the hyperlink source:
(- (gg_event-->1==gg_statuswin) -)
To decide which number is the link/-- number of the/-- selected/clicked hyperlink:
(- (gg_event-->2) -)
Section 3 - Placing links
The hyperlink list is a list of texts that vary..
To hyperlink (hyper-text - a text) as (hyper-command - a text):
let hyperlink index be a number;
if the hyper-command is listed in the hyperlink list:
repeat with count running from 1 to the number of entries in the hyperlink list:
if entry (count) of the hyperlink list is hyper-command:
let hyperlink index be count;
otherwise unless the hyper-command is "":
add hyper-command to hyperlink list;
let hyperlink index be the number of entries of hyperlink list;
say "[set link (hyperlink index)][hyper-text][terminate link]";
To say set link (N - a number):
(- if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_set_hyperlink({N}); -)
To say terminate link:
(- if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_set_hyperlink(0); -)
Section 4 - Processing hyperlinks
The hyperlink processing rules are a rulebook.
The current hyperlink ID is a number that varies.
Section 5 - Selecting replacement command
A hyperlink processing rule (this is the default command replacement by hyperlinks rule):
now the glulx replacement command is entry (current hyperlink ID) of the hyperlink list;
rule succeeds.




