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

Home » Public Forums » archive » Re: [call_external] how to use it ?
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: [call_external] how to use it ? [message #28473 is a reply to message #28455] Wed, 12 December 2001 11:38 Go to previous messageGo to previous message
Joel Gales is currently offline  Joel Gales
Messages: 6
Registered: December 2001
Junior Member
Richard Hitier wrote:

> Hi there,
>
> I've been trying to use this fonctionality for hours now,
> but... couldn't succeed :(
>
> 1st: the manual example doesn't work for me
> the array pointer doesn't point to the good values.
> (getting very high values ...)
>
> 2nd: in my own example it seems that I have to use long
> interger in idle to be able to use (int) in the C code.
>
> I'm trying to modify an array throug C routine, but
> couldn't:
> working with the array pointer doesn't seem to alter the
> idl array at all.
>
> I'm working on a Solaris station,
> using gcc compiler.
>
> There are the files:
>
> ---------------test.c-----------------------------
> int function(int argc, void *argv[])
> {
> int s=0,*ip;
> int i;
> for (i=0, ip=(int*)argv[0]; i<*(int*)argv[1]; i++, ip++)
> {
> s+=*ip;
> printf("i:%d ip:%f \n",i,*ip);
> }
> return(s);
> }
> --------------------------------------------------
>
> ---------------test.pro---------------------------
> pro none, zize
> tab = indgen(zize)
> machin=10
> print, "d'abord"
> print, tab
> i=call_external('none.so', 'function', tab, n_elements(tab))
> print, "ensuite", i
> print, tab
> end
> --------------------------------------------------
>
> ----------------Makefile--------------------------
> .SUFFIXES:
> .SUFFIXES: .c .so
>
> .c.so:
> gcc -g -fPIC $< -shared -o $@
>
> --------------------------------------------------
>
> By the way, does any one knows about calling an idl
> procedure on unix command line as any other unix exe ?
>
> I mean gently passing the args via command line ?
>
> Thanks
> --
> richard Hitier

You need to declare *ip as short int in the C program because the
indgen() function
in IDL corresponds to 16 bit integers in C. Also to display the integer
array values,
you need "%d" rather than "%f" in the printf statement.

I also added a statement "*ip= -i" which sets the array values to their
negative on
return to IDL.

-----------------------------------------------------
int function(int argc, void *argv[])
{
int s=0;
short int *ip; /* indgen() in IDL corresponds to 16bit integer
in C */
int i;
for (i=0, ip=(short int*)argv[0]; i<*(int*)argv[1]; i++, ip++)
{
s+=*ip;
printf("i:%d ip:%d \n",i,*ip);
*ip = -i;
}
return(s);
}
-------------------------------------------------------


Joel Gales
SIMBIOS GSFC/NASA Code 970.2
Phone: (301) 286-1403
FAX: (301) 286-0268
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: procedure/function assigned to table widget cell?
Next Topic: xobjview -> export image

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

Current Time: Sun Oct 12 12:18:35 PDT 2025

Total time taken to generate the page: 1.44187 seconds