home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR36 / KEXX.ZIP / PUSH.KEX < prev    next >
Text File  |  1992-06-23  |  3KB  |  82 lines

  1. ************************************************
  2. * PUSH.KEX
  3. *
  4. * Function: Implement the PUSH function for a simple KEDIT context stack
  5. * To run:   See PUSHPOP.DOC
  6. * Requires: KEDIT 5.0
  7. * Version:  1.0 (June, 1992)
  8. *
  9. * Parameters:
  10. *  Name    - Name of the entry being pushed onto the stack
  11. *  Keydefs - List of the KEDIT Keynames to save definitions for
  12. *
  13. ************************************************
  14.  
  15. Parse Arg Name Keydefs
  16. Name = Upper(Name)
  17.  
  18. If Name = "" Then Name = "DEFAULT"
  19.  
  20. * Get the size of the existing stack
  21. 'NoMsg Editv Get StackSize'
  22.  
  23. * If there is no existing stack, initialize one
  24. If \DataType(StackSize, "N") | StackSize = 0 Then StackSize = 0
  25.  
  26. * Create index to new entry
  27. StackSize = StackSize + 1
  28.  
  29. * Save current place in file
  30. 'SOS Save'; 'Cursor CmdLine'
  31. Call ErrorCheck "Point .stack"StackSize
  32. 'SOS Restore'
  33.  
  34. * Save context name, current fileid, current cursor position and ...
  35. *  ... the names of the keydefs being tracked
  36. Call ErrorCheck "Editv SetL StackFID."StackSize Fileid.1() Cursor.1() Cursor.2()
  37. Call ErrorCheck "Editv SetL StackName."StackSize Name
  38. Call ErrorCheck "Editv SetL StackKeys."StackSize Keydefs
  39.  
  40. Call ErrorCheck 'Editv Get StackEntries.'Name
  41. Entries = StackEntries.Name
  42. If \DataType(Entries, 'n')
  43.    Then Entries = 1
  44.    Else Entries = Entries + 1
  45.  
  46. * Save individual keydefs
  47. Do While Keydefs \= ""
  48.  
  49.    Parse Var Keydefs NextKey Keydefs
  50.    * Lowercase to circumvent a bug handling case in Editv variable tails
  51.    NextKey = Translate(NextKey, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  52.    "NoMsg Define" NextKey
  53.    Call ErrorCheck "Editv SetL StackKey."StackSize"."NextKey LastMsg.1()
  54.  
  55. End
  56.  
  57. * Reflect new entry on stack
  58. Call ErrorCheck "Editv Put StackSize"
  59. Call ErrorCheck 'Editv Set StackEntries.'Name Entries
  60.  
  61. Return Entries
  62.  
  63. ************************************************
  64. * Subroutine to bail out with error message in alert box
  65. *  Note: This subroutine never returns to it's caller
  66. ************************************************
  67. FatalErr:
  68.    Parse Arg ReturnCode ErrorMessage
  69.    'Alert' Delimit(ErrorMessage) 'Title $PUSH$'
  70.    Exit ReturnCode
  71.  
  72. ************************************************
  73. * Execute command and check for zero return code
  74. *  If RC is not 0, then bail out with FatalErr
  75. ************************************************
  76. ErrorCheck:
  77.    Parse Arg CmdString
  78.    "NoMsg" CmdString
  79.    If RC \= 0 Then
  80.       Call FatalErr RC LastMsg.1()
  81.    Return
  82.