I’ve run into a snag converting Conversation Builder to 6L02. This extension is much more Emily’s code still, especially the I6. And the latter is largely midsize-to-giant functions full of GLK opcodes which I have no idea what they do. GLK was updated with this version of Inform, wasn’t it?
Oh, and the whole CB extension is currently available from the extensions github.
First, external file writing doesn’t work, and it didn’t even in 6G06, and I’m not sure why. I know Kerkerkruip does external writing properly, but I haven’t looked at its code; maybe I should try to replace the system with a native I7 one? But I’d have to do it all at once, since I don’t know I6 well enough to disentangle each function piecemeal.
The main issue, though, is in the process of writing new dialog, the system saves it all in one big text stream, which is supposed to be printed out when you say “SHOW SOURCE”, not only printed to the external file. But that’s giving me runtime errors in 6L02.
The L# are debugging aids I’ve added to demarcate each line of the output.
The code in question: Carry out looking at new source (this is the source examination rule):
say "You review your new code: [paragraph break]" (A);
repeat with N running from 1 to file line count:
say "L[N]: ";
draw big buffer from line N of file "NewConversation";
say big buffer;
say line break.
The big buffer lines are merely: To draw big buffer from line (N - a number) of file (S - some text):
(- AcquireArrayFromFile({S}, big_big_buffer, {n}); -)
and
To say big buffer:
(- CharBufferDump(big_big_buffer); -)
Looks like it may be a problem with CharBufferDump, but that’s just [ CharBufferDump array_name length maxlen i;
maxlen = STRING_BUFFER_SIZE;
if (length == 0) length = array_name-->0;
for (i=0:i<array_name-->0 && i<length:i++ )
{
! print (i+WORDSIZE), ":";
if (array_name->(i+WORDSIZE) < 127 && array_name->(i+WORDSIZE) > 31)
print (char) array_name->(i+WORDSIZE);
}
];
I see elsewhere online this message can be fixed by replacing print() with PrintText(), but that doesn’t work in this case thanks to the array_name->(i+WORDSIZE); afterwards.
And if the problem isn’t in that function I suspect it may lie in StuffBuffer, which I have no idea where to even start debugging:
[rant]
[ StuffBuffer a_buffer done ix i;
if (gg_commandstr ~= 0 && gg_command_reading ~= false) {
! get_line_stream
done = glk($0091, gg_commandstr, a_buffer+WORDSIZE, LARGE_BUFFER_LENGTH-WORDSIZE);
if (done == 0) {
glk($0044, gg_commandstr, 0); ! stream_close
gg_commandstr = 0;
gg_command_reading = false;
! L__M(##CommandsRead, 5); would come after prompt
! fall through to normal user input.
}
else {
! Trim the trailing newline
if ((a_buffer+WORDSIZE)->(done-1) == 10) done = done-1;
a_buffer-->0 = done;
glk($0086, 8); ! set input style
glk($0084, a_buffer+WORDSIZE, done); ! put_buffer
glk($0086, 0); ! set normal style
print "^";
jump KPContinue;
}
}
done = false;
glk($00D0, gg_mainwin, a_buffer+WORDSIZE, LARGE_BUFFER_LENGTH-WORDSIZE, 0); ! request_line_event
while (~~done) {
glk($00C0, gg_event); ! select
switch (gg_event-->0) {
5: ! evtype_Arrange
DrawStatusLine();
3: ! evtype_LineInput
if (gg_event-->1 == gg_mainwin) {
a_buffer-->0 = gg_event-->2;
done = true;
}
}
ix = HandleGlkEvent(gg_event, 0, a_buffer);
if (ix == 2) done = true;
else if (ix == -1) done = false;
}
if (gg_commandstr ~= 0 && gg_command_reading == false) {
! put_buffer_stream
glk($0085, gg_commandstr, a_buffer+WORDSIZE, a_buffer-->0);
glk($0081, gg_commandstr, 10); ! put_char_stream (newline)
}
.KPContinue;
for (i = WORDSIZE : i <= (a_buffer-->0)+(WORDSIZE-1) : i++)
{
if ((a_buffer->i) == '"')
{ a_buffer->i = 39;
}
}
WriteArrayToFile("NewConversation", a_buffer, 1);
];
[/rant]