home *** CD-ROM | disk | FTP | other *** search
- /*
- symtest.prg
-
- This is a test of the Symbol class. It was designed more for testing
- purposes than tutorial purposes, and does not do anything useful, but
- does demonstrate some of the possibilities of the class. For a slightly
- more sane explanation of the Symbol class, please see the Norton Guide.
- */
-
- function main()
-
- // starting off slow...
- local oSym := Symbol():qout
- oSym:exec("Hi there!", "This is pretty neat, huh?")
- ? oSym:name
- oSym:exec(oSym:name) // this is equivalent to the line above, in this case
-
- // following allows nesting testing and parameter
- // integrity checking in the debugger
- oSym := Symbol():WhatFun
- ? oSym:name, "returned:", oSym:exec(99, 88, 77)
-
- // finally, test the perform message (not very thoroughly)
- oSym := Symbol():name
-
- // now, you get 10 points for figuring out what the following line will print!
- ? oSym:perform(oSym)
-
- // following line prints .f., because the two objects are not the same, even
- // though they refer to the same symbol. This is unfortunate, but difficult
- // to correct at this stage.
- ? oSym == Symbol():name
-
- // the isEqual message allows comparison of Symbol objects
- ? oSym:isEqual(Symbol():name)
- ? oSym:isEqual(Symbol():notTheSame)
-
- // execution of undefined names is ignored at present
- Symbol():notAFunction:exec()
-
- Symbol():__quit:exec()
-
- ? "execution never reaches this point..."
-
- return nil
-
- function WhatFun(p1, p2, p3)
- local oSym := Symbol():BottomLevel
- ? oSym:name, "returned:", oSym:exec(73)
- // note use of Symbol:new message below
- Symbol():new("Qout"):exec("WhatFun checking in...")
- return p1 + p2 + p3
-
- function BottomLevel(p1)
- // who needs the question mark?
- Symbol():Qout:exec("Having fun in BottomLevel...")
- return p1 * 2
-
- // eof symtest.prg
-