The length( Command

We're glad you came by, but you might find what you're looking for elsewhere.

TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it.

Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope.

LENGTH.GIF

Command Summary

Returns the length of a string.

Command Syntax

length(string)

Menu Location

This command can only be found in the catalog. Press:

  1. 2nd CATALOG to access the command catalog
  2. L to skip to commands starting with L
  3. scroll down to length( and select it

Calculator Compatibility

TI-83/84/+/SE

Token Size

2 bytes

This command is used to determine the length of a string. Unlike the dim( command for lists and matrices, it cannot be used to change this length, as there is no null character for strings (the null value is 0 for lists and matrices).

:length("HELLO
    5

Keep in mind that the length is measured in the number of tokens, and not the number of letters in the string. For example, although the sin( command contains 4 characters ("s", "i", "n", and "("), it will only add 1 to the total length of a string it's in. The execution time for length( is directly proportional to the length of the string.

Advanced Uses

The code for looping over each character (technically, each token) of a string involves length(:

:For(N,1,length(Str1
...
use sub(Str1,N,1 for the Nth character
...
:End

Related Commands

.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.