[futurebasic] Re: [FB] Passing Blocks of Data

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 1999 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Thu, 21 Oct 99 02:23:43 -0500
Mark, 

>I want to pass around a block of data between functions and I'm not sure
>a) exactly how to do it, and b) if it's the best way to do things.
>
>What I'm trying to do is:
>'dim a block big enough for the data
>DIM theData.8000
>
>'this function goes out and grabs the block of data
>'I can get this to work
>FN GetRecord(gFileH&,whichRec&,24,@theData)
Be sure the pointer you get goes into a long var.
  FN GetRecord(gFileH&,whichRec&,24,@theData&)
For starters, you might rename your variable to remind you that what it 
holds is a POINTER to the data block (i.e., its address), not the data 
itself.
  FN GetRecord(gFileH&,whichRec&,24,@DataPtr&)
>
>'here's where things break. I want to pass the block
>'of data to another function to work on it. I'm getting gibberish.
>numFields&=fn GetNumberMARCFields(gFileH&,theData)
Since you already have a pointer, you can pass it directly:
  numFields&=fn GetNumberMARCFields(gFileH&,DataPtr&)
>
>Here's how the above function looks:
>
>local fn GetNumberMARCFields(FIHndl&,@theData)
Here you have requested a pointer to the pointer. You don't want that. 
Try this.:
  local fn GetNumberMARCFields(FIHndl&,theDataPtr&)
>dim RecBase&,RecEntries&
>dim RecBase$
>
>
>RecBase$=pstr$(theData)
>RecBase$=mid$(RecBase$,12,5)
>RecBase&=VAL(RecBase$)
>RecEntries&=(RecBase&-25)/12
>
>end fn=RecEntries&
>
>I've played with just about every combination of @theData and theData that
>I can think of.
>
>I have several questions. Is what I'm trying to do even possible? If it is,
>is this the best way to do it? Should I copy everything into a handle and
>work with that instead? I'm working with a couple of thousand records, and
>I know from experience that creating handles, filling them, manipulating
>the data, then throwing them away takes a lot of time. I'd appreciate any
>ideas you may have. TIA.
Your method is as good as any if it does what you need. I would probably 
use handles, but if you have only 8000 bytes of data, your method should 
be fine. I'm not sure what your data format is, but if it's regular, be 
sure to take advantage of XREF.

 0"0
 =J= a  y
  "