I6: variable set to dictionary word, how to get to its text?

I’ve been searching the documentation on this but haven’t come up with an answer yet.

Suppose you set a variable (actually, a constant) to a specific dictionary word, like so:

Constant TEST_WORD = 'test';

What is actually stored in the constant? Is it the dictionary address of the word?

What I’m really looking to do is print the text for the associated word. I thought that TEST_WORD would be set to the dictionary address of ‘test’, so that I could just say:

print (address) TEST_WORD;

to print the string “test”, but something seems to be going wrong. Am I right about what’s stored in TEST_WORD (in which case I need to look at what else might be causing the issue), or am I wrong (in which case I’m wondering how it’s possible to convert whatever’s stored in TEST_WORD into an address)?


You’re right, and you need to look at what else might be causing the issue.

Constant Headline "^An Interactive Example^";

Include "Parser";
Include "VerbLib";

Constant TEST_WORD = 'test';

Object Start_Room "Start Room"
  with description "This is the starting room.",
  has light;

[ Initialise;
  location = Start_Room;
  print (address) TEST_WORD, "^";

Include "Grammar";

Thanks, vlaviano. What I was really after was a way to convert the contents of the variable/constant in I6 to a string at the I7 level. This seems to work for basic comparisons:

To decide which text is test word: (- print (address) TEST_WORD; -).

so things like

if "[test word]" is "test"...

evaluate to true, but it doesn’t work for things like:

say "The test word is [test word]."

Is there another way to cast this to an I7 string that doesn’t involve using the I6 print function?

No, you have to use the I6 print function in some way. There are ways to convert directly to an I7 string, but it’s messy and I never remember.

This works better:

To say test word:
     (- print (address) TEST_WORD; -).

When play begins:
	if "[test word]" is "test":
		say "Yes it is.";
	say "The test word is [test word]."

Thanks, zarf.

Any hints about which rabbit holes (in terms of documentation and keywords) to go down to try to figure out how to do this the hard way? I am very curious about how to do this, even if it is messy.

It is not a matter of documentation, it is a matter of looking at the I6 code and finding a routine that does something similar.

Basically you have to use the I6 print statement to write to a static I6 array, and then convert that to an I7 text object. TEXT_TY_CastPrimitive() is probably a good model. I think.

Thanks again, zarf. I’ll look into it (and the commentary in Text.i6t) to see if I can make any sense of it.