Re: Need help with basic spawn command [message #54066 is a reply to message #54064] |
Thu, 17 May 2007 04:14   |
Allan Whiteford
Messages: 117 Registered: June 2006
|
Senior Member |
|
|
Note that the return value can be obtained (at least under unix) with
the exit_status keyword to spawn.
IDL> spawn, 'basic', exit_status=a
IDL> print,a
10
however, it's far more useful to use the printf in your program as Yi
suggested to return data back. The exit status is typically used to
return whether or not a command executed correctly or not.
Probably best to ignore this message unless you're really sure that you
want the return value from the program rather than just its output.
Thanks,
Allan
Yi wrote:
> IDL's spawn procedure can't get the return value from C program.
> Of course, you can get the result using second argument like this :
>
> IDL> spawn, 'basic', result
>
> In this case, the result variable is not the return value of main
> function(C Program)
> but the output text result of the 'basic' command in Shell(Unix) or
> Command Prompt(MS Windows)
>
> The 'result' variable is string array, so it can catch multi lines
> text output.
>
> Anyway, if you want to use spawn procedure, the C program should be
> modified.
>
> I expect that you can get result if you insert,
>
> printf("%d", n);
>
> into your C code.
>
>
> On 5占쏙옙17占쏙옙, 占쏙옙占쏙옙7占쏙옙34占쏙옙, ryans...@gmail.com wrote:
>
>> Im running IDL on XP.
>>
>> I have this basic C code:
>>
>> #include <stdlib.h>
>>
>> int main()
>> {
>>
>> int n=5;
>> n=n*2;
>> return n;}
>>
>> //This file is basic.c
>>
>>> From IDL, I just want to call this program and return n.
>>
>> In IDL, I can write:
>>
>> SPAWN, 'basic' ; this of course runs the
>> basic.c program.
>>
>> But this doesnt return anythingof course.. ive tried to add another
>> variable after this line such as:
>> SPAWN, 'basic', variable
>>
>> But windows doesnt like any of this...
>>
>> Can anyone help me with this basic application? With spawn in the past
>> ive gotten it to do calculations on a variable and return them, but
>> with no input, im unsure how to get the output.
>>
>> Thanks for any help! Ive also boughten the 'from c->dlm->idl' book but
>> it wont be in for a few days.
>
>
>
|
|
|