realbasic-nug
[Top] [All Lists]

Re: declare w/ strings and arrays

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>, Ken Mankoff <km2237 at columbia dot edu>
Subject: Re: declare w/ strings and arrays
From: Charles Yeomans <yeomans at desuetude dot com>
Date: Thu, 30 Sep 2004 15:16:00 -0400
Cc:
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <Pine dot OSX dot 4 dot 61 dot 0409301358360 dot 469 at modnar dot giss dot nasa dot gov> <C0368964-130F-11D9-B227-000A957CB4CC at desuetude dot com> <Pine dot OSX dot 4 dot 61 dot 0409301437190 dot 2606 at modnar dot giss dot nasa dot gov>

On Sep 30, 2004, at 2:44 PM, Ken Mankoff wrote:


On Thu, 30 Sep 2004, Charles Yeomans wrote:

First, the stringPtr work is unnecessary; you can pass an Rb String in the function, and somehow a CString will be what's actually fed to the function.
OK, that makes sense. Thanks.

It looks to me as if index is being passed inline; thus the declaration as Ptr will not work, for obvious reasons. If you're working on a Mac, then you might try the declaration (assuming size_t is a 4-byte thing)

declare function nc_get_var1_text lib library ( _
     ncid as integer, _
     varid as integer, _
     index1 as Integer, _
     index2 as Integer, _
     stringPtr as cstring ) _
     as integer

If you're working on an x86 machine, then you should get a Mac because passing structs inline from Rb to an external function doesn't appear to be possible for x86.

I am on a Mac.

But I am not sure I understand or can use your suggestion for the indexPtr. I don't know if its inline or not. Its actually an array of indices that is passed into my function. And whatever is obvious to you definately is not to me, other than that declares confuse me :/.

I looked at the documentation available on the web for NetCDF. If index is an array, then the correct declaration should be

declare function nc_get_var1_text lib library ( _
      ncid as integer, _
      varid as integer, _
      indexPtr as ptr, _
      stringPtr as cstring ) _
      as integer


You didn't say how the declare doesn't work; that would be useful to know.

Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>