Right Justify Character output

Cjandura58

New Member
I need to output several numerics fields as strings using stream but I need to right justify these fields and fill the left side with spaces. Can any one help me out with this.

This is an example of what I'm doing. The entire file will output 80 string fields to a file.
______________________________________________________
Def Stream strmHELPL.
Def Var file-out As char No-undo.
Assign file-out = "C:\unidev50\HELPECdata.txt".
Def Var f-strTmp As char No-undo.
f-strTmp = "".
f-strTmp =
/* header */
String(vh-Client,"x(4)") + String(vh-BatchFeedId,"x(6)") +
String(vh-BatchSeqNum,"x(6)") + String(vh-RecType,"x(4)") +
String(vh-Tsys,"x(30)") + String(vh-TransId,"x(8)") +
String(vh-FillerA,"x(2700)").

Output Stream strmHELPL To Value(file-out).
Put Stream strmHELPL UnFormatted f-strTmp.
Output Stream strmHELPL Close.
__________________________________________________________

Thanks,
Carrie Jandura :confused:
 
Carrie,

You could use something like this to format your string:

... /* header */

replace(string(vh-Client, '9999', '0', ' ' ) +
replace(string(vh-BatchFeedId, '999999', '0', ' ' ) +
replace(string(vh-BatchSeqNum, '999999', '0', ' ' ) etc.

As usual there is probably a neater way to do this, but hopefully this will help?


Cheers,
John



Originally posted by Cjandura58
I need to output several numerics fields as strings using stream but I need to right justify these fields and fill the left side with spaces. Can any one help me out with this.

This is an example of what I'm doing. The entire file will output 80 string fields to a file.
______________________________________________________
Def Stream strmHELPL.
Def Var file-out As char No-undo.
Assign file-out = "C:\unidev50\HELPECdata.txt".
Def Var f-strTmp As char No-undo.
f-strTmp = "".
f-strTmp =
/* header */
String(vh-Client,"x(4)" ) + String(vh-BatchFeedId,"x(6)" ) +
String(vh-BatchSeqNum,"x(6)" ) + String(vh-RecType,"x(4)" ) +
String(vh-Tsys,"x(30)" ) + String(vh-TransId,"x(8)" ) +
String(vh-FillerA,"x(2700)" ).

Output Stream strmHELPL To Value(file-out).
Put Stream strmHELPL UnFormatted f-strTmp.
Output Stream strmHELPL Close.
__________________________________________________________

Thanks,
Carrie Jandura :confused:
 
Carrie,

I have just noticed that the example I gave you is not correct as it replaces all zeros with spaces. Not good at all! Sorry. Try this instead:
... /* header */

string(vh-Client, '>>>9' ) +
string(vh-BatchFeedId, '>>>>>9' ) +
string(vh-BatchSeqNum, '>>>>>9' ) etc.




Originally posted by amazing66
Carrie,

You could use something like this to format your string:

... /* header */

replace(string(vh-Client, '9999', '0', ' ' ) +
replace(string(vh-BatchFeedId, '999999', '0', ' ' ) +
replace(string(vh-BatchSeqNum, '999999', '0', ' ' ) etc.

As usual there is probably a neater way to do this, but hopefully this will help?


Cheers,
John
 
Back
Top