Trouble including I6 code (6M62)

(The below is for 6M62.)
I’ve taken a big hunk of Parser.i6t so I can customize it:

include (-
[ Keyboard  a_buffer a_table  nw i w w2 x1 x2;
	sline1 = score; sline2 = turns;

	while (true) {
		! Save the start of the buffer, in case "oops" needs to restore it
		for (i=0 : i<64 : i++) oops_workspace->i = a_buffer->i;
	
		! In case of an array entry corruption that shouldn't happen, but would be
		! disastrous if it did:
		#Ifdef TARGET_ZCODE;
...
		if (i == 2) {
			VM_RestoreWindowColours();
			VM_Style(SUBHEADER_VMSTY);
			SL_Location(); print "^";
			! print (name) location, "^";
			VM_Style(NORMAL_VMSTY);
			IMMEDIATELY_UNDO_RM('E'); new_line;
			continue;
		}
		return nw;
	}
];
-) instead of "Reading the Command" in "Parser.i6t".

As I understand it, this is the way to do it. But I’m getting errors:

Problem. The text ‘#Ifdef TARGET_ZCODE’ [] is followed by a semicolon ‘;’, which only makes sense to me inside a rule or phrase (where there’s a heading, then a colon, then a list of instructions divided by semicolons). Perhaps you want a full stop ‘.’ instead?

It seems to be reading the I6 inclusion as if it were I7. Why is this?

(For context, I’m just trying to customize the output after the undo is finished, i.e. replace the SL_Location() above. I’ve customized room description heading rule elsewhere and I’d like to match it.)

This compiles ok for me when I paste it into a 6M62 (9.3) project.

Well, as written there are I6 errors, starting with “…” not being a I6 statement. But I don’t run into the problem you’re running into.

Well, I’m definitely using 6M62:

Launching: ni "-internal" "/Users/rileypb/Desktop/Inform_test.app/Contents/Resources/Internal" "-external" "/Users/rileypb/Library/Inform" "-project" "/Users/rileypb/dev/Inform/Untitled.inform" "-format=ulx"
Inform 7 build 6M62 has started.

I’m on MacOS 11.7.3. I downloaded a new copy of the IDE and threw out the old folder in ~/Library, and still the same error.

I have however found the proximal cause of the error:

				! If the replacement is longer than the original, move up...
				for (i=INPUT_BUFFER_LEN-1 : i>=w+x2 : i--)
					a_buffer->i = a_buffer->(i-x2+w2);
		
				! ...increasing buffer size accordingly.

If you change i-- to i = i - 1, it all compiles. Looks like the i--) was mistaken for ending the inclusion.

Should be okay to also just add a space to break up the -).

2 Likes

Haha, yeah that would work. :man_facepalming:

Does I6 have a pre-decrement operator as well? I use --i for counted loops in most languages of that style just because text editors often used to mis-tokenize the punctuation in i--) as a single unit…

Yes, it has pre/post inc/decrement.

1 Like

side note, the z-machine not only has the prerequisite for pre/post increment/decrement (short/fast INC/DEC machine instruction), but also an increment/decrement and branch.

Which is notably never used by Inform (unless you use inline assembly). If I remember right, this led to some odd bugs lingering in Z-machine interpreters for a long time, because these opcodes were so seldom used. (Same with print_table.)