STR
 
Syntax

STR( expression )
Description


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 bstring

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

STR is useful for computation such as STR(x/5),  which will compute x divided by 5 and then convert to ASCII, in this case STR() is required

For floating point numbers use SPRINTF.

Example


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

Differences from other BASICs

See also