Welcome to iraf.net Friday, May 03 2024 @ 08:22 PM GMT
hbar |
12/04/2006 03:11PM (Read 3154 times)
|
|
|
Status: offline
Registered: 12/04/2006
Posts: 1
|
Hi,in a cl script I am trying to read in a string of numbers, e.g. "12,15,19". Is there an easy way to split this string at the delimiter "," into individual components and convert the numbers into integers?hbar
|
|
|
|
fitz |
12/04/2006 03:11PM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
If it's a small string as in your example, try[code:1:af7859ba1c]cl> print ("1,2,3") | trans STDIN "," " " | scan (i,j,k)[/code:1:af7859ba1c]The TRANSLIT task can do the split, and then you just "scan-from-pipe" into the variables you want. If it's a longer list, instead of a space use "\n" to force a newline, redirect to a file and then read through the file in the usual way.-Mike
|
|
|
|
| |
|
Content generated in: 0.12 seconds |
|