home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a066 / 1.img / SYMTEST.PRG < prev    next >
Encoding:
Text File  |  1992-03-20  |  1.8 KB  |  60 lines

  1. /*
  2.     symtest.prg
  3.  
  4.     This is a test of the Symbol class.  It was designed more for testing
  5.     purposes than tutorial purposes, and does not do anything useful, but
  6.     does demonstrate some of the possibilities of the class.  For a slightly
  7.     more sane explanation of the Symbol class, please see the Norton Guide.
  8. */
  9.  
  10. function main()
  11.  
  12. // starting off slow...
  13. local oSym := Symbol():qout
  14. oSym:exec("Hi there!", "This is pretty neat, huh?")
  15. ? oSym:name
  16. oSym:exec(oSym:name)    // this is equivalent to the line above, in this case
  17.  
  18. // following allows nesting testing and parameter
  19. // integrity checking in the debugger
  20. oSym := Symbol():WhatFun
  21. ? oSym:name, "returned:", oSym:exec(99, 88, 77)
  22.  
  23. // finally, test the perform message (not very thoroughly)
  24. oSym := Symbol():name
  25.  
  26. // now, you get 10 points for figuring out what the following line will print!
  27. ? oSym:perform(oSym)
  28.  
  29. // following line prints .f., because the two objects are not the same, even
  30. // though they refer to the same symbol.  This is unfortunate, but difficult
  31. // to correct at this stage.
  32. ? oSym == Symbol():name
  33.  
  34. // the isEqual message allows comparison of Symbol objects
  35. ? oSym:isEqual(Symbol():name)
  36. ? oSym:isEqual(Symbol():notTheSame)
  37.  
  38. // execution of undefined names is ignored at present
  39. Symbol():notAFunction:exec()
  40.  
  41. Symbol():__quit:exec()
  42.  
  43. ? "execution never reaches this point..."
  44.  
  45. return nil
  46.  
  47. function WhatFun(p1, p2, p3)
  48.     local oSym := Symbol():BottomLevel
  49.     ? oSym:name, "returned:", oSym:exec(73)
  50.     // note use of Symbol:new message below
  51.     Symbol():new("Qout"):exec("WhatFun checking in...")
  52. return p1 + p2 + p3
  53.  
  54. function BottomLevel(p1)
  55.     // who needs the question mark?
  56.     Symbol():Qout:exec("Having fun in BottomLevel...")
  57. return p1 * 2
  58.  
  59. // eof symtest.prg
  60.