Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add spaces in the middle of a string 2

Status
Not open for further replies.

tatoriver

Programmer
Mar 23, 2009
27
0
0
US
Hello
Iam tryng to add some spaces in the middle of a string, is there any function to do this?

Example:

ws-var pic x.
change it for
ws-var pic x.

Thank you very much for your help.

Good bye
 

Is this for aligning text? I would suggest an edit macro if you have ISPF.

If you have to do it by "brute force", consider PARSE and OVERLAY:
Code:
parse var text w1 w2 w3 w4 ....
outstr = w1
outstr = Overlay( w2,outstr,15 )
outstr = Overlay( w3,outstr,31 )
(etc)

Frank Clarke
--America's source for adverse opinions since 1943.
 
yes this is for aligning text, i would like to align all the PIC at column 33, how can i do it with a macro?
 
I know nothing about writing REXX macros in ISPF.
But as rexxhead suggested, in normal REXX I would do something like this:
Code:
var01 [COLOR=#804040][b]=[/b][/color] [COLOR=#ff00ff]"WS-TextVar    pic x(10)."[/color]
var02 [COLOR=#804040][b]=[/b][/color] [COLOR=#ff00ff]"ws-Numvar-zoned       PIC      9(8)."[/color]
var03 [COLOR=#804040][b]=[/b][/color] [COLOR=#ff00ff]"ws-numvar-packed pic S9(15)V9(2) comp-3."[/color]

[COLOR=#804040][b]say[/b][/color] var01
[COLOR=#804040][b]say[/b][/color] var02
[COLOR=#804040][b]say[/b][/color] var03
[COLOR=#804040][b]say[/b][/color]

[COLOR=#804040][b]say[/b][/color] [COLOR=#008080]format_line([/color]var01[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#008080]format_line([/color]var02[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#008080]format_line([/color]var03[COLOR=#008080])[/color]
[COLOR=#804040][b]exit[/b][/color]
[COLOR=#0000ff]/**************************************************/[/color]
[COLOR=#008080]format_line[/color]: [COLOR=#804040][b]procedure[/b][/color]
  [COLOR=#804040][b]parse arg[/b][/color] line_in
  [COLOR=#804040][b]parse upper var[/b][/color] line_in varname pic picture comp [COLOR=#ff00ff].[/color]
  line_out [COLOR=#804040][b]=[/b][/color] varname
  line_out [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]overlay([/color] pic[COLOR=#804040][b],[/b][/color] line_out[COLOR=#804040][b],[/b][/color]33 [COLOR=#008080])[/color]
  line_out [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]overlay([/color] picture[COLOR=#804040][b],[/b][/color] line_out[COLOR=#804040][b],[/b][/color]37[COLOR=#008080])[/color] 
  line_out [COLOR=#804040][b]=[/b][/color] line_out comp
  [COLOR=#804040][b]return[/b][/color] line_out
Output:
Code:
WS-TextVar    pic x(10).
ws-Numvar-zoned       PIC      9(8).
ws-numvar-packed pic S9(15)V9(2) comp-3.

WS-TEXTVAR                      PIC X(10).
WS-NUMVAR-ZONED                 PIC 9(8).
WS-NUMVAR-PACKED                PIC S9(15)V9(2) COMP-3.
 
It was rexxhead's idea, the thanks should go to him
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top