Getting the length of a string

0 votes
95 views
asked Jun 3 in Authoring by Cactus (8 points)

How do I get the length of a string programmatically, in Inform 6?

1 Answer

+1 vote
answered Jun 19 by AndrewS (250 points)

http://www.firthworks.com/roger/informfaq/ii.html suggests this solution which is two-part and thus a bit awkward. I suspect there is a better one. Given a string "string" and integer strLength,

string.print_to_array(array);
strLength = array-->0;

This would give the string length. I couldn't find a better way to do this. you'll probably want to put this in a function, but my I6 is just really rusty, so this is the best I've got. Hope this helps.

This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...