[futurebasic] RE: [FB] Converting Pointers C=>FB

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

From: Chris.Young@...
Date: Wed, 7 Jul 1999 11:54:44 -0500
Robert,

I'd need to see the C source to say for sure, but sequence& is not a 
pointer... it is a handle. I would think you would need to dereference 
it via:

sequence& = [hndl&]

after first locking the handle. Unlock it at the end of the FN. That 
should clear up the problems (potential) in your other two functions, 
where you do a:

&x&, someLongValue&

These POKEs also expect a pointer. Currently, you are passing a handle 
to these functions.

hth

Chris

On Wednesday, July 07, 1999 10:55 AM, support 
[SMTP:support@...] wrote:
> In converting C to FB I'm not very solid on the difference
> between the two languages using pointers and handles.
> In the following functions, I get a bus error when
> FN BuildTuneSequence calls FN StuffNoteEvent. Stepping through
> reveals that the error occurs when the last line of FN StuffNoteEvent
> executes. Am I incrementing my pointer reference (sequence&) wrong?
> The value being inserted (f&) is 564338748
> 
> LOCAL FN BuildTuneSequence&
>   DIM x&,y&,hndl&,sequence&,err&,lp,hndlSize%
>   hndl&=0
>   hndl& = FN NEWHANDLE _clear(hndlSize%)
>   sequence& = hndl&
>   FN StuffRestEvent(sequence&,_kBeginningRestDuration)
>   sequence& = sequence& + 4
>   FN StuffNoteEvent(sequence&,1,72,100,_kNoteDuration)
>   sequence& = sequence& + 4
>   FN StuffRestEvent(sequence&,y&)
>   sequence& = sequence& + 4
>   &sequence&, &H60000000
> END FN = hndl&
> 
> CLEAR LOCAL MODE
> CLEAR LOCAL FN StuffRestEvent(x&, duration&)
>   &x&, _kRestEventType << _kEventTypeFieldPos OR duration& << 
_kRestEventDurationFieldPos
> END FN
> 
> CLEAR LOCAL MODE
> CLEAR LOCAL FN StuffNoteEvent(x&, instrument&, pitch&, noteVOL&, 
duration&)
>   DIM a&,b&,c&,d&,e&,f&
>   a& = _kNoteEventType << _kEventTypeFieldPos
>   b& = instrument& << _kEventInstrumentFieldPos
>   c& = (pitch& - _kNoteEventPitchOffset) << _kNoteEventPitchFieldPos
>   d& = (noteVOL& - _kNoteEventVolumeOffset) << 
_kNoteEventVolumeFieldPos
>   e& = duration& << _kNoteEventDurationFieldPos
>   f& = a& OR b& OR c& OR d& OR e&
>   &x&, f&        '*********** THIS LINE CRASHES  ****************
> END FN
> 
> 
> Dual is good, anyone for triple platform?
> Robert Price
> Programmer/Technical Support
> support@...
> 
> 
> 
> 
> --
> To unsubscribe, send ANY message to 
<futurebasic-unsubscribe@...>
>  << File: [FB] Converting Pointers C=_FB.TXT >>