home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR36 / KEXX.ZIP / BROWSE.KEX < prev    next >
Text File  |  1992-12-29  |  3KB  |  107 lines

  1. ************************************************
  2. * BROWSE.KEX
  3. *
  4. * Function: Locate symbol definitions and references in your C source files
  5. * To run:   See BROWSE.DOC
  6. * Requires: KEDIT 5.0, RUNCMD.KEX, PUSH.KEX, POP.KEX, and Microsoft C 6.0+
  7. * version:  2.1 (December, 1992)
  8. *
  9. * Parameters:
  10. *  Switch  - Switch indicating what sort of lookup is desired.
  11. *    -b    - Backup one BROWSE level
  12. *    -d    - Look up definition(s) of symbol
  13. *    -r    - Look up reference(s) to symbol
  14. *  Symbol  - (Optional) symbol to look up. If absent, the symbol under the
  15. *            cursor is looked up if possible.
  16. *
  17. ************************************************
  18.  
  19. Parse Arg Switch Symbol
  20.  
  21. * Save some information in case we have to bail out due to an error
  22. OriginalFid = Fileid.1()
  23. C1 = Cursor.1()
  24. C2 = Cursor.2()
  25.  
  26. * Determine which keys are used to navigate amongst BROWSER locations
  27. Call ErrorCheck 'Editv Get BROWSE_NextKey BROWSE_PrevKey BROWSE_CurrKey'
  28.  
  29. If BROWSE_NextKey = '' Then BROWSE_NextKey = 'Plus'
  30. If BROWSE_PrevKey = '' Then BROWSE_PrevKey = 'Minus'
  31. If BROWSE_CurrKey = '' Then BROWSE_CurrKey = 'Star'
  32.  
  33. If Switch = '-b' Then Do
  34.    * Backup one BROWSER level
  35.    'Macro Pop BROWSE'
  36.    Level = RC
  37.    If Level <= 0 Then Call FatalErr 1 'No current BROWSE locations'
  38.    'Macro PrgLines br'Level
  39.    'Msg Number of browse levels is now' Level - 1
  40.    Return
  41. End
  42.  
  43. If Switch = '-r' Then Do
  44.    MessageText = "Reference to"
  45.    MessageType = "reference"
  46. End
  47. Else If Switch = '-d' Then Do
  48.    MessageText = "Definition of"
  49.    MessageType = "definition"
  50. End
  51. Else
  52.    Call FatalErr 1 "Invalid BROWSE argument: '"Switch"'"
  53.  
  54. * Get the name of the file with BROWSER info
  55. Call ErrorCheck 'Editv Get BrowseFile'
  56. If BrowseFile = '' Then Do
  57.    'NoMsg Dir *.bsc'
  58.    If RC \= 0 Then
  59.       Call FatalErr 1 "Unable to locate .BSC file"
  60.    If Size.1() \= 1 Then Do
  61.       'NoMsg QQuit'
  62.       Call FatalErr 1 "Multiple .BSC files found"
  63.    End
  64.    'Locate :1'
  65.    BrowseFile = DirFileid.1()
  66.    Call ErrorCheck 'Editv Put BrowseFile'
  67.    'QQuit'
  68.    Call ErrorCheck 'Kedit' OriginalFid
  69.    'Cursor Screen' C1 C2
  70. End
  71.  
  72. * If an argument wasn't supplied, use word under cursor as symbol
  73. If Symbol = '' Then Symbol = FieldWord.1()
  74.  
  75. * Save the current context for backup operations
  76. 'Macro Push BROWSE' BROWSE_NextKey BROWSE_PrevKey BROWSE_CurrKey
  77. BrowseCount = RC
  78.  
  79. * Let BROWSE.EXE and RUNCMD.KEX do all the "real work"
  80. 'Macro RunCmd /'MessageText Symbol'/ br'BrowseCount 'BROWSE.TMP' MessageType BROWSE_NextKey BROWSE_PrevKey BROWSE_CurrKey 'DOSQUIET Browse' Switch Symbol BrowseFile
  81. 'Msg Number of browse levels is now' BrowseCount
  82.  
  83. Return
  84.  
  85. ************************************************
  86. * Subroutine to bail out with error message in alert box
  87. *  Note: This subroutine never returns to it's caller
  88. ************************************************
  89. FatalErr:
  90.    Parse Arg ReturnCode ErrorMessage
  91.    'Alert' Delimit(ErrorMessage) 'Title $BROWSE$'
  92.    * Restore screen if possible
  93.    'Kedit' OriginalFid
  94.    'Cursor Screen' C1 C2
  95.    Exit ReturnCode
  96.  
  97. ************************************************
  98. * Execute command and check for zero return code
  99. *  If RC is not 0, then bail out with FatalErr
  100. ************************************************
  101. ErrorCheck:
  102.    Parse Arg CmdString
  103.    "NoMsg" CmdString
  104.    If RC \= 0 Then
  105.       Call FatalErr RC "From <"Word(CmdString, 1)">" LastMsg.1()
  106.    Return
  107.