Login
Remember
IF Answers
Ask a Question

# 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?

- inform6

## 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.

## Related questions

- Is there a limit to the length of a script in Quest?
- How can I set the player smell in Inform 6?
- Inform6 from the ground up -- Actions not working
- How do I change 'if the player consents'? pre-Inform 6L or post-
- Is there a maximum rules limit in Inform 6?

...