Re: ASSOC and C [message #34552] |
Tue, 25 March 2003 14:06 |
Peter Mason
Messages: 145 Registered: June 1996
|
Senior Member |
|
|
Hi William,
(Relocating tongue cheekwise...) When working with an ASSOC'd variable in
IDL, you might as well be honest with yourself and use round brackets
instead of square ones. (That's because accessing an "element" of an
ASSOC'd variable is - for all intents and purposes - an IDL function call,
despite appearances.)
Now I've never tried to access an ASSOC'd variable within a C add-on
routine, but I suppose that it might be possible. In a DLM, not
CALL_EXTERNAL. Also, probably not with "EZCALL". (EZCALL is - I gather -
a way of simplifying the handling of passed parameters in your C routines.
I've never used it myself. I think that it blocks any ASSOC'd variables
from being passed, though.)
What you'd do is use the exported function IDL_ExecuteStr() to get IDL to
execute a command like "actual_data_var = assocd_var[1275]". Note that
this won't work with runtime IDL, only full IDL. Obviously, you'd
construct this command string on the C side with the desired index. You
will probably need a *named* IDL variable ("actual_data_var" in this
example) that's defined before the execute call. Like I said, I haven't
tried this myself. (I haven't even tried IDL_ExecuteStr().) I don't know
if it'll work.
An alternative is to use a real memory-mapped file instead of ASSOC().
Such an item looks and works exactly like a regular array, and you can have
your way with it in external C routines. If you're working on a Wintel
platform then you can use my "Stoneface" module for memory mapping. You
can get "Stoneface" from the RSI user contrib site. If you're using Unix
then you can try Eric Korpela's "Varray" module
(http://albert.ssl.berkeley.edu/~korpela/mmap/). It has been quite a while
since I checked on this and I don't know its current status. (An issue is
that IDL's internal structure for strings was changed in IDL5.5. If it
doesn't work on 5.5 then a simple recompilation with RSI's current
"exports.h" might fix it.)
Cheers
Peter Mason
"William M. Weibel" <wmweibel@yahoo.com> wrote in message
news:965fe337.0303241119.65314d3f@posting.google.com...
> Greetings everyone.
>
> I've been enjoying IDL's associated I/O feature for over a month now,
> and it is just fabulous. I often pass associated arrays to IDL
> procedures functions that can simply handle them like ordinary arrays.
> This is very handy when one is anticipating having to process large
> files.
>
> But, as with any addiction, once you start using ASSOC, you just want
> more. I'm writing system routines in C, and implementing them as
> DLM's. I would just L-O-V-E to pass file variables to my C functions,
> and then call something from the IDL API to access the data as if they
> were simple IDL arrays. Alas, I fear that this is just not possible.
>
> Can anyone suggest a solution, or dissuade me from this vain quest?
>
> Thanks
> William Weibel
> Space Computer Corp
|
|
|