[futurebasic] RE: [FB] code resource update

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

From: Chris.Young@...
Date: Wed, 2 Jun 1999 16:52:52 -0500
Robert,

In C, the array name is a pointer to the array. In your main, you are 
specifying a parameter which is a pointer to a long (i.e., the compiler 
does not know it is an array). When you execute your loop the second 
time, you probably generate a stack overflow.

Arrays aren't a strong area of mine in C <g>, but according to an ANSI 
C book that I am looking at, try redefining your main as:

pascal long main(long  NotesMain[]) //NotesMain is the array pointer

and see what happens.

hth

Chris Young

On Wednesday, June 02, 1999 4:25 PM, support 
[SMTP:support@...] wrote:
> All,
> 
> Following Chris Young's advice I switched my call to include the
> pascal statement, and as an extra measure decided to just go ahead and
> store the second variable into the array and eliminate the extra
> overhead and confusion of passing two parameters (Thanks, Chris) and
> return a value to determine that the proper values are being passed.
> 
> *** c-code ******************
> pascal long main(long  *NotesMain) //NotesMain is the array pointer
> {
>    long Notes;
>    SysBeep(30); // this tells me I made it this far
>    for (Notes = 0; Notes <= 30; Notes++)
>    {
>         //SysBeep(30);
>         gcrNoteRestDur[Notes] = NotesMain[Notes];
> 
>    }
>    SysBeep(30); // this tells me I made it this far
> ...
>    return gcrNoteRestDur[1];
> }
> ******************************
> 
> *** FB Code ******************
> CALL "DCOD", 1935 ,Returnvalue& , (@gNoteRestDur&(0))
> print Returnvalue&
> ******************************
> 
> Now, when I run this from FB it works fine and the print Returnvalue&
> line prints exactly what I sent in the second element of the array to
> the c-code and my routine plays exactly the quicktime notes that I
> sent to it. The problem comes when I build the application and run it.
> When the c-code is called I get the first sysbeep() followed by a Type
> 1 error dialog. If I uncomment the sysbeep() in the loop it will beep
> the first iteration and then I get the dialog for the type 1 error.
> Somehow the first assignment of array values causes this error. I have
> ensured that all the array slots are set to 0 in FB before I make the
> call.
> 
> Chris, any ideas?
> 
> 
> Robert Price
> Programmer/Technical Support
> support@...
> 
> 
> 
> 
> --
> To unsubscribe, send ANY message to 
<futurebasic-unsubscribe@...>
>  << File: [FB] code resource update.TXT >>