Discussion:
How to word wrap in Rexx?
(too old to reply)
Lindy Mayfield
2005-07-06 14:47:37 UTC
Permalink
I've been thinking about this problem for a few days now and I cannot seem to get it in my head the best way to approach it. I have a variable length text string that I want to wrap at word boundaries with a specific maximum length.

For example, if I have a 50 byte fields and I have a string of 80 bytes of text, I want to split up the lines so they fit into the 50 byte fields.

I have a nagging suspicion that I can do this easily in Rexx, but I'm having brain block. Anyone ever done this before? Any specific Rexx functions that were helpful that you used or could suggest?

Many thanks,
Lindy

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Hamilton, Robert L
2005-07-06 14:53:52 UTC
Permalink
It's in a sample file in oorexx, IIRC

bobh

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf
Of Lindy Mayfield
Sent: Wednesday, July 06, 2005 9:46 AM
To: TSO-***@VM.MARIST.EDU
Subject: How to word wrap in Rexx?

I've been thinking about this problem for a few days now and I cannot
seem to get it in my head the best way to approach it. I have a
variable length text string that I want to wrap at word boundaries with
a specific maximum length.

For example, if I have a 50 byte fields and I have a string of 80 bytes
of text, I want to split up the lines so they fit into the 50 byte
fields.

I have a nagging suspicion that I can do this easily in Rexx, but I'm
having brain block. Anyone ever done this before? Any specific Rexx
functions that were helpful that you used or could suggest?

Many thanks,
Lindy

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send
email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Paul Gilmartin
2005-07-06 14:59:17 UTC
Permalink
In a recent note, Lindy Mayfield said:

> Date: Wed, 6 Jul 2005 16:46:18 +0200
>
> For example, if I have a 50 byte fields and I have a string of 80 bytes of text, I want to split up the lines so they fit into the 50 byte fields.
>
while S<>'' do
parse value S with L 51 R
/* if R begins with a blank, L is your next 50-byte chunk
S = strip(R); iterate */
/* else find the rightmost blank in L
(if none, you must break a word)
text before last blank is next <50-byte chunk
S = (text to right of that blank)R; iterate */
end

-- gil
--
StorageTek
INFORMATION made POWERFUL

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
George, William , DHS-ITSD
2005-07-06 15:03:00 UTC
Permalink
I've not done this but you might be able to incorporate the LASTPOS
function.
1) Lastbyte = LastPos(' ',FullString,ByteLimit)
2) Parse Var FullString Line LastByte Fullstring
LINE is the var that contains the data for 1 line.
Put this in a DO loop until FULLSTRING is used up.

This is untested off the top of my head.


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf
Of Lindy Mayfield
Sent: Wednesday, July 06, 2005 7:46 AM
To: TSO-***@VM.MARIST.EDU
Subject: How to word wrap in Rexx?

I've been thinking about this problem for a few days now and I cannot
seem to get it in my head the best way to approach it. I have a
variable length text string that I want to wrap at word boundaries with
a specific maximum length.

For example, if I have a 50 byte fields and I have a string of 80 bytes
of text, I want to split up the lines so they fit into the 50 byte
fields.

I have a nagging suspicion that I can do this easily in Rexx, but I'm
having brain block. Anyone ever done this before? Any specific Rexx
functions that were helpful that you used or could suggest?

