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

  1. /* AB_GetTxt $VER 1.0 ©1995 Mads Lie Jensen
  2.  
  3.    Consider this as an external AREXX-funktion. If you just has the correct
  4.    AmigaBase-function named inhere, you don't have to worry about ADDRESS'ing
  5.    AmigaBase's AREXX-port.
  6.  
  7.    IMPORTANT!!
  8.       AmigaBase will be automatically loaded if it's not already in memory.
  9.       This is important to remember, if you have used the QUIT-command to
  10.       quit the last project, which closes AB, then calling this script will
  11.       load it again.
  12.  
  13.    Usage:
  14.       rv = "<Path and name of script"(<Parameters> [,<Function name>])
  15.  
  16.    Where:
  17.       <Path and name of script>, is the complete path and filename to the
  18.       script, put inside "". By doing it that way, you are sure that Arexx
  19.       will always find the script.
  20.  
  21.       <Parameters> are a string, which makes the parameters your function in
  22.       AmigaBase needs, OR it's one of the commands, in which case they'll
  23.       be executed. See below.
  24.  
  25.       <Function name> is the name of the function to call in your AmigaBase
  26.       project. This one is optional. If not specified, the default function
  27.       will be used. If <Parameters> are one of the Commands, this will have
  28.       no meaning.
  29.  
  30.  
  31.    The return-value from the script is whatever your AB-function returns,
  32.    unless you used the Commands. (See below.)
  33.  
  34.    Tip:
  35.       If you have functions in different projects, that returns the same sort
  36.       of information, call them the same, and then set the default function
  37.       in this script, to the function that you use most.
  38.  
  39.    BUT, this script supports commands! This means that you can get infor-
  40.    mation on the project in AmigaBase, or interact with it.
  41.    Commands have to be sent exactly as shown here. (Case sensitive!):
  42.    Commands returns 1 if they where succesfull, 0 if not, except where
  43.    said otherwise.
  44.  
  45.    %LOAD    You will, as said, be able to load a new project into AB, using
  46.             the normal AB filerequester.
  47.  
  48.    %NAME    This will return the name of the current AB-project. If the project
  49.             has not yet been saved, it will return an empty string.
  50.  
  51.    %SAVE    This will save your AB-project using it's current name. If the
  52.             project does not yet have a name, you will be presented for the
  53.             file-requester.
  54.  
  55.    %SAVEAS  This will present you for the Save-requester, where you can select
  56.             a new name to save your file under.
  57.  
  58.    %QUIT    This will quit the current AmigaBase-project. If it was the last
  59.             window, it will also quit the program. If your project has been
  60.             modified, and not saved, you will be asked if you want to save
  61.             your project before quiting, or if you want to cancel.
  62.             Returns 1 if the project was quittet, 0 if not. A value of -1
  63.             means that the last window was closed, and AmigaBase was quit too.
  64.  
  65.    %NEW     This will open a new Window, to hold a new project.
  66.  
  67.    %PROJECT This is always specified with a name of a project. Used if you
  68.             have more than one project open in AB at once, you can change
  69.             betwen them, by using %PROJECT <nameOfTheProject>.
  70.  
  71. */
  72.  
  73. /* The name of the default function to call in AB */
  74. AB_func = '_Getname'
  75.  
  76. OPTIONS RESULTS
  77. argline = arg(1)
  78.  
  79. /* If a string that could be a function in Amigabase is passed as arg 2
  80.    this is used as the function to call
  81. */
  82. IF LENGTH(arg(2)) > 0 & LEFT(ARG(2),1) = '_' THEN
  83.    AB_func = arg(2)
  84.  
  85. /* Check that this script is called as an external funktion */
  86. PARSE SOURCE Calltype .
  87.  
  88. /* If Amigabase is not loaded, then do it */
  89. IF ~(SHOW('P','REXX_AB1')) THEN DO
  90.    ADDRESS COMMAND
  91.    'run >NIL: AmigaBase:AmigaBase'
  92.    'WaitForPort REXX_AB1'
  93. END
  94.  
  95. /* Operate on AmigaBase */
  96. ADDRESS REXX_AB1
  97.  
  98. /* Check if it's a command issued. If not, call the function */
  99. RESULT = ''
  100. SELECT
  101.    WHEN argline = '%LOAD' THEN DO
  102.       LOAD
  103.       END
  104.  
  105.    WHEN argline = '%NAME' THEN DO
  106.       STATUS FILENAME
  107.       END
  108.  
  109.    WHEN argline = '%SAVE' THEN DO
  110.       SAVE
  111.       END
  112.  
  113.    WHEN argline = '%SAVEAS' THEN DO
  114.       SAVEAS
  115.       END
  116.  
  117.    WHEN argline = '%QUIT' THEN DO
  118.       QUIT
  119.       IF ~(SHOW('P','REXX_AB1')) THEN 
  120.          RESULT = -1
  121.       END
  122.  
  123.    WHEN argline = '%NEW' THEN DO
  124.       NEW
  125.       END
  126.  
  127.    WHEN LEFT(argline,8) = '%PROJECT' THEN DO
  128.       SUBSTR(argline,2)
  129.       END
  130.  
  131.    OTHERWISE DO
  132.       FUNCTION AB_func argline
  133.       END
  134.  
  135.    END
  136.  
  137.    IF Calltype = 'FUNCTION' THEN
  138.       RETURN RESULT
  139.    ELSE DO
  140.       SAY RESULT
  141.       RETURN 20
  142.       END
  143.  
  144.