[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

[sqr-users] Re: array printing challenge



This is not very eligant solution, but I think it might solve the problem.  
Unstring the field by you delimiter ('|'), then restring it with a single 
space on each side of the delimiter (' | ').  If the number of values per 
line is variable, follow that with an RTrim to remove any unwanted trailing 
delimiters.  Here's a little example:

begin-program
Let $NewVal = '123|456|789|123|456|789|123|456|789|123|456|789'
Print 'As is, from input file:'  (+0,1)
Print $NewVal (+1,1)  Wrap 14 10

Unstring $NewVal
     By  '|'
    Into $F01
         $F02
         $F03
         $F04
         $F05
         $F06
         $F07
         $F08
         $F09
         $F10
         $F11
         $F12
         $F13
         $F14
         $F15
         $F16
         $F17
         $F18
         $F19
         $F20

String   $F01
         $F02
         $F03
         $F04
         $F05
         $F06
         $F07
         $F08
         $F09
         $F10
         $F11
         $F12
         $F13
         $F14
         $F15
         $F16
         $F17
         $F18
         $F19
         $F20
    By   ' | '
   Into  $NewVal

Print 'After Restring:'  (+4,1)
Print $NewVal (+1,1)  Wrap 14 10

Let $NewVal = RTrim($NewVal,'| ')
Print 'After RTrim:'  (+4,1)
Print $NewVal (+1,1)  Wrap 14 10
End-Program


And here's what the output would look like:


As is, from input file:
123|456|789|12
3|456|789|123|
456|789|123|45
6|789



After Restring:
123 | 456 |
789 | 123 |
456 | 789 |
123 | 456 |
789 | 123 |
456 | 789 |  |
|  |  |  |  |
|



After RTrim:
123 | 456 |
789 | 123 |
456 | 789 |
123 | 456 |
789 | 123 |
456 | 789



_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users