Convert number to text (string)
You can use the WRITE instruction to convert a numeric value into a text. The text can then be used, for example, as a marker with the "Sign text" or "Engrave text" function. Or it can be written as a comment in the parts legend (header).
In the following example, the real variable RVAR is formatted as text and then saved in the variable TEXTVAR. To do this, a skip mark is transferred as the second parameter in the WRITE instruction. The line with the skip mark must contain the format instruction.
In the format instruction, a text is written in front of the numerical value ("distance ") and another text behind it (" mm").
C NOTE: The text variable TEXTVAR must be declared in the program header
C !
C CHARACTER *80 TEXTVAR
C
C Example:
C -------------------------------
C Convert number to text (string)
C -------------------------------
C Realvariable RVAR
RVAR = 123.456
C
C Write instruction (writes the value of RVAR as text in the
C Variable TEXTVAR
WRITE(TEXTVAR, 1001) RVAR
C
C Line with format instruction (7 digits before the decimal point and
C 2 digits behind it)
1001 FORMAT("Distance ",F7.2," mm")
C
C
C Output formatted text as CAD
CALL PVB445 (20.0,70.0,TEXTVAR,2,20.0,0.0,IRET)
C
C The output with the instruction:
WRITE(6,*)TEXTVAR
C
C produces: "Distance 123.46 mm"
C