realbasic-nug
[Top] [All Lists]

declare w/ strings and arrays

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: declare w/ strings and arrays
From: Ken Mankoff <km2237 at columbia dot edu>
Date: Thu, 30 Sep 2004 14:05:50 -0400 (EDT)
Delivered-to: realbasic-nug at lists dot realsoftware dot com

I'm having trouble getting a declare statement working. Perhaps someone here can help me set this up.

Here is the C documentation I have:

The function nc_get_var1_text gets a single data value from a variable of an open netCDF dataset that is in data mode. Inputs are the netCDF ID, the variable ID, a multidimensional index that specifies which value to get, and the address of a location into which the data value will be read. The value is converted from the external data type of the variable, if necessary.

int nc_get_var1_text  (int ncid, int varid, const size_t index[], char *tp);

        ncid: NetCDF ID, from a previous call to nc_open or nc_create.

        varid: Variable ID.

        index[]: The index of the data value to be read. The indices
        are relative to 0, so for example, the first data value of a
        two-dimensional variable would have index (0,0). The elements
        of index must correspond to the variable's dimensions. Hence,
        if the variable is a record variable, the first index is the
        record number.

        tp Pointer to the location into which the data value is read.

Here is my RB code:

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

dim stringPtr as memoryBlock = newMemoryBlock(256) // max string length
dim indexPtr as MemoryBlock = newMemoryBlock(8)    // 2 array elements

// get the element at position (0,2)
indexPtr.long(0) = 0
indexPtr.long(4) = 2

dim err as integer
err = nc_get_var1_text( ncid, varid, indexPtr, stringPtr )
s = stringPtr.CString(0)
return err


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