Hard to figure out what you mean with no code postet. You must place the global variabel outside the sub, normally in the top of the code. You due not need to declare it as global, if it only accessed in the current mb file. If you use either a global or module (local global:) variabel make two function to accss it, like a set procedure and get function.
 
Dim _sMyVar As String
 
Sub Main
..
End Sub
 
Function GetMyVar() As String
    GetMyVar = _sMyVar
End Function
 
Sub SetMyVar(sMyVar As String)
    _sMyVar = sMyVar
End Sub
 
Accessing variables through "properties" makes the desing more clear. But passing variables around between function and subs are not a problem in MapBasic. You should start with a design where global and modular variables are not used. I seldom use the above method. My MapBasic is a bit rusty and did't compile it, but the designmethod should work.

HTH,

Jakob Lanstorp
Software Developer
Geographical Information & IT
 
COWI A/S
Odensevej 95
DK-5260 Odense S
Denmark
 
Tel       +45 6311 4900
Mob     +45 4020 7529
Fax      +45 6311 4949
E-mail 
[EMAIL PROTECTED]
http://www.cowi.dk/gis

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marko Cucnik
Sent: Monday, May 15, 2006 8:59 PM
To: [email protected]
Subject: [MI-L] Passing Variables

Hello,
 
I am having some issues passing a variable around in my code.  I have a simple string and symbol variable that i would like to pass to different subroutines which do not directly call the original SUB.  Making the variable global does not seem to help.
 
Any ideas?
 
Marko Cucnik
BCIT - Practicum Student
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to