home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / bazy / amigabase-stamps / arexx / emptyabserver.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-11  |  5KB  |  168 lines

  1. /* AmigaBase <-> FinalWriter © 1995 Mads Lie Jensen
  2.    VER$ 1.0 28.02.1995
  3.  
  4.    Use this script from inside FinalWriter
  5.  
  6.    Purpose:
  7.  
  8.       Used to retrieve some data from an AmigaBase Project, normally an
  9.       address, but it doesn't actually matter, which data you recieve.
  10.       The text retrieved is inserted into FinalWriter with the Font/Size/
  11.       Style set in this script. (You can change those if you want)
  12.  
  13.    Usage:
  14.  
  15.       You are asked for some text to pass to your AB-function. Here you
  16.       can specify a command, (See the 'ABserver'-script), or, as normally,
  17.       you enter some parameters to your AB-function. I normally gives
  18.       every address a number in my projects, so when I need an address,
  19.       I just type in the number, and my AB-function will return the complete
  20.       address. You could of course, also just use the name of the person,
  21.       who's address you need, or whatever you like.
  22.  
  23.       You need to have the script 'ABserver.rexx' in your REXX:-drawer.
  24.  
  25.       This script needs to get an empty string returned, if nothing was
  26.       found, matching the text you asked for. (If anything else is returned,
  27.       this will get inserted into your document.)
  28.  
  29.       The script also supports commands!
  30.       (See the ABserver-script)
  31. */
  32.  
  33. OPTIONS RESULTS
  34.  
  35. /* Get the filename of the Current Project of AmigaBase.
  36.    Used for the title of the Request-text window. This way you can always
  37.    see which project is currently in AB
  38. */
  39.  
  40. continue:
  41.  
  42. project = "REXX:ABserver.rexx"('%NAME')
  43.  
  44. IF project = '' THEN
  45.    project = '<Unnamed>'
  46. ELSE
  47.    project = GetFName(project)
  48.  
  49. /*--------------------------------------------------------------------
  50.    Insert code to get the arguments to pass to your procedure here   |
  51. ----------------------------------------------------------------------*/
  52.  
  53. /*----------------------------
  54.    End of code               |
  55. ------------------------------*/
  56.  
  57. /*-----------------------------------------------------------------------------
  58.    You also have to put code in the SELECT...WHEN-loop, if you want to handle |
  59.    the return-values from the commands. If you don't do that, you cannot see  |
  60.    if the command was succesfull or not.                                      |
  61. -----------------------------------------------------------------------------*/
  62.  
  63. /* Check if the user entered some of the commands. This is also checked
  64.    in the ABserver-script, but we also needs to know, if we want to display
  65.    the result of such a command.
  66. */
  67. SELECT
  68.    WHEN RESULT = '%LOAD' THEN DO
  69.       CALL "Rexx:ABserver"('%LOAD')
  70.  
  71.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */
  72.  
  73.       /* End */
  74.  
  75.       SIGNAL continue
  76.    END
  77.  
  78.    WHEN RESULT = '%NAME' THEN DO
  79.       RESULT = "Rexx:ABserver"('%NAME')
  80.  
  81.       /* Insert code to handle returned value here. RESULT is empty if the
  82.          project has not yet been saved, else contains the file + path-name */
  83.  
  84.       /* End */
  85.  
  86.       SIGNAL continue
  87.    END
  88.  
  89.    WHEN RESULT = '%SAVE' THEN DO
  90.       RESULT = "Rexx:ABserver"('%SAVE')
  91.  
  92.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */ 
  93.  
  94.       /* End */
  95.  
  96.       SIGNAL continue
  97.    END
  98.  
  99.    WHEN RESULT = '%SAVEAS' THEN DO
  100.       RESULT = "Rexx:ABserver"('%SAVEAS')
  101.  
  102.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */
  103.  
  104.       /* End */
  105.        
  106.       SIGNAL continue
  107.    END
  108.  
  109.    WHEN RESULT = '%QUIT' THEN DO
  110.       RESULT = "Rexx:ABserver"('%QUIT')
  111.  
  112.       /* Insert code to handle returned value here. 0 = No succes,
  113.          1 = Succes, -1 = Last project was quit, and AB closed down  */
  114.  
  115.       /* End */
  116.        
  117.       SIGNAL continue
  118.    END
  119.  
  120.    WHEN RESULT = '%NEW' THEN DO
  121.       RESULT = "Rexx:ABserver"('%NEW')
  122.  
  123.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */
  124.  
  125.       /* End */
  126.        
  127.       SIGNAL continue
  128.    END
  129.  
  130.    WHEN LEFT(RESULT,8) = '%PROJECT' THEN DO
  131.       RESULT = "Rexx:ABserver"(RESULT)
  132.  
  133.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */
  134.  
  135.       /* End */
  136.        
  137.       SIGNAL continue
  138.    END
  139.  
  140.    OTHERWISE
  141.  
  142. END
  143.  
  144. /* Retrieve the text from Amigabase */
  145. ret = "Rexx:ABserver"(RESULT)
  146.  
  147. /*-----------------------------------------------------------------------------
  148.    This is where you insert your commands. The returned text can be found
  149.    in the ret-variable.
  150. -----------------------------------------------------------------------------*/
  151.  
  152. /*-----------------------------------------------------------------------------
  153.    End of your commands
  154. -----------------------------------------------------------------------------*/
  155.  
  156. EXIT
  157.  
  158. GetFName: PROCEDURE
  159.  
  160. /* Extraxt the filename from a complete path */
  161.  
  162. pos = LASTPOS('/',arg(1))
  163. IF pos = 0 THEN
  164.    pos = LASTPOS(':',arg(1))
  165.  
  166. RETURN SUBSTR(arg(1),pos+1)
  167.  
  168.