Help me, BlitzPlus

Blitz3D Forums/Blitz3D Beginners Area/Help me, BlitzPlus

Kaisuo, it will be much easier for you if you rearrange your program to do something like this:

1) Create all your GUI stuff first
2) Write an Event loop that handles everything
3) Keep other stuff out of your loop if it doesn't have to do with handling events.

Right now, your event loop is only checking for two kinds of events -- CloseWindow and Menu events. You're then trying to handle all the other stuff after the event checks in the part marked "Program". This muddles up your code and is making it very difficult for you. For instance, in your menu handler, you check to see if the menu ID that was clicked on is 1. If it is, you set the flag "newfile" to true. Later on in your loop, you check to see if "newfile" is 1, and if it is, you make create a file called "temp.bm" and set "newfile" back to 0. Worse, this code gets checked every time any event happens (i.e. every time WaitEvent() catches any event). Why don't you just put the one line that calles the makefile function in the menu handler for case 1? That way it will only ever be called when that menu is chosen.

What will be easiest and neatest for you is to have your entire loop made up of JUST event handler stuff, i.e.:
While WaitEvent()
    Select EventID()
        Case thisevent
            do this
        Case thatevent
            do that in something else
        Case anotherevent
            call a function
    End Select
Wend

In other words, that loop, with all the appropriate functions and initialization code makes up your entire program. If you have it structured like this, it's very easy to fill in the blocks.

And remember, whenever the user clicks on a tab, WaitEvent will fail and EventID will be the GadgetAction event ($401). So then you just check for it there, and then inside of that you just check what tab was clicked, and then you can do whatever you want.

Welcome to the world of event-based programming. I'll send you some barebones BlitzPlus code via email.