The length( Command
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-ShareAlike 3.0 License