Many thanks,
Lindy

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Bob Bridges
2005-07-06 15:04:36 UTC
Permalink
I have a subroutine named "indent" that I use a lot for displaying long
error messages in line mode. It sounds easier than it looks, possibly
because the task (as you've already discovered) is more complex to code
than to describe, and also because once I was using it I couldn't resist
piling lots of extra features into it. So the attached file not only cuts
lines up to specified lengths on a word boundary, it also indents or
outdents and either SAYs the message or returns it on the stack.

The basic cutting tool, though, is a pair of statements.

/* First figure out at which space we're going to cut the line: */
ps=lastpos(' ',message,max_line_length+1)

/* Then cut the line at that point: */
parse var message this_line =(ps) +1 message
/* Now this_line contains the next line of the message, and message has
the remainder. */

You put this in a loop until message has been nibbled away.



---
Bob Bridges, ***@discoverfinancial.com, 224 405-0811
***@attglobal.net, 847 520-1684 xt 243

/* March: On the legal front, a federal jury convicts Martha Stewart on
four counts of needing to be taken down a peg. In what many legal experts
call an unduly harsh punishment, a federal judge sentences Stewart to be
the topic of 17 consecutive weeks of Jay Leno jokes. -Dave Barry, 2004 in
Review */




Lindy Mayfield <***@EUR.SAS.COM>
2005-07-06 09:46

To
TSO-***@VM.MARIST.EDU
cc

Subject
How to word wrap in Rexx?




I've been thinking about this problem for a few days now and I cannot seem
to get it in my head the best way to approach it. I have a variable
length text string that I want to wrap at word boundaries with a specific
maximum length.

For example, if I have a 50 byte fields and I have a string of 80 bytes of
text, I want to split up the lines so they fit into the 50 byte fields.

I have a nagging suspicion that I can do this easily in Rexx, but I'm
having brain block. Anyone ever done this before? Any specific Rexx
functions that were helpful that you used or could suggest?
Lindy Mayfield
2005-07-06 15:08:12 UTC
Permalink
Oorexx? Scratching my head, but I'll Google before asking more...

> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf
> Of Hamilton, Robert L
> Sent: Wednesday, July 06, 2005 4:54 PM
> To: TSO-***@VM.MARIST.EDU
> Subject: Re: How to word wrap in Rexx?
>
> It's in a sample file in oorexx, IIRC
>
> bobh
>
> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf
> Of Lindy Mayfield
> Sent: Wednesday, July 06, 2005 9:46 AM
> To: TSO-***@VM.MARIST.EDU
> Subject: How to word wrap in Rexx?
>
> I've been thinking about this problem for a few days now and I cannot
> seem to get it in my head the best way to approach it. I have a
> variable length text string that I want to wrap at word boundaries with
> a specific maximum length.
>
> For example, if I have a 50 byte fields and I have a string of 80 bytes
> of text, I want to split up the lines so they fit into the 50 byte
> fields.
>
> I have a nagging suspicion that I can do this easily in Rexx, but I'm
> having brain block. Anyone ever done this before? Any specific Rexx
> functions that were helpful that you used or could suggest?
>
> Many thanks,
> Lindy
>
> ----------------------------------------------------------------------
> For TSO-REXX subscribe / signoff / archive access instructions, send
> email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
>
> ----------------------------------------------------------------------
> For TSO-REXX subscribe / signoff / archive access instructions,
> send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Rhea, Matthew
2005-07-06 15:08:01 UTC
Permalink
Here's what I used for 72 positions.

/*---------------------------REXX-------------------------------------*/
/*--------------------------------------------------------------------*/
/* TAKES AN INPUT STATEMENT AND SPLITS IT UP SO THAT EACH */
/* LINE IS NO LONGER THAN 72 POSITIONS */
/*--------------------------------------------------------------------*/
TRACE O
INPUT. = ''
OUTPUT. = ''
I = 0
J = 0
N = 0
/*--------------------------------------------------------------------*/
"EXECIO * DISKR INDD (FINIS STEM INPUT."
IF RC <> 0 THEN
DO
SAY 'ERROR OPENING INDD FILE'
EXIT RC
END /* DO */
ELSE
NOP
/* END IF */
/*--------------------------------------------------------------------*/
DO I = 1 TO INPUT.0
INPUT.I = STRIP(INPUT.I)
IF LENGTH(INPUT.I) > 72 THEN
DO WHILE LENGTH(INPUT.I) > 72
CALL SPLIT_LINE
END /* DO */
ELSE
NOP
/* END IF */
N = N + 1
OUTPUT.N = INPUT.I
END /* DO */
/*--------------------------------------------------------------------*/
"EXECIO * DISKW OUTDD (FINIS STEM OUTPUT."
IF RC > 1 THEN
DO
SAY 'ERROR WRITING OUTDD FILE'
EXIT RC
END /* DO */
ELSE
EXIT
/* END IF */
/*--------------------------------------------------------------------*/
SPLIT_LINE:
DO J = 72 TO 1 BY -1
IF SUBSTR(INPUT.I,J,1) = ' ' THEN
DO
N = N + 1
OUTPUT.N = SUBSTR(INPUT.I,1,J -1)
INPUT.I = SUBSTR(INPUT.I,J+1)
LEAVE
END /* DO */
ELSE
NOP
/* END IF */
END /*DO */
RETURN
/*--------------------------------------------------------------------*/


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU]On Behalf
Of Lindy Mayfield
Sent: Wednesday, July 06, 2005 9:46 AM
To: TSO-***@VM.MARIST.EDU
Subject: [TSO-REXX] How to word wrap in Rexx?


