[I7] headdesking with glk [SOLVED]

[code]Include Glulx Entry Points by Emily Short. Use direct event handling.

Figure of a Red Button is the file “red_button.png”.

Part - Displaying Thumbnails

To say thumb (F - a figure-name):
display F as a thumbnail.

To display (chosen figure - a figure-name) as a thumbnail:
(- DrawThumb({chosen figure}); -)

Include (-

[ DrawThumb N;
glk_request_hyperlink_event(gg_mainwin);
glk_set_hyperlink(67);
glk_image_draw(gg_mainwin, ResourceIDsOfFigures–>N, imagealign_MarginLeft, 0);
glk_set_hyperlink(0);
];

-).

Test Chamber is a room. “[thumb Figure of a Red Button]Not much here, other than the big, bright, shiny red button.”

A man called Gordon is here. The indefinite article is “your faithful assistant”.

Include (-

Constant GG_ILLUSTRATION_ROCK 210;
Global gg_full_illustration = 0;

-).

The thumbnail-clicking rule translates into I6 as “THUMBNAIL_R”.

Glulx input handling rule for a hyperlink-event:
open the damn window.

To open the damn window:
(- if gg_full_illustration == 0) {
gg_full_illustration = glk_window_open(gg_mainwin, (winmethod_Above+winmethod_Fixed), 600, wintype_Graphics, GG_ILLUSTRATION_ROCK );
}
-).
[/code]

Here’s what I want to happen: A small graphic (in this example, a red button) appears in the main output window. When the player clicks it, a new graphics window splits from the main window. I have the hyperlink working, but I cannot figure out a way to attach code to the hyperlink event.

So let’s start with the example above. Why doesn’t it work? Inform tells me that gg_full_illustration is an udeclared variable – but it is declared, as a global variable.

Kind of at my wit’s end, here. This is the fifth or sixth completely different approach that I’ve tried, and I’m ready to conclude that my original assessment was correct: I do not understand Glk (or I6 inclusions) whatsoever.
red_button.png

When defining an I6 global variable, you have to cope with the I6 requirement that variables must be defined before use.

Include (-

Constant GG_ILLUSTRATION_ROCK 210;
Global gg_full_illustration = 0;

-) after "Global Variables" in "Output.i6t".

It may help to look at the generated project.inform/Build/auto.inf file when an error like this turns up.

ALso, you’re missing an open-paren in the open-the-damn-window phrase, but you probably caught that.

By the way, I apologize for not posting complete solutions to questions like this. I wish there were some but I haven’t had time to sit down and construct examples.

Thanks! That worked and I’m pretty sure I understand what’s going on again. I’ll probably be back for more soon, though.

BTW no apologies necessary. I’m grateful for the work you’ve put into this; I’m only impatient because I find the rest of I7 so intuitive.