home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / bazy / amigabase-stamps / arexx / callab.fw < prev    next >
Text File  |  1995-03-11  |  7KB  |  240 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.       It's developed for inserting addresses into documents.
  13.  
  14.    Usage:
  15.  
  16.       You are asked for some text to pass to your AB-function. Here you
  17.       can specify a command, (See the 'ABserver'-script), or, as normally,
  18.       you enter some parameters to your AB-function. I normally gives
  19.       every address a number in my projects, so when I need an address,
  20.       I just type in the number, and my AB-function will return the complete
  21.       address. You could of course, also just use the name of the person,
  22.       who's address you need, or whatever you like.
  23.  
  24.       You need to have the script 'ABserver.rexx' in your REXX:-drawer.
  25.  
  26.       This script needs to get an empty string returned, if nothing was
  27.       found, matching the text you asked for. (If anything else is returned,
  28.       this will get inserted into your document.)
  29.  
  30.       The script also supports commands!
  31.       (See the ABserver-script)
  32.  
  33.       IMPORTANT!!
  34.          This script uses the default AB-function, defined in AB-server!!
  35. */
  36.  
  37. OPTIONS RESULTS
  38.  
  39. /* Get the filename of the Current Project of AmigaBase.
  40.    Used for the title of the Request-text window. This way you can always
  41.    see which project is currently in AB
  42. */
  43.  
  44. continue:
  45.  
  46. project = "REXX:ABserver.rexx"('%NAME')
  47.  
  48. IF project = '' THEN
  49.    project = '<Unnamed>'
  50. ELSE
  51.    project = GetFName(project)
  52.  
  53. /*--------------------------------------------------------------------
  54.    Insert code to get the arguments to pass to your procedure here   |
  55. ----------------------------------------------------------------------*/
  56.  
  57. ScreenToFront
  58.  
  59. RESULT = ''
  60. RequestText project '"Get matching text"'
  61.  
  62. /* If nothing entered or Cancel is pressed */
  63. IF RESULT = '' THEN
  64.    EXIT
  65. ELSE
  66.    which = RESULT
  67.  
  68. /*----------------------------
  69.    End of code               |
  70. ------------------------------*/
  71.  
  72. /*-----------------------------------------------------------------------------
  73.    You also have to put code in the SELECT...WHEN-loop, if you want to handle |
  74.    the return-values from the commands. If you don't do that, you cannot see  |
  75.    if the command was succesfull or not.                                      |
  76. -----------------------------------------------------------------------------*/
  77.  
  78. /* Check if the user entered some of the commands. This is also checked
  79.    in the ABserver-script, but we also needs to know, if we want to display
  80.    the result of such a command.
  81. */
  82. SELECT
  83.    WHEN RESULT = '%LOAD' THEN DO
  84.       CALL "Rexx:ABserver"('%LOAD')
  85.  
  86.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */
  87.  
  88.       /* End */
  89.  
  90.       SIGNAL continue
  91.    END
  92.  
  93.    WHEN RESULT = '%NAME' THEN DO
  94.       RESULT = "Rexx:ABserver"('%NAME')
  95.  
  96.       /* Insert code to handle returned value here. RESULT is empty if the
  97.          project has not yet been saved, else contains the file + path-name */
  98.  
  99.       IF RESULT = '' THEN
  100.          ShowMessage 1 1 '"Current project of AmigaBase" "has not been given" "a name yet." "Ok" "" ""'
  101.       ELSE
  102.          ShowMessage 1 0 '"Current project of AmigaBase is:"' RESULT '"" "Ok" "" ""'
  103.  
  104.       /* End */
  105.  
  106.       SIGNAL continue
  107.    END
  108.  
  109.    WHEN RESULT = '%SAVE' THEN DO
  110.       RESULT = "Rexx:ABserver"('%SAVE')
  111.  
  112.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */ 
  113.  
  114.       IF RESULT = 0 THEN
  115.          ShowMessage 1 1 '"Save was NOT succesfull!" "" "" "Ok" "" ""'
  116.  
  117.       /* End */
  118.  
  119.       SIGNAL continue
  120.    END
  121.  
  122.    WHEN RESULT = '%SAVEAS' THEN DO
  123.       RESULT = "Rexx:ABserver"('%SAVEAS')
  124.  
  125.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */
  126.  
  127.       IF RESULT = 0 THEN
  128.          ShowMessage 1 1 '"Save was NOT succesfull!" "" "" "Ok" "" ""'
  129.  
  130.       /* End */
  131.        
  132.       SIGNAL continue
  133.    END
  134.  
  135.    WHEN RESULT = '%QUIT' THEN DO
  136.       RESULT = "Rexx:ABserver"('%QUIT')
  137.  
  138.       /* Insert code to handle returned value here. 0 = No succes,
  139.       1 = Success, -1 = Last project was quit, and AB closed down */
  140.  
  141.       IF RESULT = 0 THEN
  142.          ShowMessage 1 1 '"The current project has NOT been closed." "" "" "Ok" "" ""'
  143.       ELSE DO
  144.          IF RESULT = -1 THEN DO
  145.             ShowMessage 1 1 '"AmigaBase has been closed." "" "" "Exit" "Continue" ""'
  146.             IF RESULT = 1 THEN
  147.                EXIT
  148.          END
  149.       END
  150.  
  151.       /* End */
  152.        
  153.       SIGNAL continue
  154.    END
  155.  
  156.    WHEN RESULT = '%NEW' THEN DO
  157.       RESULT = "Rexx:ABserver"('%NEW')
  158.  
  159.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */
  160.  
  161.       /* End */
  162.        
  163.       SIGNAL continue
  164.    END
  165.  
  166.    WHEN LEFT(RESULT,8) = '%PROJECT' THEN DO
  167.       RESULT = "Rexx:ABserver"(RESULT)
  168.  
  169.       /* Insert code to handle returned value here. 0 = No succes, 1 = Succes */
  170.  
  171.       IF RESULT = 0 THEN
  172.          ShowMessage 1 1 '"Project has NOT been changed" "" "" "Ok" "" ""'
  173.  
  174.  
  175.       /* End */
  176.        
  177.       SIGNAL continue
  178.    END
  179.  
  180.    OTHERWISE
  181.  
  182. END
  183.  
  184. /* Retrieve the text from Amigabase */
  185. ret = "Rexx:ABserver"(RESULT)
  186.  
  187. /*-----------------------------------------------------------------------------
  188.    This is where you insert your commands. The returned text can be found
  189.    in the ret-variable.
  190. -----------------------------------------------------------------------------*/
  191.  
  192. /* If anything is returned, then insert it */
  193. IF LENGTH(ret)>0 THEN DO
  194.  
  195.    /* All commands in here, are FinalWriters Arexx-commands.
  196.       If you don't like the way text is inserted, this is where you
  197.       change styles,fonts or whatever you don't like.
  198.    */
  199.    ScreenToFront
  200.    WinToFront
  201.  
  202.    /* Set the attributes for the text */
  203.    FontSize 8
  204.    Width 150
  205.    Spacing Variable
  206.    Leading 8
  207.  
  208.    /* Insert the text */
  209.    Type ret
  210.  
  211.    /* Set the attributes to the ones you want to use after the
  212.       inserted text
  213.    */
  214.    FontSize 18
  215.    Width Normal
  216.    Spacing Single
  217.    Leading 14
  218.  
  219.    END
  220. ELSE
  221.    /* If an empty string was returned, which means not found */
  222.    ShowMessage 1 1 '"Cannot retrieve the text for"' which '"in current project" "Ok" "" ""'
  223.  
  224. /*-----------------------------------------------------------------------------
  225.    End of your commands
  226. -----------------------------------------------------------------------------*/
  227.  
  228. EXIT
  229.  
  230. GetFName: PROCEDURE
  231.  
  232. /* Extraxt the filename from a complete path */
  233.  
  234. pos = LASTPOS('/',arg(1))
  235. IF pos = 0 THEN
  236.    pos = LASTPOS(':',arg(1))
  237.  
  238. RETURN SUBSTR(arg(1),pos+1)
  239.  
  240.