I've been thinking about this problem for a few days now and I cannot seem to get it in my head the best way to approach it. I have a variable length text string that I want to wrap at word boundaries with a specific maximum length.

For example, if I have a 50 byte fields and I have a string of 80 bytes of text, I want to split up the lines so they fit into the 50 byte fields.

I have a nagging suspicion that I can do this easily in Rexx, but I'm having brain block. Anyone ever done this before? Any specific Rexx functions that were helpful that you used or could suggest?

Many thanks,
Lindy

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
gerard46
2005-07-06 18:35:14 UTC
Permalink
| Rhea, Matthew wrote:
| Here's what I used for 72 positions.
|
| /*---------------------------REXX-------------------------------------*/
| /*--------------------------------------------------------------------*/
| /* TAKES AN INPUT STATEMENT AND SPLITS IT UP SO THAT EACH */
| /* LINE IS NO LONGER THAN 72 POSITIONS */
| /*--------------------------------------------------------------------*/
| TRACE O
| INPUT. = ''
| OUTPUT. = ''
| I = 0
| J = 0
| N = 0
| /*--------------------------------------------------------------------*/
| "EXECIO * DISKR INDD (FINIS STEM INPUT."
| IF RC <> 0 THEN
| DO
| SAY 'ERROR OPENING INDD FILE'
| EXIT RC
| END /* DO */
| ELSE
| NOP
| /* END IF */
| /*--------------------------------------------------------------------*/
| DO I = 1 TO INPUT.0
| INPUT.I = STRIP(INPUT.I)
| IF LENGTH(INPUT.I) > 72 THEN
| DO WHILE LENGTH(INPUT.I) > 72
| CALL SPLIT_LINE
| END /* DO */
| ELSE
| NOP
| /* END IF */
| N = N + 1
| OUTPUT.N = INPUT.I
| END /* DO */
| /*--------------------------------------------------------------------*/
| "EXECIO * DISKW OUTDD (FINIS STEM OUTPUT."
| IF RC > 1 THEN
| DO
| SAY 'ERROR WRITING OUTDD FILE'
| EXIT RC
| END /* DO */
| ELSE
| EXIT
| /* END IF */
| /*--------------------------------------------------------------------*/
| SPLIT_LINE:
| DO J = 72 TO 1 BY -1
| IF SUBSTR(INPUT.I,J,1) = ' ' THEN
| DO
| N = N + 1
| OUTPUT.N = SUBSTR(INPUT.I,1,J -1)
| INPUT.I = SUBSTR(INPUT.I,J+1)
| LEAVE
| END /* DO */
| ELSE
| NOP
| /* END IF */
| END /*DO */
| RETURN
| /*--------------------------------------------------------------------*/

A few things...

The above code doesn't handle an input line of all blanks (or a single
blank).

The other thing is that if the input line is > 72 characters, and hasn't
any blanks in it, the DO WHILE LENGTH(INPUT.I)>72 loops.

Also, I so no need to add dead code (ELSE NOP), and non-unique comments
on END /* DO */ phrases.

So, I rewrote the above code just a wee bit and made the issuing of
error messages so that they stand out more. The code also handles a
blank input line.

I also eliminated the DO loop to find the last blank on long lines.

==========================================================================
/*REXX*/ trace o
/*--------------------------------------------------------------------+
| reads input lines & splits them so each line is less than 73 chars |
+--------------------------------------------------------------------*/

@.='' /*stem for input records. */
$.='' /*stem for output records. */
maxlen=72 /*maximum length of each line.*/
nr=0 /*number of lines written. */

"EXECIO * DISKR INDD (FINIS STEM @."
if rc\==0 then call sayer 'error opening INDD file.'

