realbasic-nug
[Top] [All Lists]

Re: declare w/ strings and arrays

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: declare w/ strings and arrays
From: Ken Mankoff <km2237 at columbia dot edu>
Date: Thu, 30 Sep 2004 14:44:17 -0400 (EDT)
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>

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 :/.

The nc_get_var1_text function works on multi-dimensional text arrays. The array is specified by 'varid', and the user has to know what the dimensions of it are.

If its a 1D array, then the pass in an index with 1 element equal to X, the index into the 1D array they want.

If the array accessed by nc_get_var1_text is 4D, then they pass in an 'index' of lengh 4, where (w,x,y,z) specify what element they want returned from StrPtr.

Your comment suggest that if I want to support an array with up to 16 dimensions, I need to code this 16 times. Is this true?

Thanks,

   -k.

_______________________________________________
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>