I am wondering if there is a way to get the number of characters in a text property? For example, each object may or may not have a (TEXT) property within its declaration (I know this is generally used for ‘Reading’) - I would like to display that text centred on the screen but, as it could vary from item to item, I would need to know the length of the ‘string’.
I wish the “JAPAN: 1954” to be printed centred on the screen - currently I am also creating another property called TEXTLEN to pass the length of the text to a CENTRE routine but was wondering if there was anyway in ZIL to get the length of this without the need to explicitly pass the info?
Any help would be appreciated, even if it only expanded my knowledge of the ZIL language
It’s true that the Z-machine has no way of checking the length of a string without printing it to memory, and what makes it worse is that it’s up to the programmer to make sure the buffer you print to is big enough for the string, or it will write past the end of the buffer and probably destroy some other important data.
Yes, the ‘buffer’ size in @eriktorbjorn example of 80 char should suffice for me (as I only need about 40 for the largest of my strings) but I take your point that we don’t want to end up overflowing across important data! - thanks AG
Another way to do this would be to write a PROPDEF/PROPSPEC that computes the length of the string at compile time, then stores it next to the string pointer in the property.