do j=1 to @.0
@.j=space(@.j)
if @.j=='' then @.j=' '
if length(@.j)>maxlen then do while length(@.j)>maxlen
_=lastpos(' ',@.j)
if _==0 then _=length(@.j)
nr=nr+1
$.nr=strip(substr(@.j,1,_-1))
@.j =strip(substr(@.j,_+1))
end
nr=nr+1
if @.j\=='' then $.nr=@.j
end

"EXECIO * DISKW OUTDD (FINIS STEM $."
if rc>1 then call sayer 'error writing OUTDD file.'
exit


sayer: say; say '***error!***' arg(1); say; say 'RC='rc; say; exit rc
=========================================================================

I feel that if you can get the whole shebang on one screen, it is easier
to comprehend (and thus, easier to modify and/or debug).
______________________________________________________________Gerard S.



| -----Original Message-----
| From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU]On Behalf
| Of Lindy Mayfield
| Sent: Wednesday, July 06, 2005 9:46 AM
| To: TSO-***@VM.MARIST.EDU
| Subject: [TSO-REXX] How to word wrap in Rexx?
|
|
| I've been thinking about this problem for a few days now and I cannot seem to get it in my head the best way to approach it. I
have a variable length text string that I want to wrap at word boundaries with a specific maximum length.
|
| For example, if I have a 50 byte fields and I have a string of 80 bytes of text, I want to split up the lines so they fit into the
50 byte fields.
|
| I have a nagging suspicion that I can do this easily in Rexx, but I'm having brain block. Anyone ever done this before? Any
specific Rexx functions that were helpful that you used or could suggest?
|
| Many thanks,
| Lindy
Lindy Mayfield
2005-07-06 15:16:02 UTC
Permalink
Sweeet! Thanks! And thanks for explaining it. Makes sense now.



_____

From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Bob Bridges
Sent: Wednesday, July 06, 2005 5:00 PM
To: TSO-***@VM.MARIST.EDU
Subject: Re: How to word wrap in Rexx?




