comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Need help with basic spawn command
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Need help with basic spawn command [message #54059] Thu, 17 May 2007 08:32 Go to previous message
ryanselk is currently offline  ryanselk
Messages: 16
Registered: May 2007
Junior Member
On May 17, 2:45 am, Yi <yi.se...@gmail.com> 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.


Thank you so much, I understand now! Your right that it works when
adding a printf to the code with the result on the spawn.

I was under the impression that this would not work on windows, only
unix, not sure why, but it does.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: write a root group to HDF5 file
Next Topic: 2D interpolation with sparse data

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:53:21 PDT 2025

Total time taken to generate the page: 0.00401 seconds