Re: CALL_EXTERNAL puzzle (still) ? [message #12761 is a reply to message #12752] |
Fri, 04 September 1998 00:00  |
rmlongfield
Messages: 68 Registered: August 1998
|
Member |
|
|
Hi all,
In article <6smfdj$iqk$1@readme.uio.no>,
steinhh@ulrik.uio.no (Stein Vidar Hagfors Haugan) wrote:
>
> rmlongfield@my-dejanews.com wrote:
>
>> print,'de-referenced pointer: ',*filename
>> result = CALL_EXTERNAL(VALUE=[1B],'example_c.so','example_c', filename)
>
> Whooa - here you're sending a *pointer* to a *string* variable
> into the call_external routine - and it's definitely *not* set
> up to receive it! In fact, your routine would *only* work if
> you sent it a scalar string that is passed by *value* only.
> (E.g. a string literal)
Thanks for your comments, but ... after some additional testing, I still
maintain that something is not clear about CALL_EXTERNAL. Firstly,
regardless of the unconventional setup of my program, it *worked*. What
bothered me was that I didn't understand why (i.e. it worked for reasons that
would not be clear if one reads the code).
When I first started working with the strings, I couldn't get the value
passed. Now it seems to work, see result_b below :).
However, why can't I pass a pointer? And if I want to pass a pointer, and
print the value of another pointer just before the CALL_EXTERNAL, why is the
wrong one passed? (See result_a). Ok, I'm neither a UNIX nor C expert (I'd
like to say I'm an experienced user) and working with CALL_EXTERNAL was the
first time I had to deal with argc and argv, and strings seemed to be a
particular problem...Someone tells me that maybe the stdio and stdin are
connected for CALL_EXTERNAL... I use PRINT statements all the time to guide
my way through the operation of my code. I am also rather fond of the use of
pointers. Any further comments?
Nevertheless, the filename, chosen with an IDL widget, is passed to my C
programs, as was my intent. I've gotten rid of the pointer part.
Rose
;;;; IDL CODE ;;;;;;;;;;;;;; See previous post for C code;;;;;;;;;;;;
PRO example_idl
day1 = '961081302'
day2 = '999999999'
filename1=(PTR_NEW(STRTRIM(STRING(day1),2)))
filename2=(PTR_NEW(STRTRIM(STRING(day2),2)))
print,'de-referenced pointer: ',*filename1
result_a = CALL_EXTERNAL(VALUE=[1B],'example_c.so','example_c', filename2)
print,'de-referenced pointer: ',*filename1
; This works !!!!!!!!!!!!!
result_b = CALL_EXTERNAL(VALUE=[1B],'example_c.so','example_c', day2)
end
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
|
|
|