Welcome to iraf.net Friday, May 17 2024 @ 12:12 PM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 C code in procedure script
   
jacom
 07/22/2011 08:56AM (Read 1706 times)  
+----
Newbie

Status: offline


Registered: 07/22/2011
Posts: 5
Hi,I am using IRAF V2.14I have a C language code coordtransform.c which I want to include in a procedure script.
I have defined it as a foreign task by
task coordtransform = $coordtransform.c
In IRAF it works fine if I do the normal !coordtransform "filename", but the same command in the procedure script does not work.The C code takes a file name as an argument, where the file name is defined as imname // '.coo.1' in the procedure script.In the procedure script I have:
!gcc -lm coordtransform.c -o coordtransform
!./coordtransform , imname // '.coo.1'Is it possible to do it like this?Thanks
Jaco

 
Profile Email
 Quote
fitz
 07/22/2011 08:56AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
For C code, you can't run it directly in a CL script and I doubt you want to compile it every time the script runs, but you're on the right track. What you want is to first compile the code and then call the binary from the script as a foreign task. For example, assuming you've compiled the program you would declare it as a foreign task using the command:[code:1:c917c84ca0]task $foreign = $/path/coordtransform[/code:1:c917c84ca0]You can put this in your login.cl or loginuser.cl file before the final 'keep' statement, or in the script itself.You would then call it from the script using something like[code:1:c917c84ca0]coordtransform (imname // ".coo.1")[/code:1:c917c84ca0]or alternatively as[code:1:c917c84ca0]print ("!/path/coordtransform " // imname // ".coo.1") | cl()[/code:1:c917c84ca0]which simply creates an escaped command string it pipes to the CL to execute.

 
Profile Email
 Quote
jacom
 07/22/2011 08:56AM  
+----
Newbie

Status: offline


Registered: 07/22/2011
Posts: 5
Thank you for the reply.Yes I included the compiling only to see if it runs in the script.
After some playing around with different syntax, I finally got it to work.With only the "coordtransform (imname // ".coo.1")" in the script, I got an error with the arguments in the C code, but the "print ("!/path/coordtransform " // imname // ".coo.1") | cl()" worked just fine.Thanks you!Regards
Jaco

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