Thanks to Brian and Paul. I got it to work. However I am curious how you knew this. The only reference to extern I find relates to libraries and that was in the Target Palm OS.pdf. I searched all the pdf documentation included with codewarrior and that was all there was. I put the extern Char *gJay in the header file and so didn't need to put it in each .c file. The string was just an example so I could go ahead and begin creating a database and remember the reference to the database after the function. If you are opening a database with the init function you would have to declare it global or it would lose scope after the function...but I don't see any examples of this being declared globally so was lost on how to do it.
How did you guys know the extern keyword would do this. You don't need it in C or C++ to create a global variable. Jay Thanks Brian, Do you mean I declared it correctly and in addition I need to put the code you suggested in each of the .c files? Jay >From Brian: In the other sources (not main.c): extern Char *gJay; >Creating a global variable: > >I tried to create a global variable and test to see the >scope of that variable >in a custom alert. So I created a variable called >gJay. > > >Char * gJay = "Jay"; > >When I put this code in the main.c file (the file that >has the MainFormInit function in it) >below the # includes >above the functions >right where it says Global Variables >right below where the preferences were declared > >no compile errors > > >When I put code in to read the value of that variable >gJay in another .c file within the project >(Information.c) >Then I get a compile error. I get an undefined >identifier error. It reads all other information from >this file correctly. > > >So I moved the declaration to the main header file. >When I attempt to compile I get a Link error. > >LengthWeight.c Global object gJay was already declared >in file Information.c >Utility.c Global object gJay was already declared in >file Information.c >Main.c Global object gJay was already declared in file >Information.c >Utility.c Global object gJay was already declared in >file Information.c >About.c Global object gJay was already declared in file >Information.c > >Information.c only attempts to use the variable. It is >declared in the header and used in the Information.c >file. > > >I know the project is seeing the variable as I have my >global variable colored light blue and when I type in >gJay it turns light blue. > >Any help would be appreciated. Jay -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
