IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: Shannara on December 22, 2006, 04:58:46 PM

Title: Global Classes possible?
Post by: Shannara on December 22, 2006, 04:58:46 PM
At first, I thought I could create a global class by doing the following:


Global myClass;
BaseClass myClass;


And after I create the bugger, I would be able to use it in any class and source file (via extern) in my project. Even though it compiles with no error, on execution, the whole program crashes. Are global classes allowed in Aurora (currently) ? Im thinking i'm trying something that isnt allowed or checked during compilation.
Title: Re: Global Classes possible?
Post by: Ionic Wind Support Team on December 22, 2006, 05:23:43 PM
Classes are global by default.  If you look at how I remade your project you can see that you only need the definition of the class, the linker figures out the rest.
Title: Re: Global Classes possible?
Post by: Shannara on December 22, 2006, 06:49:24 PM
hrm .... ok, so when I do something like frmMain : CWindow,

I should be able to type frmMain.OnClose() in any other class that references the include? That's what I am trying to do, globally access a class instance :)
Title: Re: Global Classes possible?
Post by: Ionic Wind Support Team on December 22, 2006, 07:39:01 PM
Now that is something different.  You shouldn't really call an OnXXX handler yourself.  If you want to close a window just call it's Destroy method.

If you are trying to access a specific instance of a class from another file then make a global pointer to that instance.

Paul.
Title: Re: Global Classes possible?
Post by: Shannara on December 24, 2006, 10:11:33 AM
Hmm, on top of source files, typing the following according to the manual:


global *fMainMenu;
mMainMenu *fMainMenu;


Even if I remove the 2nd line, the following error happens:


File: C:\Projects\Online RPG  Maker (Aurora)\Client\Main.src (8) syntax error - *
Error(s) in compiling "C:\Projects\Online RPG  Maker (Aurora)\Client\Main.src"



It doesnt seem to like the pointer symbol for some reason.
Title: Re: Global Classes possible?
Post by: Ionic Wind Support Team on December 24, 2006, 10:35:33 AM
The * tells it is a pointer variable.  It is not part of the variable name so nix it from the GLOBAL statement.

global fMainMenu;
mMainMenu *fMainMenu;

Title: Re: Global Classes possible?
Post by: Bruce Peaslee on December 24, 2006, 10:51:35 AM
Quote from: Paul Turley on December 22, 2006, 07:39:01 PM
You shouldn't really call an OnXXX handler yourself.ÂÃ, 

Is that true in general? I have been doing something like this:


MainWindow::OnMenuPick(int nID), int
{
ÂÃ,  ÂÃ, select nID
ÂÃ,  ÂÃ, {
ÂÃ,  ÂÃ,  ÂÃ,  case FILE_EXIT:
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  OnClose();
ÂÃ,  ÂÃ,  ÂÃ,  case HELP_ABOUT:
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, MessageBox(this,"Another great one.","About",0);
ÂÃ,  ÂÃ, }
}


In this way I can put all of my checking ("Do you really want to quit?") in one spot.
Title: Re: Global Classes possible?
Post by: Ionic Wind Support Team on December 24, 2006, 10:58:46 AM
That's fine.  It all depends on what the particular handler does.  I have run into problems in the past using MFC code where calling a handler generated another message, etc.