Welcome to iraf.net Friday, March 29 2024 @ 12:03 AM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 Basic questions How to define string arrays and clear strings and arrays that I want to redefine
   
andrej
 12/15/2014 06:13PM (Read 1843 times)  
+++--
Chatty

Status: offline


Registered: 08/21/2009
Posts: 57
Greetings. I am struggling so much to find some basic information but when I run a bunch of general internet searching, and search through the manual and the help in IRAF itself, I can't find answers to some basic things (tried on a few different days and have spent almost 6 hours with an exhaustive combination of search terms):

(1) How do I create a string array like "first," "second," "third," "fourth"?

(2) How do I print the whole string? Like if I do

string mycustomarray = "first," "second," "third," "fourth"

How can I use a print command to get

first, second, third, fourth

to appear in the Terminal?


(3) How do I clear the definition of mycustomarray so that I can define it to be something else later, like

mycustomarray = "one," "two," "three," "four"

?


(4) Likewise, how do I clear the definitions of other strings that I create, for example,

string myvariable = "December2014"

and redefine it to be

myvariable = "January2015"

?


(5) Where can I find a tutorial or workshop on how to work with how to set my own IRAF variables? The resources that I located were about parameters within tasks and advanced scripting.

 
Profile Email
 Quote
fitz
 12/16/2014 04:23PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
(1) How do I create a string array like "first," "second," "third," "fourth"?


Try
string foo[4] = "first", "second", "third", "fourth"

The size of the array must be part of the declaration.


(2) How do I print the whole string? Like if I do

string mycustomarray = "first," "second," "third," "fourth"

How can I use a print command to get

first, second, third, fourth

to appear in the Terminal?


You would have to do it in a loop, e.g.

PHP Formatted Code

   for (i=1; i <= 4; i=i+1) {
       printf ("%s", foo[i])
       if (i < 4)
           printf (",")
       else
           printf ("\n")
    }
 


(3) How do I clear the definition of mycustomarray so that I can define it to be something else later, like

mycustomarray = "one," "two," "three," "four"

?


You can't "undeclare" the array, you can simply reuse the elements. Note this means you can't change the size either.



(4) Likewise, how do I clear the definitions of other strings that I create, for example,

string myvariable = "December2014"

and redefine it to be

myvariable = "January2015"

?


Just exactly like that, i.e. you redefine to the value.


(5) Where can I find a tutorial or workshop on how to work with how to set my own IRAF variables? The resources that I located were about parameters within tasks and advanced scripting.


In case you haven't already found it, see the Script Guide at https://iraf.net/irafdocs/script/ as well as the CL Programmer's Manual at
ftp://iraf.noao.edu/iraf/docs/clman.ps.Z

 
Profile Email
 Quote
   
Content generated in: 0.11 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