home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / lpexmac.zip / loadfile.lx < prev    next >
Text File  |  1998-09-05  |  4KB  |  98 lines

  1. /* english text follows below */
  2.  
  3. /* Datei: loadfile.lx
  4.    Zweck: Macro zum laden einer anderen Datei in ein neues Editorfenster.
  5.    Erstellt: 03.08.98
  6.    Autor: Jens Fettkenheuer (Clearwater Software & System Service GmbH)
  7.  
  8.    Erläuterungen:
  9.    Diese Datei muss sich entweder im Verzeichnis X:\IBMCPP\MACROS oder
  10.    in einem Verzeichnis das in der Umgebungsvariablen "LPATH" aufgeführt
  11.    ist, befinden.
  12.    Um das Macro zu aktivieren, muss in die Datei PROFILE.LX die Zeile:
  13.  
  14.                        'SET ACTION.C-F2 MACRO LOADFILE'
  15.  
  16.    eingefügt werden. Diese sorgt dafür, daß durch drücken der Tastenkombination:
  17.                        CTRL+F2    bzw. Strg+F2
  18.    das Macro gestartet wird.
  19.    Voraussetzung für das Laden einer Datei ist
  20.    entweder:
  21.      der Cursor befindet sich in einer Zeile die mit dem #include- Statement beginnt
  22.    oder
  23.      der Dateiname wird als Textblock im Editorfenster markiert
  24.    Es können nur Dateien geladen werden die sich entweder im aktuellen Path der Editor-
  25.    Session befinden oder in einem der Pfade die in der Umgebungsvariablen "INCLUDE" auf-
  26.    geführt sind.
  27.  
  28.    Ich habe festgestellt, daß neue Macros erst nach einem Reboot (OS/2) aktiv werden.
  29.  */
  30.  
  31. /* File: loadfile.lx
  32.    Purpose: macro to load an other file into a new editor window
  33.    Created: 03.08.98
  34.    Author: Jens Fettkenheuer (Clearwater Software & System Service GmbH)
  35.  
  36.    Explanations:
  37.    This file must be stored either into the directory X:\IBMCPP\MACROS or in a
  38.    directory stated in the environment variable "LPATH".
  39.    To activate the macro the following line must be inserted into the file
  40.    PROFILE.LX
  41.                        'SET ACTION.C-F2 MACRO LOADFILE'
  42.  
  43.    These line activates the keys
  44.                        Ctrl+F2
  45.    to start the macro.
  46.    Precondition to load a file is
  47.    either:
  48.      the cursor must be located in a line beginning with the #include- statement
  49.    or:
  50.      the file name must be marked as a block of text inside the current editor session.
  51.    Only files located either in the current directory of the current editor session or
  52.    located in one of the directories statet in the "INCLUDE" environment variable can
  53.    be found and therefore loaded via this macro.
  54.  
  55.    i found that new macros become active after a reboot only
  56. */
  57.  
  58. call RxFuncAdd 'SysSearchPath', 'RexxUtil', 'SysSearchPath'
  59.  
  60. 'extract content into lCurrentLine'
  61. lIncludeString= subword(lCurrentLine, 1, 1)
  62. lFileName= ""
  63. if (lIncludeString = "#include") then
  64.   do
  65.     lFileName= subword(lCurrentLine, 2, 1)
  66.     lFileName= strip(lFileName, 'L', '<')
  67.     lFileName= strip(lFileName, 'T', '>')
  68.     lFileName= strip(lFileName, 'B', '"')
  69.   end
  70. else
  71.   do
  72.     'extract blockstart into lBlockStart'
  73.     'extract blocklength into lBlockLength'
  74.     if (lBlockStart > 0) & (lBlockLength > 0) then
  75.       lFileName= substr(lCurrentLine, lBlockStart, lBlockLength)
  76.     else
  77.       do
  78.         alarm
  79.         say "move cursor to line starting with #include statement or mark the filename to load as block of text"
  80.         exit
  81.       end
  82.   end
  83. if (length(lFileName) > 0) then
  84.   do
  85.     lFoundFile= SysSearchPath('INCLUDE', lFileName)
  86.     if (lFoundFile = "") then
  87.       do
  88.         'alarm'
  89.         say 'the file --> ' lFileName' <-- could not be found (must be either in the current directory or in the INCLUDE path)'
  90.       end
  91.     else
  92.       do
  93.         say 'file ' lFoundFile ' successfully loaded'
  94.         'lx' lFoundFile
  95.       end
  96.   end
  97.  
  98.