View previous topic :: View next topic
|
Author |
Message |
Rexxguy Currently Banned New User
Joined: 25 Sep 2008 Posts: 2 Location: Malaysia
|
|
|
|
Hi Guys,
Can you please tell me how to move a words in string of words to particular position using REXX...
Example...
From
Code: |
1234567890123456789012345678901234567890123456789012345678901
REXX IS GOOD TO LEARN AS A SYSTEM LANGUAGE |
To
Code: |
1234567890123456789012345678901234567890123456789012345678901
REXX IS GOOD----spaces-----------------TO--spaces----LEARN
AS A SYSTEM LANGUAGE |
I would like to change the TO stmt to pos 40 and LEARN to 54 pos...
after movement if there is enough space in the line the rest of words can be accomodated...else I need to write to the next line...
Is there any way around in REXX to achive the above solution.. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
did You care to search the forum for "rexx string" ( all the terms ) |
|
Back to top |
|
|
genesis786
Active User
Joined: 28 Sep 2005 Posts: 210 Location: St Katherine's Dock London
|
|
|
|
u can try something like this:
Code: |
/* rexx */
str = 'Rexx is good to learn as a system language'
str1 = left(substr(str,1,pos('to',str)-1),40,' ')
str2 = substr(str,pos('to',str))
say str1 || str2
exit
|
but not really sure why would u want to do this?
there can be many other ways if u look at string functions
check this out
www.kilowattsoftware.com/tutorial/rexx/ |
|
Back to top |
|
|
Maverick34
New User
Joined: 19 Aug 2007 Posts: 4 Location: UK
|
|
|
|
You can fill out a string with a "pad" field using the "substr" function, plus it can be used to carve up a sting into separate parts.
Check out the manual.
Regards
Mark |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello rg and welcome to the forums,
Quote: |
after movement if there is enough space in the line the rest of words can be accomodated...else I need to write to the next line.. |
Your example does not show this. . . Why is "AS" not on the same line with LEARN?
If there are no solid rules, it will be difficult to implement.
Also, please note that your "data" has been "Code"ed - using the "Code" tag at the top of the Reply panel. This uses a fixed font and will preserve your alignment. Use Preview to see how your post will appear to the forum (rather than how it appears in the reply editor). When your are satisfied with the appearance, Submit. |
|
Back to top |
|
|
|