I looked at the samples but don't really understand what I would use them for?

Thanks

Now I am even more confusedts-soft wrote:http://en.wikipedia.org/wiki/Modular_programming
Code: Select all
; pretend Vehicle is the name of the module...
Global test.Vehicle
test::NewAuto(77)
test::NewBoat()
Code: Select all
ImportModule hisMath "libs\ts-soft\super-cool-math"
ImportModule myMath "libs\my-stuff\crappy-way-of-doing-things"
define his.hisMath
define my.myMath
;....
debug his:Py()
debug my:Py()
It's because a single colon denotes a statement separator.fsw wrote:Why do we have two colons?
Wouldn't one suffice?
Oh yeah, that's right - I never use it thougheesau wrote:It's because a single colon denotes a statement separator.fsw wrote:Why do we have two colons?
Wouldn't one suffice?
Code: Select all
DeclareModule ThingA
; This is the only procedure callable from the outside
Declare DoThingA(foo, bar)
EndDeclareModule
Module ThingA
; Here we can use simple names without fear of a name collision with another
; module. Without Modules, these would have to be called "ThingA_x" to separate
; them similar names in the ThingB code.
Global x = 1, y = 2
; This procedure is only visible in here, so again, we can use any name we want
; without a collision with other code
Procedure Calculate()
ProcedureReturn 42
EndProcedure
; this can be called from the outside
Procedure DoThingA(foo, bar)
x = Calculate() + y
Debug x
EndProcedure
EndModule
Code: Select all
DeclareModule ThingB
; visible from the outside
Declare DoThingB()
EndDeclareModule
Module ThingB
; here, the same names are used as in the ThingA module, but no problem.
; The global variable here is not the same as the one in ThingA.
Global y
Procedure Calculate()
ProcedureReturn 21
EndProcedure
Procedure DoThingB()
y = Calculate()
Debug y
EndProcedure
EndModule
Code: Select all
XIncludeFile "ThingA.pb"
XIncludeFile "ThingB.pb"
; open the needed modules
UseModule ThingA
UseModule ThingB
; somewhere in the main code, call the modules
; ...
DoThingA(1, 2)
;.. and later...
DoThingB()
Code: Select all
DeclareModule Common
; some shared constants
#SomeConstant = 1
#OtherConstant = 25
; some shared code
Declare ReadConfiguration()
EndDeclareModule
Module Common
; the shared procedure
Procedure ReadConfiguration()
EndProcedure
EndModule
Code: Select all
DeclareModule ThingA
; This is the only procedure callable from the outside
Declare DoThingA(foo, bar)
EndDeclareModule
Module ThingA
UseModule Common
Procedure DoThingA(foo, bar)
ReadConfiguration()
Debug #SomeConstant
EndProcedure
EndModule
Code: Select all
DeclareModule ThingB
Declare DoThingB()
EndDeclareModule
Module ThingB
UseModule Common
Procedure DoThingB()
ReadConfiguration()
; ...
EndProcedure
EndModule