Posted: Fri Jul 22, 2011 8:56 am Post subject: C code in procedure script
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'
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
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.
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