home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 5 / CD_Magazyn_EXEC_nr_5.iso / Programy / Programowanie / FetchRefs2.1.lha / FetchRefs2.1 / Scripts / ReqFetchRefs.Amitex < prev   
Encoding:
Text File  |  2001-01-28  |  2.8 KB  |  101 lines

  1. /* This script opens the FetchRefs requester for any reference
  2.  * $VER: ReqFetchRefs 1.00 (© R.Florac, 27/01/01) */
  3.  
  4. signal on syntax
  5.  
  6. editorname = 'AMITEX'
  7.  
  8. OPTIONS RESULTS
  9.  
  10. caller = ADDRESS()
  11. if (left(caller, length(editorname)) ~= editorname) then
  12.     exit 10
  13.  
  14. /* Get the function name from editor (get current word). */
  15. 'BLOCK(1)'          /* lecture numéro de ligne début de bloc */
  16. ld = result
  17. if ld<=0 then do
  18.     'WORD(0)'
  19.     function = result
  20. end
  21. else do
  22.     'BLOCK(3)'          /* lecture numéro de ligne de fin */
  23.     lf = result
  24.     if ld ~= lf then do
  25.     'MESSAGE("Sélection incorrecte")'
  26.     exit
  27.     end
  28.     'TEXTMARK(-1)'      /* lecture du bloc marqué */
  29.     function = result
  30. end
  31.  
  32. if function="" then do
  33.     function = getclip(fetchref)
  34.     'ASKTEXT("Fonction à chercher ?", "'function'")'
  35.     function = result
  36. end
  37. if function="" then exit
  38. a = setclip(fetchref,function)
  39.  
  40. /* Définition d'un fichier temporaire pour charger la référence */
  41. cutat = VERIFY(function, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_")
  42. if cutat > 0 THEN
  43.     basename = LEFT(function, cutat - 1)
  44. ELSE
  45.     basename = function
  46.  
  47. filename = 'T:FR_'basename
  48.  
  49. /* It doesn''t matter whether we want a taglist, varargs og whatever function */
  50. IF RIGHT(function, 7) = "TagList" THEN
  51.     function = LEFT(function, LENGTH(function) - 7)
  52. ELSE IF RIGHT(function, 4) = "Tags" THEN
  53.     function = LEFT(function, LENGTH(function) - 4)
  54. ELSE IF RIGHT(function, 1) = "A" THEN
  55.     function = LEFT(function, LENGTH(function) - 1)
  56.  
  57. /* Now actually get the reference */
  58. address command
  59. if ~show(p, "FETCHREFS") then do
  60.     'run > nil:' "Prog:docs/FetchRefs/FetchRefs Prog:docs/FetchRefs/FetchRefs.index"
  61.     waitforport "FETCHREFS"
  62. end
  63.  
  64. ADDRESS 'FETCHREFS'
  65. FR_REQ function || '(%|Tags|TagList|A)' filename CASE FILEREF
  66. gotoline = rc2
  67. resultat = rc
  68.  
  69. /* Address editor again to load the file */
  70. address value caller
  71. if resultat~=0 then do
  72.     /* Skip if the error was '...!' (actually 'Aborted!'). This occours
  73.      * whenever the 'select from what file' window is closed, which is
  74.      * not really an error.
  75.      */
  76.     if right(rc2, 1) ~='!' then
  77.         /* Reporte l'erreur (passée par FetchRefs) */
  78.         'MESSAGE("Recherche 'function'"+CHR(10)+"'RC2'")'
  79. end
  80. else do
  81.     /* Make the editor open a new window and load the autodoc into it. */
  82.     'OPEN("'filename'")'
  83.  
  84.     /* If FetchRefs provided us with a goto line (it does for .h files
  85.      * only - as it only makes sense for them) then we jump to that line.
  86.      */
  87.     if gotoline ~= 0 then
  88.         'GOTO(1,'gotoline')'
  89.  
  90.     /* Delete the autodoc file */
  91.     ADDRESS COMMAND 'C:Delete >NIL:' filename
  92. end
  93. exit
  94.  
  95. /* Traitement des erreurs, interruption du programme */
  96. syntax:
  97. erreur=RC
  98. 'MESSAGE("Script GetFileref.Amitex"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  99. address command
  100. exit
  101.