STR$ function

Purpose:

STR$ converts an INTEGER, SINGLE, or DOUBLE number to a string.

Syntax:

RetStr = STR$(Number [, NoSpace AS INTEGER])

Return Value:

  • Data type: STRING
    RetStr The string converted from the Number parameter argument.

Parameters:

  • Number INTEGER, SINGLE, or DOUBLE literal or variable.
  • Data type: INTEGER
    NoSpace [OPTIONAL] The default no argument or 0 indicates that a space is prepended to the returned string if the Number is positive. If NoSpace is 1 then the space will not be prepended to the RetStr.

Remarks:

👉 By default, a space is prepended to the returned string if Number is positive and the optional NoSpace parameter is empty or 0. This space is the location for the sign part of the number. When the Number argument is a negative number, a minus sign will be there.

Example:

 DIM RetStr$

 RetStr$ = STR$(3.14159265358979)

 PRINT DQ$ & RetStr$ & DQ$

 RetStr$ = STR$(-3.14159265358979)

 PRINT DQ$ & RetStr$ & DQ$

 RetStr$ = STR$(3.14159265358979, 1)

 PRINT DQ$ & RetStr$ & DQ$

Result:

" 3.14159265358979"
"-3.14159265358979"
"3.14159265358979"

BCX Console Sample Programs using the STR$ function.

STRL$ function

Purpose:

STRL$ converts an LDOUBLE number to a string.

Syntax:

RetStr = STRL$(Number [, NoSpace AS INTEGER])

Return Value:

  • Data type: STRING
    RetStr The string converted from the Number parameter argument.

Parameters:

  • Number Integer or floating point literal or variable.
    👉 "L" must be appended to the LDOUBLE literal number.
  • Data type: INTEGER
    NoSpace [OPTIONAL] The default no argument or 0 indicates that a space is prepended to the returned string if the Number is positive. If NoSpace is 1 then the space will not be prepended to the RetStr.

Remarks:

👉 By default, a space is prepended to the returned string if Number is positive and the optional NoSpace parameter is empty or 0. This space is the location for the sign part of the number. When the Number argument is a negative number, a minus sign will be there.

Example:

DIM RetStr$
 
RetStr$ = STRL$(3.141592653589793239L)
PRINT DQ$ & RetStr$ & DQ$
 
RetStr$ = STRL$(-3.141592653589793239L)
PRINT DQ$ & RetStr$ & DQ$

RetStr$ = STRL$(3.141592653589793239L, 1)
PRINT DQ$ & RetStr$ & DQ$

Result:

" 3.141592653589793239"
"-3.141592653589793239"
"3.141592653589793239"