I have a subroutine named "indent" that I use a lot for displaying long error messages in line mode. It sounds easier than it looks, possibly because the task (as you've already discovered) is more complex to code than to describe, and also because once I was using it I couldn't resist piling lots of extra features into it. So the attached file not only cuts lines up to specified lengths on a word boundary, it also indents or outdents and either SAYs the message or returns it on the stack.

The basic cutting tool, though, is a pair of statements.

/* First figure out at which space we're going to cut the line: */
ps=lastpos(' ',message,max_line_length+1)

/* Then cut the line at that point: */
parse var message this_line =(ps) +1 message
/* Now this_line contains the next line of the message, and message has the remainder. */

You put this in a loop until message has been nibbled away.



---
Bob Bridges, ***@discoverfinancial.com, 224 405-0811
***@attglobal.net, 847 520-1684 xt 243

/* March: On the legal front, a federal jury convicts Martha Stewart on four counts of needing to be taken down a peg. In what many legal experts call an unduly harsh punishment, a federal judge sentences Stewart to be the topic of 17 consecutive weeks of Jay Leno jokes. -Dave Barry, 2004 in Review */




Lindy Mayfield <***@EUR.SAS.COM>

2005-07-06 09:46

To

TSO-***@VM.MARIST.EDU

cc



Subject

How to word wrap in Rexx?








I've been thinking about this problem for a few days now and I cannot seem to get it in my head the best way to approach it. I have a variable length text string that I want to wrap at word boundaries with a specific maximum length.

For example, if I have a 50 byte fields and I have a string of 80 bytes of text, I want to split up the lines so they fit into the 50 byte fields.

I have a nagging suspicion that I can do this easily in Rexx, but I'm having brain block. Anyone ever done this before? Any specific Rexx functions that were helpful that you used or could suggest?


----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Dave Salt
2005-07-06 15:13:42 UTC
Permalink
Hi Lindy,

The following example breaks the text on or before position 30. You can of
course set it to whatever you want:

text = "elephant elephant elephant elephant"
breakat = lastpos(" ",text,30)
say left(text,breakat)
say substr(text,breakat+1)

Hope this helps!

Dave Salt
SimpList(tm) - The easiest, most powerful way to surf a mainframe!
http://www.mackinney.com/products/SIM/simplist.htm




>From: Lindy Mayfield <***@EUR.SAS.COM>
>Reply-To: TSO REXX Discussion List <TSO-***@VM.MARIST.EDU>
>To: TSO-***@VM.MARIST.EDU
>Subject: How to word wrap in Rexx?
>Date: Wed, 6 Jul 2005 16:46:18 +0200
>
>I've been thinking about this problem for a few days now and I cannot seem
>to get it in my head the best way to approach it. I have a variable length
>text string that I want to wrap at word boundaries with a specific maximum
>length.
>
>For example, if I have a 50 byte fields and I have a string of 80 bytes of
>text, I want to split up the lines so they fit into the 50 byte fields.
>
>I have a nagging suspicion that I can do this easily in Rexx, but I'm
>having brain block. Anyone ever done this before? Any specific Rexx
>functions that were helpful that you used or could suggest?
>
>Many thanks,
>Lindy
>
>----------------------------------------------------------------------
>For TSO-REXX subscribe / signoff / archive access instructions,
>send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Ryerse, Robin
2005-07-06 15:24:11 UTC
Permalink
I trust you are aware of ISREDIT's "textflow" (TF line command)


Robin Ryerse
EDS Canada - Software Services - Mainframe
Phone:(905)528-2511.6139 Pager: (905)312-2372

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf
Of Lindy Mayfield
Sent: July 6, 2005 10:46 AM
To: TSO-***@VM.MARIST.EDU
Subject: How to word wrap in Rexx?

I've been thinking about this problem for a few days now and I cannot
seem to get it in my head the best way to approach it. I have a
variable length text string that I want to wrap at word boundaries with
a specific maximum length.

For example, if I have a 50 byte fields and I have a string of 80 bytes
of text, I want to split up the lines so they fit into the 50 byte
fields.

I have a nagging suspicion that I can do this easily in Rexx, but I'm
having brain block. Anyone ever done this before? Any specific Rexx
functions that were helpful that you used or could suggest?

Many thanks,
Lindy

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Lindy Mayfield
2005-07-06 15:47:47 UTC
Permalink
Yes, but I have a long text string in a DB2 table that I want to display on an ISPF screen in a Rexx/DB2/Ispf app wrote.

> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf
> Of Ryerse, Robin
> Sent: Wednesday, July 06, 2005 5:23 PM
> To: TSO-***@VM.MARIST.EDU
> Subject: Re: How to word wrap in Rexx?
>
> I trust you are aware of ISREDIT's "textflow" (TF line command)
>
>
> Robin Ryerse
> EDS Canada - Software Services - Mainframe
> Phone:(905)528-2511.6139 Pager: (905)312-2372
>
> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf
> Of Lindy Mayfield
> Sent: July 6, 2005 10:46 AM
> To: TSO-***@VM.MARIST.EDU
> Subject: How to word wrap in Rexx?
>
> I've been thinking about this problem for a few days now and I cannot
> seem to get it in my head the best way to approach it. I have a
> variable length text string that I want to wrap at word boundaries with
> a specific maximum length.
>
> For example, if I have a 50 byte fields and I have a string of 80 bytes
> of text, I want to split up the lines so they fit into the 50 byte
> fields.
>
> I have a nagging suspicion that I can do this easily in Rexx, but I'm
> having brain block. Anyone ever done this before? Any specific Rexx
> functions that were helpful that you used or could suggest?
>
> Many thanks,
> Lindy
>
> ----------------------------------------------------------------------
> For TSO-REXX subscribe / signoff / archive access instructions,
> send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
>
> ----------------------------------------------------------------------
> For TSO-REXX subscribe / signoff / archive access instructions,
> send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Jeremy C B Nicoll
2005-07-13 16:02:05 UTC
Permalink
In article
<***@emeamail02.emea.sas.com>,
Lindy Mayfield <***@EUR.SAS.COM> wrote:
> Yes, but I have a long text string in a DB2 table that I want to
> display on an ISPF screen in a Rexx/DB2/Ispf app wrote.

Write it to a vio file, then call browse.

--
Jeremy C B Nicoll - my opinions are my own.

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Hamilton, Robert L
2005-07-06 16:00:16 UTC
Permalink
Open object rexx; go to sourceforge.net
bobh

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf
Of Lindy Mayfield
Sent: Wednesday, July 06, 2005 10:07 AM
To: TSO-***@VM.MARIST.EDU
Subject: Re: How to word wrap in Rexx?

Oorexx? Scratching my head, but I'll Google before asking more...

> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On
> Behalf Of Hamilton, Robert L
> Sent: Wednesday, July 06, 2005 4:54 PM
> To: TSO-***@VM.MARIST.EDU
> Subject: Re: How to word wrap in Rexx?
>
> It's in a sample file in oorexx, IIRC
>
> bobh
>
> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On
> Behalf Of Lindy Mayfield
> Sent: Wednesday, July 06, 2005 9:46 AM
> To: TSO-***@VM.MARIST.EDU
> Subject: How to word wrap in Rexx?
>
> I've been thinking about this problem for a few days now and I cannot
> seem to get it in my head the best way to approach it. I have a
> variable length text string that I want to wrap at word boundaries
> with a specific maximum length.
>
> For example, if I have a 50 byte fields and I have a string of 80
> bytes of text, I want to split up the lines so they fit into the 50
> byte fields.
>
> I have a nagging suspicion that I can do this easily in Rexx, but I'm
> having brain block. Anyone ever done this before? Any specific Rexx
> functions that were helpful that you used or could suggest?
>
> Many thanks,
> Lindy
>
> ----------------------------------------------------------------------
> For TSO-REXX subscribe / signoff / archive access instructions, send
> email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
>
> ----------------------------------------------------------------------
> For TSO-REXX subscribe / signoff / archive access instructions, send
> email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send
email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Robert Zenuk
2005-07-06 17:09:31 UTC
Permalink
Here is a quick and dirty example for a split at position 35:

/* rexx - tsplit */
call tsplit 35 'this is a really long msg that should split'
call tsplit 35 'this is a short line'
exit 0
tsplit: arg ll msg
do while length(msg) > ll
lblank = lastpos(' ',msg,ll)
say strip(substr(msg,1,lblank))
msg = strip(delstr(msg,1,lblank))
end
if length(msg) < ll then
say msg
return


Rob

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Lindy Mayfield
2005-07-06 17:10:09 UTC
Permalink
Yes, it did. Many thanks. It was the lastpos forest that I couldn't see for the trees. I kept going down the list of functions thinking one of these should do it.. (-:

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Dave Salt
Sent: Wednesday, July 06, 2005 17:13
To: TSO-***@VM.MARIST.EDU
Subject: Re: How to word wrap in Rexx?

Hi Lindy,

The following example breaks the text on or before position 30. You can of
course set it to whatever you want:

text = "elephant elephant elephant elephant"
breakat = lastpos(" ",text,30)
say left(text,breakat)
say substr(text,breakat+1)

Hope this helps!

Dave Salt
SimpList(tm) - The easiest, most powerful way to surf a mainframe!
http://www.mackinney.com/products/SIM/simplist.htm




>From: Lindy Mayfield <***@EUR.SAS.COM>
>Reply-To: TSO REXX Discussion List <TSO-***@VM.MARIST.EDU>
>To: TSO-***@VM.MARIST.EDU
>Subject: How to word wrap in Rexx?
>Date: Wed, 6 Jul 2005 16:46:18 +0200
>
>I've been thinking about this problem for a few days now and I cannot seem
>to get it in my head the best way to approach it. I have a variable length
>text string that I want to wrap at word boundaries with a specific maximum
>length.
>
>For example, if I have a 50 byte fields and I have a string of 80 bytes of
>text, I want to split up the lines so they fit into the 50 byte fields.
>
>I have a nagging suspicion that I can do this easily in Rexx, but I'm
>having brain block. Anyone ever done this before? Any specific Rexx
>functions that were helpful that you used or could suggest?
>
>Many thanks,
>Lindy
>
>----------------------------------------------------------------------
>For TSO-REXX subscribe / signoff / archive access instructions,
>send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Thom Stone
2005-07-07 03:18:56 UTC
Permalink
Here's a piece of code I got from this list> I believe from Gerard
Hildeberger if I remember his name correctly. It does what you want pretty
much exactly. It will not let the text run over your width limit.

/**/ PARSE ARG WIDTH TXT
CALL WRAPPER WIDTH,TXT /*TEST THE WRAPPER CODE.*/
EXIT
WRAPPER: PARSE ARG SW,TXT; IF SW==0 | SW=='' THEN SW=80
/* SW=SW-1 */ /* IF SCREEN NEEDS AN ATTRIBUTE BYTE.*/
/*(BELOW) NOT RECOMMENDED AS TXT MAY NEED IMBEDDED BLANKS.*/
/* TXT=SPACE(TXT) */
DO FOREVER
TXT=STRIP(TXT); IF LENGTH(TXT)<=SW THEN LEAVE
_=LASTPOS(' ',TXT,SW+1); IF _<2 THEN _=SW
SAY STRIP(LEFT(TXT,_))
TXT=SUBSTR(TXT,_+1)
END
IF TXT\=='' THEN SAY TXT
RETURN

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of
Lindy Mayfield
Sent: Wednesday, July 06, 2005 9:46 AM
To: TSO-***@VM.MARIST.EDU
Subject: How to word wrap in Rexx?

I've been thinking about this problem for a few days now and I cannot seem
to get it in my head the best way to approach it. I have a variable length
text string that I want to wrap at word boundaries with a specific maximum
length.

For example, if I have a 50 byte fields and I have a string of 80 bytes of
text, I want to split up the lines so they fit into the 50 byte fields.

I have a nagging suspicion that I can do this easily in Rexx, but I'm having
brain block. Anyone ever done this before? Any specific Rexx functions
that were helpful that you used or could suggest?

Many thanks,
Lindy

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email
to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Gerard Schildberger
2005-07-07 06:01:39 UTC
Permalink
| Thom Stone wrote:
| Here's a piece of code I got from this list> I believe from Gerard
| Hildeberger if I remember his name correctly. It does what you want pretty
| much exactly. It will not let the text run over your width limit.

Pretty close, it's Gerard Schildberger [***@rrt.net] _______Gerard S.


| /**/ PARSE ARG WIDTH TXT
| CALL WRAPPER WIDTH,TXT /*TEST THE WRAPPER CODE.*/
| EXIT
| WRAPPER: PARSE ARG SW,TXT; IF SW==0 | SW=='' THEN SW=80
| /* SW=SW-1 */ /* IF SCREEN NEEDS AN ATTRIBUTE BYTE.*/
| /*(BELOW) NOT RECOMMENDED AS TXT MAY NEED IMBEDDED BLANKS.*/
| /* TXT=SPACE(TXT) */
| DO FOREVER
| TXT=STRIP(TXT); IF LENGTH(TXT)<=SW THEN LEAVE
| _=LASTPOS(' ',TXT,SW+1); IF _<2 THEN _=SW
| SAY STRIP(LEFT(TXT,_))
| TXT=SUBSTR(TXT,_+1)
| END
| IF TXT\=='' THEN SAY TXT
| RETURN
|
| -----Original Message-----
| From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of
| Lindy Mayfield
| Sent: Wednesday, July 06, 2005 9:46 AM
| To: TSO-***@VM.MARIST.EDU
| Subject: How to word wrap in Rexx?
|
| I've been thinking about this problem for a few days now and I cannot seem
| to get it in my head the best way to approach it. I have a variable length
| text string that I want to wrap at word boundaries with a specific maximum
| length.
|
| For example, if I have a 50 byte fields and I have a string of 80 bytes of
| text, I want to split up the lines so they fit into the 50 byte fields.
|
| I have a nagging suspicion that I can do this easily in Rexx, but I'm having
| brain block. Anyone ever done this before? Any specific Rexx functions
| that were helpful that you used or could suggest?
|
| Many thanks,
| Lindy

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Lindy Mayfield
2005-07-13 16:06:22 UTC
Permalink
Sorry, not that long. (-:

Just 100 bytes. But I display it in 3 33 byte lines on a window.

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Jeremy C B Nicoll
Sent: Wednesday, July 13, 2005 17:58
To: TSO-***@VM.MARIST.EDU
Subject: Re: How to word wrap in Rexx?

In article
<***@emeamail02.emea.sas.com>,
Lindy Mayfield <***@EUR.SAS.COM> wrote:
> Yes, but I have a long text string in a DB2 table that I want to
> display on an ISPF screen in a Rexx/DB2/Ispf app wrote.

Write it to a vio file, then call browse.

--
Jeremy C B Nicoll - my opinions are my own.

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Loading...