I vaguely remember pointers being supported in TADS3 but documentation is sparse and seems to only cover function pointers, so I thought I’d post my use case here.
Let’s say I have a “global” string variable somewhere, maybe a message I’d like to use in multiple places.
myGlobal
fooMsg = 'bar baz '
;
myObj : Thing
cannotTakeMsg = &myGlobal.fooMsg // How do I do this?
;
The idea is that I could change the string later and all references to it would also update. Essentially, I need to use a C-style string pointer. Is this possible in TADS3?
Have you tried simply losing the ampersand? The cannotTakeMsg should re-evaluate every time it’s accessed, so if you change the global the takeMsg should reflect it, unless I’m misunderstanding what you’re asking…
Is there some reason you don’t want to just put it in playerActionMessages where most of these kind of messages live? Something like:
modify playerActionMessages
cantWhateverHere = '{You/he} can\'t do that here. '
cantWhateverObj(obj) { return('{You/he} don\'t do that to the <<obj.theName>>. '); }
;