Cnvrt$

From Br Wiki
(Redirected from CNVRT$)
Jump to: navigation, search
CNVRT$ (<spec$>, <numeric expression>)

The CNVRT$ internal function returns a string representing the numeric value X in the format specification coded in the string spec$. Spec$ is a string that has the same syntax as format specifications in the FORM statement for READ/WRITE operations. B, BH, BL, D, G, GZ, L, N, NZ, PD, PIC, S and ZD are allowed.

Comments and Examples

CNVRT$ is an enhanced version of STR$ that provides a lot of flexibility in converting a number to a string.

00010 LET A=0
00020 LET B=10
00030 LET C=.10
00040 PRINT USING 50: STR$(A),STR$(B),STR$(C)
00050 FORM C 5
00060 LET S$="NZ 5.2"
00070 PRINT USING 50: CNVRT$(S$,A), CNVRT$(S$,B), CNVRT$(S$,C)

The output on your screen would be:

    0  10 0.1
    10.00 0.10

Related Functions

The Str$ function also converts numbers to strings, but without the format control of CNVRT$.

Technical Considerations

  1. CNVRT$ takes much longer to execute than formatting with FORM statements.