IonicWind Software

IWBasic => General Questions => Topic started by: Bruce Peaslee on November 11, 2007, 09:54:32 AM

Title: Forward Declarations
Post by: Bruce Peaslee on November 11, 2007, 09:54:32 AM
I have been fooling around with EBasic as that's where most of the action is these days. It reminds me of the good old days of IBasic Pro. (Only better)

I do have one question, though. I would like to be able to put the handlers for windows and dialogs right after the window or dialog declarations to enhance readability of the code. When I try this I get compile errors because there are references to yet undeclared windows or routines.


Dialog d1
CreateDialog d1, ..., &d1_handler
...
Sub d1_handler
...
Window main
OpenWindow main, ..., &main_handler
...
Sub main_handler




Is there some way to "forward declare" (if that's the right term) to avoid this?

Title: Re: Forward Declarations
Post by: LarryMc on November 11, 2007, 10:01:46 AM
My only guess would be to put all your required declarations in an .inc file and put it at the top of your program.

Larry
Title: Re: Forward Declarations
Post by: Ionic Wind Support Team on November 11, 2007, 10:10:42 AM
There shouldn't be any problems with the handlers, I do that all the time.  In fact most of the examples have the variable, followed by the OPENWINDOW statement, followed by all of the subroutines.

Do you have anything more specific?

Title: Re: Forward Declarations
Post by: Bruce Peaslee on November 11, 2007, 10:20:21 AM
The current code is too big. Let me put together an example later today.
Title: Re: Forward Declarations
Post by: Bruce Peaslee on November 11, 2007, 12:00:09 PM
Here is what I was attempting:


Autodefine "off"

DIALOG d1
CREATEDIALOG d1,0,0,300,202,0x80C80080,wMain,"Test Dialog",&d1_handler

SUB d1_handler
   Return
ENDSUB

Window wMain
OpenWindow wMain, 0, 0, 900, 470, @MINBOX, null, "Test Window", &wMain_handler

WaitUntil wMain = 0
End

Sub wMain_Handler

   Select @Message
      Case @IDCLOSEWINDOW
         CloseWindow wMain
   EndSelect
EndSub
Title: Re: Forward Declarations
Post by: Ionic Wind Support Team on November 11, 2007, 12:08:36 PM
That's why DoModal and ShowDialog have an optional 'parent' parameter.   So you don't have to specify it in the CREATEDIALOG statement.

Paul.
Title: Re: Forward Declarations
Post by: Bruce Peaslee on November 11, 2007, 12:12:28 PM
That does it.

Thanks.