How to use PUT statement to write numbers as characters?

Posted by untipet on 19-Jun-2018 02:32

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.

Posted by George Potemkin on 19-Jun-2018 02:41

Remove the "UNFORMATTED " option.

All Replies

Posted by George Potemkin on 19-Jun-2018 02:41

Remove the "UNFORMATTED " option.

Posted by jonathan.wilson on 19-Jun-2018 02:44

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

Posted by mollyfed on 19-Jun-2018 02:51

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").

Posted by untipet on 19-Jun-2018 03:59

Thanks for the answers. It was really helpful!

Posted by Brian K. Maher on 19-Jun-2018 05:56

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+
 
 

Posted by mollyfed on 26-Jun-2018 17:10

Is there an echo in here? ;-) [tag:GreatMindsThinkALike] #ButFoolsNeverDiffer

This thread is closed