How to use PUT statement to write numbers as characters? - Forum - OpenEdge General - Progress Community

How to use PUT statement to write numbers as characters?

 Forum

How to use PUT statement to write numbers as characters?

This question is answered

Hi folks, I supose this is a very simple question, but I haven't found an answer.

I'm using the PUT statement to write into a file a collection of numbers. The problem is that I need them to be a character but when using the PUT UNFORMATTED it writes it as number instead. There is an example of code and the result.

OUTPUT TO VALUE(cFilePath) APPEND.

PUT UNFORMATTED cId.

If I print the value of cId it's '0123', but the value written in the file is '123'.

Any idea about how to use PUT to write it correctly?

Thanks in advance.

Verified Answer
  • Remove the "UNFORMATTED " option.

All Replies
  • Remove the "UNFORMATTED " option.

  • So is cId a INT or CHAR?  You should really include its DEF VAR and also how you populate the data.

  • Or if you can't for other reasons remove the UNFORMATTED option, could you convert them to string before or in the put statement with the formatting wanted. I.E. PUT UNFORMAT string(cid,"9999").

  • Thanks for the answers. It was really helpful!

  • put unformatted string(cID,”9999”)  <- assuming you want it to by 4 bytes long with leading zeroes
     
     
    Brian Maher
    Principal Engineer, Technical Support
    Progress
    Progress
    14 Oak Park | Bedford, MA 01730 | USA
    phone
    +1 781 280 3075
     
     
    Twitter
    Facebook
    LinkedIn
    Google+
     
     

  • Is there an echo in here? ;-) #GreatMindsThinkALike #ButFoolsNeverDiffer