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

Home » Public Forums » archive » Re: CALL_EXTERNAL and memory allocation
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 and memory allocation [message #29693 is a reply to message #29682] Sun, 10 March 2002 15:43 Go to previous messageGo to previous message
Michael Zingale is currently offline  Michael Zingale
Messages: 4
Registered: March 2002
Junior Member
I should also point out that I have an example of reading a string from
an HDF5 dataset into IDL via call_external at the bottom of the
following page:

http://www.ucolick.org/~zingale/io_tutorial/

in the file idl_hdf5.tar

Mike

Michael Zingale wrote:

> I typically do something like the following:
>
>
> in IDL:
>
> string = ' '
>
> ierr = call_external('lib.so', 'read_string', string)
>
>
> and in C:
>
> IDL_STRING* string = (IDL_STRING *) argv[0];
>
> then fill string.s with the string.
>
>
> To do an array of strings, it is a little more compilicated. If you do
>
> unklabels = strarr(num),
>
> you must initialize each string with a UNIQUE value, otherwise, IDL
> gives them the same memory address. I do something like this:
>
> unklabels = strarr(nvar)
>
> ; this is important -- each string must be initialized to a unique
> ; 'word', otherwise all the unklabels will share the same address in
> ; memory
> for i = 0, nvar-1 do begin
> unklabels[i] = string(i, format = '(i4)')
> endfor
>
> Then I can fill this in IDL w/o problems.
>
> Mike
>
>
>
>
>
>
> lyubo wrote:
>
>> I have to get back a string from C, and if I have a null string
>> defined in IDL and passed to C it won't work, because there
>> isn't any memory allocated to the string.
>>
>> In general, how can I allocate memory for a string in IDL?
>>
>> lyubo
>>
>>
>>
>>
>>
>>
>>
>
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Grayscale AND Binary Image
Next Topic: MODIS L1B - 250m

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

Current Time: Sat Oct 11 01:33:40 PDT 2025

Total time taken to generate the page: 0.08297 seconds