Variable must be defined before use

I’m working on a Kerkerkruip extension that uses Text Capture by Eric Eve. There’s a variable defined in Text Capture that has the name “capture_active” in I6. I include Text Capture at the beginning of the extension. But I still get the error ‘Variable must be defined before use: “capture_active”’…

The extension replaces some sections of Basic Screen Effects by Emily Short, and that’s where the “capture_active” variable is used. I had this working back in 6G60, but the I6 code was in the story file, not an extension. How can I get this to work?

I tried listing Text Capture first in the story file, right before Basic Screen Effects, but then I got the error 'No such constant as “INDEXED_TEXT_TY_Say”

Edit: looks like that’s an unrelated error. But I don’t like having to list Text Capture first… is there any way around it?

INDEXED_TEXT_TY_Say was something I copied from Simple Unit Tests by Dannii Willis. I’m guessing that’s something that changed in 6L38 - how to you say a (formerly indexed) text in I6 now?


Thanks, Zarf! That worked.

Now I’m back to the original problem. Everything was working fine until I added this line to one of my extensions (Kerkerkruip Test Sets):

assert "transcript should be capturing" based on whether or not text capturing is active;

Even though Text Capture is the very first extension included in the project, it’s saying “variable must be defined before use” all over again:

I6 source code ordering has nothing to do with I7 source code ordering.

Not “nothing”, really, but the connection is tenuous. I7 generates the I6 source code in whatever order it wants.

For extensions that include I6, the extension places its code explicitly using the “Include () before/after SECTION of TEMPLATE” phrase. Possibly Text Capture is using bad placement. Or you may need to write a function that tests the text_capture variable; functions can be called before declaration.

I looked in the code for Text Capture, and here’s the declaration:

Include (-	Global capture_active = 0;	-).

Do you have any recommendations for what section to place that in? After “Definitions.i6t” looks like a popular place.

I could do a patch, and also contact Eric Eve.

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

Not tested, but you might as well go where all the others are.

Unfortunately the I7 documentation doesn’t give much guidance on where I6 code should be included, but based on one example give in passing and a couple of other comments in the Extensions document you could try changing:

Part 3 - I6 Code

Include (- Global capture_active = 0; -). 

In Text Capture to:

Part 3 - I6 Code

Include (- Global capture_active = 0; -) after "Definitions.i6t". 

And seeing if that helps.

That looks like it worked, Eric! Would you be willing to upload an update to Text Capture with the patch?

I’m not entirely sure where one’s meant to upload it to these days. I’ve just emailed a copy to the email address given on the I7 website, but the set of extensions that appears there doesn’t seem to be the same as the ones that appear in the Public Library, so I’ve rather lost track of what the correct procedure is now.

Gah! I hope they sort that out…

Even the old version of Text Capture is missing from the Inform 7 site! Could someone put the new version on github (or send it to me to put on github)?

I think I installed it via the “public library” feature of 6L38 (on a Mac). Can you get it that way?

Eric, could you send me or Dannii your latest version so we can include it in Kerkerkruip’s materials? Thanks!

Oh, I had forgotten to look there. Oops :confused:

I was going to link to the bug report, but I see you got there first:

I’m away from home right now, so I don’t have a copy of the updated Text Capture to hand right now. I’ve sent an updated version to the official I7 Extensions site and had an acknowledgment from Mark Musante, but whether it’ll end up on the old extensions site or the new Public Library; I haven’t yet figured out what the procedure is (if there is one) for updating the Public Library.