HP OpenVMS Systems

ask the wizard
Content starts here

Text-formatting DCL Lexical Functions? F$FAO?

» close window

The Question is:

How do I convert a number into a six character string with padded zeroes using
I have a sequence number with leading zeroes held in a file.  I open the file
 and read this number, which is considered a string e.g. "000030".  When I
 increment this number it gets converted to an integer i.e 30.  Before writing
 this back to the file I n
eed to replace the leading zeroes.
There does not appear to be a lexical function to replace the zeroes only
 f$edit to remove them.

The Answer is :

  $ x = f$fao("!6ZL", f$integer("000030") + 1 )
  $ show symbol x
    X = "000031"

answer written or last revised on ( 23-SEP-2004 )

» close window