Nov 89 Mousehole
Volume Number: 5
Issue Number: 11
Column Tag: Mousehole Report
Mousehole Report 
By Rusty Hodge & Larry Nedry, Mousehole BBS
From: Tomt
Re: global variables
This is probably a dumb question but is there a way in LSP 2.0 to create global
variables that are accessible by multiple units? As an old Fortran person I’d really
like the equivalent of a common statement to give global scope to a variable, I’d even
settle for something likes C’s extern statement. Thanks for any help. By the way I’d
like this to work independently of the build order.
From: Siegel
Re: global variables
Declare any public globals in the interface-part of a UNIT, and any other UNITs that
want that global should USE the UNIT where the global is declared.
From: Jmoreno
Re: global variables
The best way to create global variable that are accessible by multiple units AND
independent of the build order is to create a unit with just global declarations and have
it first in the build and have all of your units use it. Something like this
Unit MyGlobals;
INTERFACE
CONST
MyConst = 32;
TYPE
MYTPE = INTEGER;
VAR
MyGlobalVar: INTEGER;
SecndGlob:Str255;
IMPLEMENTATION
{ I don’t need no stinkin implementation}
END.
From: Macww
Re: global variables
Someone else has probably replied by now, but here goes. It is very common for a
Pascal program to have a separate unit, consisting of an interface section only,
declaring all global constants, variables, types, etc. Put it first in the build order, but
the order of subsequent units will not matter vis a vis the Globals unit.
From: Jmoreno
Re: Dispatch Table
I’m trying to gain some experience with C by translating a program I have from Pascal
to C. I don’t want to do a line by line translation, and I noticed that I could handle menu
events using a dispatch table to functions instead of a bunch of switch statements. My
problem is that I can not get the dispatch table to compile under Think C 3.0. Could
somebody please post an example of one?
From: Noisy
Re: Dispatch Table
One way to code a dispatch table in C is to create an array of pointers to functions. That
way you can provide your own indexing techniques and bypass multiple depths of
switch() statements. This does have some limitations though: since all the calls are