Skip to content
Property Value
Hex Value $BB2B
Categories
Localizations
  • FR: longueur(

length(

Overview

Returns the number of characters in string.

Availability: Token available everywhere.

Syntax

length(string)

Arguments

NameTypeOptional
stringstring

Location

2nd, catalog, length(


Description

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

Source: parts of this page were written by the following TI|BD contributors: burr, DarkerLine, GoVegan, jonbush, kg583, Michael2_3B.

History

Calculator OS Version Description
TI-83 0.01013 Added
Authors: Adrien Bertrand