[futurebasic] Re: Memory question

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 1998 : Group Archive : Group : All Groups

From: Mark Goodes <wave@...>
Date: Sun, 5 Apr 1998 18:23:10 -0400
>Well I tried the first time to write OSErr=FN MemError(), but FB doesn't
>recognise this toolbox function. How can I check MEMERROR from FB ?

I hadn't realized this.  I tried to look up the format for an assembler
inline call to MEMERROR but there was something there that I didn't
understand.  Maybe the negative result for a pointer will work reliably.

>I thought I could build more generic functions that could
>deal with pointers and handles indifferently.

Now I see...maybe the quickest way to do this might be to have a FN
GetAddress like this:

Dim addr&
Local Fn GetAddress&(block&)
  LONG IF FN HGETSTATE(block&)>-1   ' it's a handle
    addr&=[block&]
  XELSE
    addr&=block&
  END IF
End fn=addr&

Then you could use the addr& in BLOCKMOVE statements.
The only problem would be that you wouldn't know whether a block was a
handle or not, so you might have to make a practice of always locking and
unlocking your blocks no matter what (I'm sure that it won't do any harm to
try to lock a pointer; you'll probably just get an error message back.)

Good luck.

____________
wave (Toronto, Canada)
Much better at "OOPS!" programming than OOP programming.