home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / v / vsnbl220.zip / DEMO.SNO < prev    next >
Text File  |  1991-02-14  |  2KB  |  75 lines

  1.     &trim = 1
  2.     &trace = 10000
  3.     define('outfun()')
  4.     define('resfun(name)n1')
  5.     trace('output',"value",,'outfun')
  6.     trace('result',"value",,'resfun')
  7.     filename = "demo.txt"
  8.     &parm break(";") ";" rem . filename
  9.     input('in_',1,,filename)    :f(error)
  10.     var_pat = (any(&ucase &lcase) (break(" " char(9)) | rpos(0))) . var
  11.  
  12. * Here to start a new screen load.  Initialize line counter.
  13. next    lc = 0
  14. main    line = in_            :f(end)
  15.     line pos(0) any('*<>?&') . c = "" :s($('d' c))
  16.     output = line            :(main)
  17.  
  18. d>    line var_pat            :f(execute)
  19.     trace(var,"value",,'resfun')    :(exec2)
  20.  
  21. * Display line to be executed, then compile and execute it.
  22. execute
  23. d*    var = ""
  24. exec2    output = line
  25.     code = code(line '; :(exec3)')    :s<code>f(main)
  26. exec3    (differ(var) differ(var,"RESULT") stoptr(var))    :(main)
  27.  
  28. * Scroll previous output to top of screen, wait for user to type Enter.
  29. scroll
  30. d<    output = lt(lc,24)        :s(scroll)
  31.     output = "Press Enter (─┘) to continue, Control-C to terminate:" char(26)
  32.     output = ?input            :(next)
  33.  
  34. * Trace function to increment line counter on each assignment to output
  35. outfun    lc = lc + 1            :(return)
  36.  
  37. * Trace assignments to result variable.
  38. resfun    name pos(1) rem . n1 = replace(n1, &ucase, &lcase)    :f(error)
  39.     output = ident(datatype($name),"INTEGER") '(' name ' <-- ' $name ')'
  40.     output = ident(datatype($name),"STRING") '(' name ' <-- "' $name '")'
  41.     lc = lc + 1            :(return)
  42.  
  43. * Display line to be executed in CODE format.
  44. d?    output = '?' line
  45.     code = code(line '; :s(s1)f(f1)')    :s<code>f(main)
  46. s1    output = "Success"        :(main)
  47. f1    output = "Failure"        :(main)
  48.  
  49. * Here to tryout some statements interactively.
  50. d&    stoptr('output')
  51.     stoptr('result')
  52.     endfile(1)
  53.  
  54.     input('keyboard', 15, 255, 'CON:')
  55.     &errlimit = 1000
  56.     define('errfun_()')
  57.     trace('errtype','keyword',,'errfun_')
  58.  
  59. newlin  screen = '?' char(26)
  60.     inpt_  = keyboard            :f(end)
  61. *    Compile statement with Goto appended and execute it
  62.     code   = code(inpt_ ' :s(s) f(f)')    :s<code>
  63.     screen = 'Compilation error: ' &errtext ', reenter:' :(newlin)
  64.  
  65. s    output = 'Success'            :(newlin)
  66. f    output = 'Failure'            :(newlin)
  67.  
  68. errfun_    output = 'Execution error #' &errtype ', ' &errtext :(return)
  69.  
  70. * Here if cannot find the demo.txt filename.
  71. error    &CODE = 1
  72.  
  73. end
  74.  
  75.