Welcome to iraf.net Friday, May 03 2024 @ 08:22 PM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 chomp
   
hbar
 12/04/2006 03:11PM (Read 3154 times)  
+----
Newbie

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

 
Profile Email
 Quote
fitz
 12/04/2006 03:11PM  
AAAAA
Admin

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

 
Profile Email
 Quote
   
Content generated in: 0.12 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login