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

Home » Public Forums » archive » CALL_EXTERNAL and IDL_STRING
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
CALL_EXTERNAL and IDL_STRING [message #22931] Fri, 22 December 2000 08:05 Go to next message
Frederique Soulard is currently offline  Frederique Soulard
Messages: 1
Registered: December 2000
Junior Member
We are trying to use the CALL_EXTERNAL function in order to get strings from
a C routine. The variables are defined as IDL_STRING and have to be
modifyable into the C routine. Our C routine reads strings from a binary
file into C string variables. Then we are trying to copy the C strings into
the IDL_STRING pointers (copy byte after byte). We encounter problems while
doing this (memory overlaping probably). Does someone has any advice to give
in order to solve our problems (no question to re-develop the reading in IDL
routine) ? Is a ByteArr method a solution ?
Thanks.
Re: CALL_EXTERNAL and IDL_STRING [message #23116 is a reply to message #22931] Thu, 04 January 2001 02:55 Go to previous message
Nigel Wade is currently offline  Nigel Wade
Messages: 286
Registered: March 1998
Senior Member
Mark Rivers wrote:
>
> Frederique Soulard wrote in message
> <91vttb$tpn$1@s1.read.news.oleane.net>...
>> We are trying to use the CALL_EXTERNAL function in order to get strings
> from
>> a C routine. The variables are defined as IDL_STRING and have to be
>> modifyable into the C routine. Our C routine reads strings from a binary
>> file into C string variables. Then we are trying to copy the C strings into
>> the IDL_STRING pointers (copy byte after byte). We encounter problems while
>> doing this (memory overlaping probably). Does someone has any advice to
> give
>> in order to solve our problems (no question to re-develop the reading in
> IDL
>> routine) ? Is a ByteArr method a solution ?
>
> Yes, I always use byte arrays for this. In IDL dimension your byte arrays
> so that the dimension
> which is the string length is greater than it will ever need to be in the C
> code. Have the C code
> fill in the byte array with trailing NULLs. On return to IDL convert to a
> string or string array using the string() function.
>
> Mark Rivers

Please pass the length of the IDL string to the C routine and make sure
you don't copy more than the string can hold. Todays huge string is
tomorrows
buffer overrun. I don't use CALL_EXTERNAL so I don't really know much
about it,
but if you have an IDL_STRING pointer can you use IDL_StrStore to put
your
string into the IDL variable?

The alternative would be to write a "system routine" (i.e. using
LINKIMAGE
or a DLM). System routines can create IDL variables of any type.

--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
Re: CALL_EXTERNAL and IDL_STRING [message #23119 is a reply to message #22931] Wed, 03 January 2001 21:00 Go to previous message
Mark Rivers is currently offline  Mark Rivers
Messages: 49
Registered: February 2000
Member
Frederique Soulard wrote in message
<91vttb$tpn$1@s1.read.news.oleane.net>...
> We are trying to use the CALL_EXTERNAL function in order to get strings
from
> a C routine. The variables are defined as IDL_STRING and have to be
> modifyable into the C routine. Our C routine reads strings from a binary
> file into C string variables. Then we are trying to copy the C strings into
> the IDL_STRING pointers (copy byte after byte). We encounter problems while
> doing this (memory overlaping probably). Does someone has any advice to
give
> in order to solve our problems (no question to re-develop the reading in
IDL
> routine) ? Is a ByteArr method a solution ?


Yes, I always use byte arrays for this. In IDL dimension your byte arrays
so that the dimension
which is the string length is greater than it will ever need to be in the C
code. Have the C code
fill in the byte array with trailing NULLs. On return to IDL convert to a
string or string array using the string() function.

Mark Rivers
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 5.3, Trouble with Laptop under Linux, using TrueColor
Next Topic: Re: I for Interactive Programming? (was: widget_control and group_leader)

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

Current Time: Wed Oct 08 14:00:21 PDT 2025

Total time taken to generate the page: 0.00759 seconds