Welcome to iraf.net Tuesday, May 21 2024 @ 04:43 AM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 Confusion over paremeter entry with parentheses
   
mdurre
 01/15/2014 04:04AM (Read 702 times)  
+----
Newbie

Status: offline


Registered: 10/14/2013
Posts: 4
Hi, I'm confused how to handle parameters for tasks with or without parentheses. E.g.
PHP Formatted Code
gemlist aaa 100-102
produces
PHP Formatted Code
aaa0100
aaa0101
aaa0102
and the output can be piped to a file, e.g.
PHP Formatted Code
gemlist aaa 100-102 > filelist
However, I want to make the parameters variables, so my understanding is that I have to do the following
PHP Formatted Code
string fname
fname="aaa"
gemlist(fname,"100-102")
This works OK, but I can't pipe it to a file, i.e. I get a syntax error when I do
PHP Formatted Code
gemlist(fname,"100-102") > filelist
** Syntax error
**: gemlist(fname,"100-102") > filelist
                                ^
Alternately, is there a way to force a parameter to be interpreted as a variable, e.g.
PHP Formatted Code
string fname
fname="aaa"
gemlist fname 100-102
and have "fname" interpreted as "aaa"

 
Profile Email
 Quote
fitz
 01/15/2014 04:38AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040

This works OK, but I can't pipe it to a file, i.e. I get a syntax error when I do

gemlist(fname,"100-102") \$this->_split2($m[0]) filelist
** Syntax error
**: gemlist(fname,"100-102") \$this->_split2($m[0]) filelist


The syntax in this case is to put the redirection inside the parenthesis as an addition argument, i.e.

PHP Formatted Code
gemlist (fname, "100-102", > "filelist")


Note that the refirected filename must be quoted if you are giving a literal file name such as 'filelist' in the example, otherwise it will be interpreted as a script variable.


Alternately, is there a way to force a parameter to be interpreted as a variable, e.g.

string fname
fname="aaa"
gemlist fname 100-102

and have "fname" interpreted as "aaa"


Here what you're trying to do is use the "command mode" syntax (i.e. what you normally use on the command line, the form with the parens is known as "program" or "compute" mode) with a script variable, to do this you need to first interpret the variable value to form a valid command. The usual trick to this is something like

PHP Formatted Code

print ("gemlist " // fname // " 100-102") | cl()
 


where you construct the command and pipe it to a CL to execute.

If you haven't already seen it you might check the Script Guide available from https://iraf.net/irafdocs/script for more details.[/code]

 
Profile Email
 Quote
mdurre
 01/15/2014 04:41AM  
+----
Newbie

Status: offline


Registered: 10/14/2013
Posts: 4
AHA, worked perfectly thankyou. Big Grin

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