home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / CXT212.ZIP / CXT_ME.CMD < prev    next >
OS/2 REXX Batch file  |  1993-07-03  |  12KB  |  326 lines

  1. ;*****************************************************************************
  2. ;
  3. ;   CXT_ME.CMD - MicroEMACS MACRO FUNCTIONS FOR
  4. ;
  5. ;       CSTN (TM) C STRUCTURE TREE NAVIGATOR
  6. ;       CFTN (TM) C FUNCTION TREE NAVIGATOR
  7. ;
  8. ;   Copyright (C) Juergen Mueller (J.M.) 1992-1993
  9. ;   All rights reserved.
  10. ;
  11. ;   You are expressly prohibited from selling this software in any form,
  12. ;   distributing it with another product, or removing this notice.
  13. ;
  14. ;   Limited permission is given to registered CXT users to modify this
  15. ;   file for their own personal use only. This file may not be used for any
  16. ;   purpose other than in conjunction with the CXT software package.
  17. ;
  18. ;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  19. ;   EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE
  20. ;   IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR
  21. ;   PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  22. ;   PROGRAM AND DOCUMENTATION IS WITH YOU.
  23. ;
  24. ;   written by: Juergen Mueller, Aldingerstrasse 22, D-70806 Kornwestheim,
  25. ;               Federal Republic of Germany (GER)
  26. ;
  27. ;   FILE       : CXT_ME.CMD
  28. ;   REVISION   : 26-Jun-1993
  29. ;                15:20:17
  30. ;
  31. ;*****************************************************************************
  32.  
  33. ;*****************************************************************************
  34. ;**** write initial message ****
  35. ;*****************************************************************************
  36. write-message "Loading CXT macro package"
  37.  
  38. ;*****************************************************************************
  39. ;**** macro package initialization section ****
  40. ;*****************************************************************************
  41. set %cxt_item ""                ; set internal variables
  42. set %cxt_file ""
  43. set %cxt_line ""
  44. set %cxtn_cmd ""
  45. set %char_set "_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  46.  
  47. set %cft_base &env "CFTNBASE"   ; get environment variables, if set
  48. !if &seq &len %cft_base 0
  49.   set %cft_base &env "CXTNBASE"
  50.  
  51.   !if &seq &len %cft_base 0
  52.     set %cft_base ""
  53.   !endif
  54. !endif
  55.  
  56. set %cst_base &env "CSTNBASE"   ; get environment variables, if set
  57. !if &seq &len %cst_base 0
  58.   set %cst_base &env "CXTNBASE"
  59.  
  60.   !if &seq &len %cst_base 0
  61.     set %cst_base ""
  62.   !endif
  63. !endif
  64.  
  65. ;*****************************************************************************
  66. ;**** definition of user macros ****
  67. ;*****************************************************************************
  68.  
  69. ;**** find function ****
  70. store-procedure cft
  71.         execute-procedure _extract_item         ; get tagged item
  72.         execute-procedure _cxt_cft
  73. !endm
  74.  
  75. ;**** find data type ****
  76. store-procedure cst
  77.         execute-procedure _extract_item         ; get tagged item
  78.         execute-procedure _cxt_cst
  79. !endm
  80.  
  81. ;**** find function ****
  82. store-procedure cftmark
  83.         execute-procedure _extract_marked_item  ; get marked item
  84.         execute-procedure _cxt_cft
  85. !endm
  86.  
  87. ;**** find function ****
  88. store-procedure cstmark
  89.         execute-procedure _extract_marked_item  ; get marked item
  90.         execute-procedure _cxt_cst
  91. !endm
  92.  
  93. ;**** find function ****
  94. store-procedure cftfind
  95.         set %cxt_item "CFT function name: "
  96.         set %cxt_item @%cxt_item                ; get user input
  97.         execute-procedure _cxt_cft
  98. !endm
  99.  
  100. ;**** find data type ****
  101. store-procedure cstfind
  102.         set %cxt_item "CST data type name: "
  103.         set %cxt_item @%cxt_item                ; get user input
  104.         execute-procedure _cxt_cst
  105. !endm
  106.  
  107. ;**** set CFT database name ****
  108. store-procedure cftbase
  109.         set %cft_base "CFT database name: "
  110.         set %cft_base @%cft_base                ; get user input
  111. !endm
  112.  
  113. ;**** set CST database name ****
  114. store-procedure cstbase
  115.         set %cst_base "CST database name: "
  116.         set %cst_base @%cst_base                ; get user input
  117. !endm 
  118.  
  119. ;**** set CFT and CST database name ****
  120. store-procedure cxtbase
  121.         set %cxt_base "CFT and CST database name: "
  122.         set %cxt_base @%cxt_base                ; get user input
  123.         set %cft_base %cxt_base
  124.         set %cst_base %cxt_base
  125. !endm 
  126.  
  127. ;**** CFT file list
  128. store-procedure cftfile
  129.         write-message "Extracting CFT filelist"
  130.  
  131.         !if ¬ &seq &len %cft_base 0
  132.           set %tmp &cat &cat "-f" %cft_base " "         ; database access path
  133.         !else
  134.           set %tmp "" 
  135.         !endif
  136.  
  137.         set %cxtn_cmd &cat "cftn -F " %tmp 
  138.         pipe-command %cxtn_cmd          ; perform database access, shell command
  139. !endm
  140.  
  141. ;**** CST file list
  142. store-procedure cstfile
  143.         write-message "Extracting CST filelist"
  144.  
  145.         !if ¬ &seq &len %cst_base 0
  146.           set %tmp &cat &cat "-f" %cst_base " "         ; database access path
  147.         !else
  148.           set %tmp "" 
  149.         !endif
  150.  
  151.         set %cxtn_cmd &cat "cstn -F " %tmp 
  152.         pipe-command %cxtn_cmd          ; perform database access, shell command
  153. !endm
  154.  
  155. ;*****************************************************************************
  156. ;**** internal macro execution functions ****
  157. ;*****************************************************************************
  158.  
  159. ;*****************************************************************************
  160. ;* CFT front-end *
  161. ;*****************************************************************************
  162. store-procedure _cxt_cft
  163.         !if &seq &len %cxt_item 0
  164.           write-message "No function selected"
  165.           !return
  166.         !endif
  167.  
  168.         write-message &cat "Searching for function: " %cxt_item
  169.  
  170.         !if ¬ &seq &len %cft_base 0
  171.           set %tmp &cat &cat "-f" %cft_base " "         ; database access path
  172.         !else
  173.           set %tmp "" 
  174.         !endif
  175.  
  176.         set %cxtn_cmd &cat &cat "cftn -b " %tmp %cxt_item
  177.         execute-procedure _cxt_search                   ; start search
  178. !endm
  179.  
  180. ;*****************************************************************************
  181. ;* CST front-end *
  182. ;*****************************************************************************
  183. store-procedure _cxt_cst
  184.         !if &seq &len %cxt_item 0
  185.           write-message "No data type selected"
  186.           !return
  187.         !endif
  188.  
  189.         write-message &cat "Searching for data type: " %cxt_item
  190.  
  191.         !if ¬ &seq &len %cst_base 0
  192.           set %tmp &cat &cat "-f" %cst_base " "         ; database access path
  193.         !else
  194.           set %tmp "" 
  195.         !endif
  196.  
  197.         set %cxtn_cmd &cat &cat "cstn -b " %tmp %cxt_item
  198.         execute-procedure _cxt_search                   ; start search
  199. !endm
  200.  
  201. ;*****************************************************************************
  202. ;* the database retrieval function *
  203. ;*****************************************************************************
  204. store-procedure _cxt_search
  205.         set %cxt_file ""                ; clear variables
  206.         set %cxt_line ""
  207.  
  208. !force  pipe-command %cxtn_cmd          ; perform database access, shell command
  209.         !if &seq $status FALSE
  210.           !return
  211.         !endif
  212.  
  213. !force  select-buffer command           ; get result buffer from pipe-command
  214.         !if &seq $status FALSE
  215.           !return
  216.         !endif
  217.  
  218. !force  beginning-of-file               ; go to file begin
  219.         !if &seq $status FALSE
  220.           !return
  221.         !endif
  222.  
  223.         set-mark                        ; extract target file name
  224.  
  225. !force  search-forward " "              ; search for first blank after file name
  226.         !if &seq $status FALSE
  227.           !return
  228.         !endif
  229.  
  230.         backward-character
  231.         copy-region
  232.         set %cxt_file $kill             ; store target file name
  233.         forward-character
  234.         set-mark                        ; extract target file line
  235.         end-of-line
  236.         copy-region
  237.         set %cxt_line $kill             ; store target file line
  238.  
  239. !force  delete-window                   ; delete command window
  240. !force  delete-buffer command           ; delete command buffer
  241. !force  next-buffer                     ; switch to next buffer just to hide command buf
  242.  
  243.         !if ¬ &exist %cxt_file       ; test if file exists
  244.           write-message &cat &cat "Target file ~"" %cxt_file "~" not found"
  245.           !return
  246.         !endif
  247.         
  248. !force  find-file %cxt_file             ; open target file
  249.  
  250.         !if &seq $status TRUE
  251. !force    goto-line %cxt_line           ; jump to target line
  252.  
  253.           !if &seq $status FALSE
  254.             clear-message-line
  255.             !return
  256.           !endif
  257.  
  258.           delete-other-windows          ; just for safety
  259.           redraw-display                ; center target line
  260.           clear-message-line
  261.         !endif
  262. !endm
  263.  
  264. ;*****************************************************************************
  265. ;* read search item from current buffer *
  266. ;*****************************************************************************
  267. store-procedure _extract_item
  268.         set %cxt_item ""                ; clear variable
  269.  
  270.         !if &seq &sindex %char_set &chr $curchar 0
  271.           !return                       ; not on a valid "C" character
  272.         !endif
  273.         
  274. !force  end-of-word
  275. !force  previous-word
  276.         set-mark                        ; mark first item character
  277. !force  end-of-word                     ; goto end of item
  278.         copy-region
  279.         set %cxt_item $kill             ; store item name
  280. !endm
  281.  
  282. ;*****************************************************************************
  283. ;* read marked search item *
  284. ;*****************************************************************************
  285. store-procedure _extract_marked_item
  286.         set %cxt_item ""                                ; clear variable
  287. !force  copy-region
  288.         set %cxt_item $kill                             ; store item name
  289.  
  290.         !if ¬ &seq &len %cxt_item 0
  291.           set %cxt_item &cat &cat "~"" %cxt_item "~""   ; quote
  292.         !endif
  293. !endm
  294.  
  295. ;*****************************************************************************
  296. ;* bind macros to WINDOWS menu, only if MicroEMACS for WINDOWS is present *
  297. ;*****************************************************************************
  298. !if &seq $sres "MSWIN"          ; test, if this is running under MS Windows
  299.   ; insert separator
  300.   bind-to-menu  nop     ">&Miscellaneous>-@5"
  301.  
  302.   ; create a new underlying pop-up menu for the CFT macros
  303.   macro-to-menu cft     ">&Miscellaneous>C&FT macros@6>CFT &function search@0"
  304.   macro-to-menu cftmark "CFT function search &mark"
  305.   macro-to-menu cftfind "CFT function search &prompt"
  306.   macro-to-menu cftfile "CFT file&list"
  307.   macro-to-menu cftbase "CFT data&base name"
  308.   macro-to-menu cxtbase "CFT and CST database &name"
  309.  
  310.   ; create a new underlying pop-up menu for the CST macros
  311.   macro-to-menu cst     ">&Miscellaneous>C&ST macros@7>CST &data type search@0"
  312.   macro-to-menu cstmark "CST data type search &mark"
  313.   macro-to-menu cstfind "CST data type search &prompt"
  314.   macro-to-menu cstfile "CST file&list"
  315.   macro-to-menu cstbase "CST data&base name"
  316.   macro-to-menu cxtbase "CFT and CST database &name"
  317. !endif
  318.  
  319. ;*****************************************************************************
  320. ;**** write final message ****
  321. ;*****************************************************************************
  322. write-message "CXT macro package loaded"
  323.  
  324. ;**** THIS IS THE END THIS IS THE END THIS IS THE END THIS IS THE END ****
  325.  
  326.