Submit a Story  :  IRAF Links  :  Past Polls  :  Calendar  :  Advanced Search  
     iraf.net
FAQ
 Forum FAQForum FAQ   Forum SearchForum Search   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

C code in procedure script

 
Post new topic   Reply to topic    iraf.net Forum Index -> General IRAF
View previous topic :: View next topic  
Author Message
jacom



Joined: 22 Jul 2011
Posts: 5

PostPosted: Fri Jul 22, 2011 8:56 am    Post subject: C code in procedure script Reply with quote

Hi,

I am using IRAF V2.14

I 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
Back to top
View user's profile Send private message
fitz
Site Admin


Joined: 30 Sep 2005
Posts: 3257
Location: Tucson

PostPosted: Fri Jul 22, 2011 10:31 pm    Post subject: Reply with quote

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:
task $foreign = $/path/coordtransform


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:
coordtransform (imname // ".coo.1")


or alternatively as

Code:
print ("!/path/coordtransform " // imname // ".coo.1") | cl()


which simply creates an escaped command string it pipes to the CL to execute.
Back to top
View user's profile Send private message
jacom



Joined: 22 Jul 2011
Posts: 5

PostPosted: Mon Jul 25, 2011 11:02 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    iraf.net Forum Index -> General IRAF All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2009 phpBB Group
 Copyright © 2005-2011 iraf.net
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.12 seconds