STR( expression )

STR will convert an integer  expression into a string.

For example, STR(3) will become "3", or STR(333) will become "333".

Incidentally, this is the opposite of the VAL function, which converts a string into a number.

STR is also used in certain routines of the Hardware Library to designate that a series of bytes should be read or written to a string.

Also in the following case the STR function is implied and is not required.

bstring = 333 + " sent"         '  will save the ASCI string "333 sent" into b$

The implied STR will work for simple expressions, but anything complex should use STR(), this would include any function call, array element fetches.

For floating point numbers use SPRINTF.


DIM bstring (10) AS STRING
a = 8421
bstring = STR(a)
PRINT a, b     ' will display    8421     8421

Differences from other BASICs

See also