The string() Command

string.png

Command Summary

Converts any expression to a string.

Command Syntax

string(expression)

Menu Location

  • Press 2nd MATH to enter the MATH popup menu.
  • Press D to enter the String submenu.
  • Press 1 to select string(.

Calculator Compatibility

This command works on all calculators.

Token Size

2 bytes

The string() command converts any expression to its string form. This applies to numbers, but also to lists, matrices, symbolic expressions, and equations. The result depends on all the mode settings that are typically involved with displaying a number: base, exact/approx setting, etc.

:string(50)
           "50"
:string({1,2,3,4,5})
           "{1,2,3,4,5}"
:string(1/(1-x))
           "-1/(x-1)"

The main use of string() is with output commands like PtText, PxlText, Text, Title, etc. These commands only work with strings, so for any other data type, you'll have to use string() first — & will also come in handy. For example:

:Text "The value of x is: "&string(x)

If you're just converting numbers, you might also want to look into format(), which only applies to numbers and also puts them in a specific form.

Advanced Uses

Together with the # (indirection) operator, string() can be used to access variables like a1, a2, a3, …, in order:

:#("a"&string(n))

Related Commands

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