[code]Chapter “Setup”
Include (-
[ STORED_ACTION_TY_Support task arg1 arg2 arg3;
switch(task) {
CREATE_KOVS: return STORED_ACTION_TY_Create();
CAST_KOVS: rfalse;
DESTROY_KOVS: return STORED_ACTION_TY_Destroy(arg1);
PRECOPY_KOVS: rfalse;
COPY_KOVS: return STORED_ACTION_TY_Copy(arg1, arg2);
COMPARE_KOVS: return STORED_ACTION_TY_Compare(arg1, arg2);
READ_FILE_KOVS: if (arg3 == -1) rtrue; return STORED_ACTION_TY_ReadFile(arg1, arg2, arg3);
WRITE_FILE_KOVS: return STORED_ACTION_TY_WriteFile(arg1);
HASH_KOVS: return STORED_ACTION_TY_Hash(arg1);
}
];
-) instead of “KOV Support” in “StoredAction.i6t”.
Include (-
[ STORED_ACTION_TY_WriteFile txb;
print “A”;
print BlkValueRead(txb, 0), “,”; ! action
print BlkValueRead(txb, 1), “,”; ! noun
print BlkValueRead(txb, 2), “,”; ! second noun
print BlkValueRead(txb, 3), “,”; ! actor
print BlkValueRead(txb, 4), “,”; ! request flag
if (BlkValueRead(txb, 5)) {
INDEXED_TEXT_TY_WriteFile(BlkValueRead(txb, 5));
} else {
print “;”;
}
];
[ STORED_ACTION_TY_ReadFile txb auxilary_file character
index value;
while (index ~= 5 && character ~= 32 or 9 or 10 or 13 or 0 or -1) {
character = FileIO_GetC(auxilary_file);
if (character == ',') {
BlkValueWrite(txb, index++, value);
value = 0;
} else {
value = value * 10 + (character - '0');
}
}
character = FileIO_GetC(auxilary_file);
if (character == 'S') {
if (~~BlkValueRead(txb, 5)) {
BlkValueWrite(txb, 5, INDEXED_TEXT_TY_Support(CREATE_KOVS));
}
INDEXED_TEXT_TY_ReadFile(BlkValueRead(txb, 5), auxilary_file, character);
} else {
if (BlkValueRead(txb, 5)) {
BlkFree(BlkValueRead(txb, 5));
BlkValueWrite(txb, 5, 0);
}
}
return txb;
];
-) before “Involvement” in “StoredAction.i6t”.
Chapter “Demo”
There is a room.
The File of Memory is called “memory”.
Table of Memory
memory (stored action)
Before doing anything:
now the memory in row one of the Table of Memory is the current action.
Instead of jumping:
write the File of Memory from the Table of Memory;
say “Done.”
Instead of singing:
read the File of Memory into the Table of Memory.
Every turn:
showme the memory in row one of the Table of Memory.
Test me with “jump / z / sing”.[/code]
Note that this code breaks Inform’s rule about writing addresses to files; such a file can only be read by the same version of the story that wrote it.