home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 4: Phase Four / 17Bit_Phase_Four.iso / files / 3347.dms / 3347.adf / AdPro-Toolbox / F0.adpro next >
Encoding:
Text File  |  1994-04-16  |  44.2 KB  |  1,955 lines

  1. /*                            
  2. **                       A D P r o   T o o l b o x        
  3. **
  4. **                             Version 4.10
  5. **
  6. **    This ARexx program is a Format Converter and effect generator.
  7. **             Requires ADPro V2.3.0 for some new features
  8.                           This Program is Shareware
  9.                            Last changes: 15.4.1994
  10.  
  11. **                      
  12. **            ------------------------------------------------
  13. **           |        This AREXX script was written by        |
  14. **              |              Andreas Seebacher of              |
  15. **           |                 BitART design                  |
  16. **           |               Debugging help by                |
  17. **           |                  Martin Moser                  |
  18. **           |    Some useful ideas by Armin Kleinschmidt     |
  19. **              |                     (c) 1993-94                   |
  20. **               ------------------------------------------------
  21. */
  22.  
  23. /*
  24.   Make sure the needed libraries are available, and away we go!
  25. */
  26.  
  27. IF ~SHOW('L','rexxsupport.library') THEN
  28.   CALL ADDLIB('rexxsupport.library',0,-30,0)
  29. IF ~SHOW('L','rexxarplib.library') THEN
  30.   CALL ADDLIB('rexxarplib.library',0,-30,0)
  31.  
  32. ADDRESS "ADPro"
  33. OPTIONS RESULTS
  34. NL = '0A'X
  35.  
  36. ADPRO_TO_BACK
  37.  
  38. /*
  39.   Find a free hostport.
  40. */
  41.  
  42. host='TOOLBOXHOST'
  43. port='TOOLBOXPORT'
  44. IF replyport='' THEN
  45.   DO
  46.     DO i=1 WHILE SHOW('P',host||i)
  47.     END
  48.     host=host||i
  49.     port=port||i
  50.   END
  51. ELSE
  52.   DO
  53.     host=host'.'replyport
  54.     port=port'.'replyport
  55.     IF SHOW('P',port) THEN
  56.       DO
  57.         INTERPRET ADDRESS port FRONT
  58.         EXIT(0)
  59.       END
  60.   END
  61.  
  62. /*
  63.   We need a HOST to set up our window in
  64. */
  65.  
  66. CALL setup_host()
  67.  
  68. CALL setup_variables()
  69.  
  70. w.=''
  71. w.idcmp='CLOSEWINDOW+MENUPICK+GADGETUP+MOUSEBUTTONS'
  72. w.flags='WINDOWCLOSE+WINDOWDRAG'
  73.  
  74.  
  75. w.title='ADPro-ToolBOX V4.10  (c) BitART design 1994'
  76. IF replyport~='' THEN w.title='ADPro-ToolBOX V4.10    (c) BitART design 1994'
  77.  
  78. pscreen='Workbench'
  79. xmax=410
  80. ymax=165
  81. CALL OpenWindow(host,(ScreenCols(pscreen)-xmax)%2, ,
  82.                      (ScreenRows(pscreen)-ymax)%2, ,
  83.                      xmax,ymax,w.idcmp,w.flags,w.title)
  84.  
  85. /*
  86.   Make sure our text images will be correct, no matter what...
  87. */
  88.  
  89. CALL SetFont(host,'topaz.font',8)
  90.  
  91. CALL SetAPen(host,1)
  92.  
  93. /*
  94.   Setting up our main menus...
  95. */
  96.  
  97. CALL AddMenu(host,'Project')
  98. CALL AddItem(host,'Start Converting','OK','S')
  99. CALL AddItem(host,'-------------------','DUMMY')
  100. CALL AddItem(host,'Save Preferences...','SAVEPREFS','P')
  101. CALL AddItem(host,'-------------------','DUMMY')
  102. CALL AddItem(host,'Quit    ','CLOSEWINDOW','Q')
  103.  
  104. CALL AddMenu(host,'Prefs')
  105. CALL AddItem(host,'First pic palette','PALETTE')
  106. CALL AddSubItem(host,'   Palette locked','PLOCKED','L',-1)
  107. CALL AddSubItem(host,'   Palette unlocked','PUNLOCKED','U',-1)
  108.  
  109.     if LockedItemFlag=1 then do
  110.         CALL SetItem(host,1,0,LockedItemFlag,ON)
  111.         PSTATUS unlocked
  112.     end
  113.     else do
  114.         LockedItemFlag=0
  115.         CALL SetItem(host,1,0,LockedItemFlag,ON)
  116.         PSTATUS locked
  117.     end
  118.  
  119. CALL AddItem(host,'Requester','REQ')
  120. CALL AddSubItem(host,'   ReqToolsRequester','REQTOOL','R',-1)
  121. CALL AddSubItem(host,'   Arp Requester','ARPREQ','A',-1)
  122.  
  123.     if RequesterItemFlag=1 then do
  124.         CALL SetItem(host,1,1,RequesterItemFlag,ON)
  125.         ReqFlag=1
  126.     end
  127.     else do
  128.         RequesterItemFlag=0
  129.         CALL SetItem(host,1,1,RequesterItemFlag,ON)
  130.         ReqFlag=0
  131.     end
  132.  
  133. CALL SetAPen(host,1)
  134.  
  135. /* 
  136.   Setting up our gadgets...
  137. */
  138.  
  139. /* ------ Loader -------*/
  140. CALL Move(host,10,26)
  141. CALL Text(host,'Loader')
  142.  
  143. CALL AddGadget(host,70,20,1,IMAGELOADFORMAT,'LLL||%g',150,RIDGEBORDER)
  144.  
  145. /* ------ Saver -------*/
  146. CALL Move(host,10,42)
  147. CALL Text(host,'Saver')
  148.  
  149. CALL AddGadget(host,70,36,2,IMAGESAVEFORMAT,'SSS||%g',150,RIDGEBORDER)
  150.  
  151. /* ------ Dither -------*/
  152. CALL Move(host,10,58)
  153. CALL Text(host,'Dither 0=Off,1=Floyd..')
  154.  
  155. CALL AddGadget(host,195,52,3,DITHERING,'DDD||%g',25,RIDGEBORDER)
  156.  
  157. /* ------ Scale X -------*/
  158. CALL Move(host,10,74)
  159. CALL Text(host,'Absolute Scale-x')
  160.  
  161. CALL AddGadget(host,170,68,4,ABSSC_X,'SSX||%g',50,RIDGEBORDER)
  162.  
  163. /* ------ Scale Y -------*/
  164. CALL Move(host,10,90)
  165. CALL Text(host,'Absolute Scale-y')
  166.  
  167. CALL AddGadget(host,170,84,5,ABSSC_Y,'SSY||%g',50,RIDGEBORDER)
  168.  
  169. /* ------ Operator -------*/
  170. CALL Move(host,10,106)
  171. CALL Text(host,'Operator')
  172.  
  173. CALL AddGadget(host,82,100,6,OPERATORNAME,'OOP||%g',118,RIDGEBORDER)
  174.  
  175. /* ---- OperatorHelp ----*/
  176. CALL AddGadget(host,208,99,20,'?','OPHELP')
  177.  
  178. /* ------ COLORS -------*/
  179. CALL Move(host,226,106)
  180. CALL Text(host,'Number of Colors')
  181.  
  182. CALL AddGadget(host,360,100,7,COLORNR,'CCC||%g',40,RIDGEBORDER)
  183.  
  184.  
  185. /*
  186.   Table to set the right Output screenresolution...
  187. */
  188.  
  189. CALL box(host,2,1,226,17,174,77)
  190.  
  191. CALL SetAPen(host,1)
  192. CALL Move(host,235,27)
  193. CALL Text(host,' Set Output Format:')
  194. CALL AddGadget(host,240,33,10,' Hi-Res ','RES_XH')
  195. CALL AddGadget(host,320,33,11,' Lo-Res ','RES_XL')
  196. CALL AddGadget(host,240,49,12,'  Lace  ','RES_YL')
  197. CALL AddGadget(host,320,49,13,' NoLace ','RES_YNL')
  198. CALL AddGadget(host,240,65,14,' HOscan ','HOVER')
  199. CALL AddGadget(host,320,65,15,' HSdtSz ','HSDTSZ')
  200. CALL AddGadget(host,240,81,16,' VOscan ','VOVER')
  201. CALL AddGadget(host,320,81,17,' VSdtSz ','VSDTSZ')
  202.  
  203. /* 
  204.    --------------------------------- 
  205.               STATUS BOX 
  206.    ---------------------------------- 
  207. */
  208.  
  209. CALL box(host,1,2,175,119,225,12)  /* StatusBox */
  210. CALL SetAPen(host,1)
  211. CALL Move(host,10,128)
  212. CALL Text(host,'Selected Resolution:')
  213.  
  214. CALL SetAPen(host,2)
  215. if HIRES = 0 then do
  216.         CALL Move(host,185,128)
  217.         CALL Text(host,'LoRes ')
  218. end
  219. else do
  220.         CALL Move(host,185,128)
  221.         CALL Text(host,'HiRes ')
  222.     HIRES=1
  223. end     
  224.  
  225. if INTERLACE = 0 then do
  226.         CALL Move(host,240,128)
  227.         CALL Text(host,'NoLace ')
  228. end
  229. else do
  230.         CALL Move(host,240,128)
  231.         CALL Text(host,' Lace  ')
  232.     INTERLACE=2
  233. end     
  234.  
  235. if HOVERSCAN = 0 then do
  236.         CALL Move(host,300,128)
  237.         CALL Text(host,'SdtSz ')
  238. end
  239. else do
  240.         CALL Move(host,300,128)
  241.         CALL Text(host,'HScan ')
  242.     HOVERSCAN=8
  243. end     
  244.  
  245. if VOVERSCAN = 0 then do
  246.         CALL Move(host,350,128)
  247.         CALL Text(host,'SdtSz ')
  248. end
  249. else do
  250.         CALL Move(host,350,128)
  251.         CALL Text(host,'VScan ')
  252.     VOVERSCAN=16
  253. end         
  254.  
  255. /* --------------------------------- */
  256.  
  257. CALL Box(host,1,2,10,ymax-23,388,1)        /* Lower Line */ 
  258.  
  259. CALL AddGadget(host,11,ymax-16,98,'START CONVERTING','OK')
  260. CALL AddGadget(host,xmax-64,ymax-16,99,'CANCEL','CLOSEWINDOW')
  261. CALL AddGadget(host,(xmax/2)-10,ymax-16,97,'HELP n INFO','HELP')
  262.  
  263.  
  264. /*
  265. --------------------------------------------
  266. ---  Getting our Arguments from the port ---
  267. --------------------------------------------
  268. */
  269.  
  270. CALL tofront()
  271.  
  272. quitflag = 0
  273. register = 0
  274. number = 0
  275. newnum = 1
  276. CALL ActivateGadget(host,1)
  277.  
  278. start:
  279.   
  280. do forever
  281.   if quitflag=1 then leave
  282.     t = waitpkt(port)
  283.   do forever
  284.       p = getpkt(port)
  285.       if c2d(p) = 0 then leave
  286.  
  287.       arg = getarg(p,0)
  288.       t = reply(p, 0)
  289.  
  290.       if arg=CLOSEWINDOW then do
  291.         CALL CloseWindow(host)
  292.     quitflag=1
  293.       end 
  294.  
  295.       if LEFT(arg,3)='LLL' THEN do
  296.         IMAGELOADFORMAT = RIGHT(arg,LENGTH(arg)-5)  
  297.         CALL ActivateGadget(host,2)
  298.       end
  299.       if LEFT(arg,3)='SSS' THEN do
  300.         IMAGESAVEFORMAT = RIGHT(arg,LENGTH(arg)-5)
  301.         CALL ActivateGadget(host,3)
  302.       end
  303.       if LEFT(arg,3)='DDD' THEN do
  304.         DITHERING = RIGHT(arg,LENGTH(arg)-5)
  305.         CALL ActivateGadget(host,4)
  306.       end
  307.       if LEFT(arg,3)='SSX' THEN do
  308.         ABSSC_X = RIGHT(arg,LENGTH(arg)-5)
  309.         CALL ActivateGadget(host,5)
  310.       end
  311.       if LEFT(arg,3)='SSY' THEN do
  312.         ABSSC_Y = RIGHT(arg,LENGTH(arg)-5)
  313.         CALL ActivateGadget(host,6)
  314.       end
  315.       if LEFT(arg,3)='OOP' THEN do
  316.         OPERATORNAME = RIGHT(arg,LENGTH(arg)-5)
  317.         CALL ActivateGadget(host,7)
  318.       end
  319.       if LEFT(arg,3)='CCC' THEN COLORNR = RIGHT(arg,LENGTH(arg)-5)
  320.     
  321. /*
  322.     Returncodes for resolution settings 
  323.     when resolutionbuttons are pressed 
  324. */
  325.  
  326.       if arg='RES_XH' THEN do
  327.          HIRES=1
  328.          CALL SetAPen(host,2)
  329.          CALL Move(host,185,128)
  330.          CALL Text(host,'HiRes ')
  331.      CALL SetAPen(host,1)
  332.       end  
  333.  
  334.       if arg='RES_XL' THEN do
  335.          HIRES=0
  336.      CALL SetAPen(host,2)
  337.          CALL Move(host,185,128)
  338.          CALL Text(host,'LoRes ')
  339.      CALL SetAPen(host,1)
  340.       end    
  341.  
  342.       if arg='RES_YL' THEN do
  343.          INTERLACE=2
  344.      CALL SetAPen(host,2)
  345.          CALL Move(host,240,128)
  346.          CALL Text(host,' Lace  ')
  347.      CALL SetAPen(host,1)
  348.       end
  349.  
  350.       if arg='RES_YNL' THEN do
  351.          INTERLACE=0
  352.      CALL SetAPen(host,2)
  353.          CALL Move(host,240,128)
  354.          CALL Text(host,'NoLace ')
  355.      CALL SetAPen(host,1)
  356.       end
  357.  
  358.       if arg='HOVER' THEN do
  359.          HOVERSCAN=8
  360.      CALL SetAPen(host,2)
  361.          CALL Move(host,300,128)
  362.          CALL Text(host,'HScan ')
  363.      CALL SetAPen(host,1)
  364.       end
  365.  
  366.       if arg='HSDTSZ' THEN do
  367.          HOVERSCAN=0
  368.      CALL SetAPen(host,2)
  369.          CALL Move(host,300,128)
  370.          CALL Text(host,'SdtSz ')
  371.      CALL SetAPen(host,1)
  372.       end
  373.  
  374.       if arg='VOVER' THEN do
  375.          VOVERSCAN=16
  376.      CALL SetAPen(host,2)
  377.          CALL Move(host,350,128)
  378.          CALL Text(host,'VScan ')
  379.      CALL SetAPen(host,1)
  380.       end
  381.  
  382.       if arg='VSDTSZ' THEN do
  383.          VOVERSCAN=0
  384.      CALL SetAPen(host,2)
  385.          CALL Move(host,350,128)
  386.          CALL Text(host,'SdtSz ')
  387.      CALL SetAPen(host,1)
  388.       end
  389.  
  390. /* 
  391.       Palette locked/unlocked status and
  392.       ReqTools or Arp library selection
  393. */
  394.  
  395.       if arg='PLOCKED' THEN do
  396.          CALL SetItem(host, 1, 0, 0, ON)
  397.          CALL SetItem(host, 1, 0, 1, OFF)
  398.      PSTATUS locked
  399.      LockedItemFlag=0
  400.       end
  401.  
  402.       if arg='PUNLOCKED' THEN do
  403.          CALL SetItem(host, 1, 0, 0, OFF)
  404.          CALL SetItem(host, 1, 0, 1, ON)
  405.          PSTATUS unlocked
  406.      LockedItemFlag=1
  407.       end
  408.  
  409.       if arg='REQTOOL' THEN do
  410.      ReqFlag=0
  411.      CALL SetItem(host,1,1,0,ON)
  412.      CALL SetItem(host,1,1,1,OFF)
  413.      RequesterItemFlag=0
  414.       end
  415.  
  416.       if arg='ARPREQ' THEN do
  417.      ReqFlag=1
  418.       CALL SetItem(host,1,1,0,OFF)
  419.      CALL SetItem(host,1,1,1,ON)
  420.      RequesterItemFlag=1
  421.       end
  422.  
  423.       if arg='HELP' then do
  424.          IF( ~EXISTS( "adproscripts:F0.guide")) THEN do
  425.         ADPRO_TO_FRONT
  426.         Okay1 "<F0.guide> not found. Please" || NL ||,
  427.                     "copy it into <adproscripts:> " || NL ||,
  428.               "and try again  "
  429.         ADPRO_TO_BACK
  430.          end
  431.          IF( ~EXISTS( "sys:utilities/AmigaGuide")) THEN do
  432.         ADPRO_TO_FRONT
  433.         Okay1 " AmigaGuide not found. "
  434.               ADPRO_TO_BACK
  435.          end
  436.          else do
  437.                  cmd = "run AmigaGuide adproscripts:F0.guide"
  438.                      ADDRESS COMMAND cmd
  439.          end
  440.       END
  441.  
  442.       if arg='OPHELP' then do         
  443.     ADPRO_TO_FRONT
  444.              Okay1 "Special Operators" || NL ||,             
  445.                  "           " || NL ||, 
  446.                  " +Blur     " || NL ||,
  447.              " +Ripple   " || NL ||,
  448.                  " +Balance  " || NL ||,
  449.                       " +Twirl    " || NL ||,
  450.                       " +3DMosaik " || NL ||,
  451.                       " +HVMosaik " || NL ||,
  452.                   " +Refract  " || NL ||,
  453.                       " +Emboss   " || NL ||,
  454.                       " +Fresco   "
  455.     ADPRO_TO_BACK
  456.       end  
  457.  
  458.       if arg='SAVEPREFS' then do
  459.             success=open(PrefsFile,'ADProScripts:F0.config','W')
  460.         if success=0 then do
  461.             ADPRO_TO_FRONT
  462.             OKAY1 "Can't write Preferences!"
  463.             ADPRO_TO_BACK
  464.         end
  465.         else do
  466.             chars=writeln(PrefsFile,LockedItemFlag)
  467.             chars=writeln(PrefsFile,RequesterItemFlag)
  468.             chars=writeln(PrefsFile,IMAGELOADFORMAT)
  469.             chars=writeln(PrefsFile,IMAGESAVEFORMAT)
  470.             chars=writeln(PrefsFile,ABSSC_X)
  471.             chars=writeln(PrefsFile,ABSSC_Y)
  472.             chars=writeln(PrefsFile,DITHERING)
  473.             chars=writeln(PrefsFile,HIRES)
  474.             chars=writeln(PrefsFile,INTERLACE)
  475.             chars=writeln(PrefsFile,HOVERSCAN)
  476.             chars=writeln(PrefsFile,VOVERSCAN)
  477.             chars=writeln(PrefsFile,OPERATORNAME)
  478.             chars=writeln(PrefsFile,COLORNR)        
  479.             success=close(PrefsFile)
  480.         end
  481.     end
  482.         
  483.  
  484.       if arg=OK then do  
  485.     CALL CloseWindow(host)
  486.     CALL CallByReference()
  487.       end
  488.   end
  489. END
  490.  
  491. EXIT
  492.  
  493.  
  494.  
  495. /*
  496.   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  497.   *****************************
  498.   -----------------------------
  499.   ---- A D P R O - P A R T ----
  500.   -----------------------------
  501.   *****************************
  502.   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  503. */    
  504.  
  505. CallByReference:
  506.  
  507. IF OperatorName='+Ripple' | OperatorName='+RIPPLE' | OperatorName='+ripple'
  508.  THEN CALL RippleGUI() 
  509. IF OperatorName='+Twirl' | OperatorName='+TWIRL' | OperatorName='+twirl'
  510.  THEN CALL TwirlGUI() 
  511. IF OperatorName='+Emboss' | OperatorName='+EMBOSS' | OperatorName='+emboss'
  512.  THEN CALL EmbossGUI() 
  513. IF OperatorName='+Blur' | OperatorName='+BLUR' | OperatorName='+blur'
  514.  THEN CALL BlurGUI() 
  515. IF OperatorName='+Refract' | OperatorName='+REFRACT' | OperatorName='+refract'
  516.  THEN CALL RefractGUI() 
  517. IF OperatorName='+Balance' | OperatorName='+BALANCE' | OperatorName='+balance'
  518.  THEN CALL BalanceGUI() 
  519.  
  520.  
  521. ADPRO_TO_FRONT
  522.  
  523.  
  524.  GETFILES '"Select first file to convert"'
  525.  IF RC ~= 0 THEN DO
  526.     CALL CloseWindow(host)
  527.     EXIT
  528.  END
  529.  
  530. /* 
  531.   This one is for the fist file entry.
  532. */
  533.  
  534.  TheFiles      = ADPRO_RESULT
  535.  NumberOfFiles = WORDS(TheFiles)
  536.  
  537.  
  538.  if reqflag=1 then do                  /* That means Arp-library active! */
  539.     string      = word(TheFiles,1)
  540.     laenge      = length(string)
  541.     pointpos    = lastpos(".",string)
  542.     indexdigits = laenge - pointpos
  543.     number      = right(string,indexdigits)
  544.  end
  545.  else do                               /* ReqTools-library active! */
  546.     string      = word(TheFiles,1)
  547.     laenge      = length(string)
  548.     realstring  = left(string,laenge-1)
  549.     reallength  = length(realstring)
  550.     pointpos    = lastpos(".",realstring)
  551.     indexdigits = reallength - pointpos
  552.     number      = right(realstring,indexdigits)
  553.  end
  554.  
  555.     if indexdigits ~= "3" then do
  556.              OKAY1 ,
  557.                      " The Fileindex must have three     " || NL ||,
  558.                  " digits as suffix!                 " || NL ||,
  559.                  " Example:   Picname.000            " || NL ||,
  560.                  " or         Picname.269            " || NL ||,
  561.                  "                                   " || NL ||,
  562.                  " Possible Errors:                  " || NL ||,
  563.                  " - Wrong library (If you use       " || NL ||,
  564.                  "   RTPatch you must choose the     " || NL ||,
  565.                  "   ReqToolsLibrary from the menu)  " || NL ||,
  566.                  " - Wrong Fileindex (see above!)    " || NL ||,
  567.                  "                                   "
  568.              EXIT
  569.     end
  570.  
  571. /* 
  572.   This one is for the last file entry.
  573. */
  574.  
  575.  GETFILES '"Select last file to convert"'
  576.  IF RC ~= 0 THEN DO
  577.     CALL CloseWindow(host)
  578.     EXIT
  579.  END
  580.  
  581.  TheFiles2      = ADPRO_RESULT
  582.  NumberOfFiles2 = WORDS(TheFiles2)
  583.  
  584.  
  585.  if reqflag=1 then do                  /* That means Arp-library active! */
  586.     string2      = word(TheFiles2,1)
  587.     laenge2      = length(string2)
  588.     pointpos2    = lastpos(".",string2)
  589.     indexdigits2 = laenge2 - pointpos2
  590.     number2      = right(string2,indexdigits2)
  591.  end
  592.  else do                               /* ReqTools-library active! */
  593.     string2      = word(TheFiles2,1)
  594.     laenge2      = length(string2)
  595.     realstring2  = left(string2,laenge2-1)
  596.         reallength2  = length(realstring2)
  597.     pointpos2    = lastpos(".",realstring2)
  598.     indexdigits2 = reallength2 - pointpos2
  599.     number2      = right(realstring2,indexdigits2)
  600.  end
  601.     
  602.     if indexdigits2 ~= "3" then do
  603.              OKAY1 ,
  604.                      " The Fileindex must have three     " || NL ||,
  605.                  " digits as suffix!                 " || NL ||,
  606.                  " Example:   Picname.000            " || NL ||,
  607.                  " or         Picname.269            " || NL ||,
  608.                  "                                   " || NL ||,
  609.                  " Possible Errors:                  " || NL ||,
  610.                  " - Wrong library (If you use       " || NL ||,
  611.                  "   RTPatch you must choose the     " || NL ||,
  612.                  "   ReqToolsLibrary from the menu)  " || NL ||,
  613.                  " - Wrong Fileindex (see above!)    " || NL ||,
  614.                  "                                   "
  615.              EXIT
  616.     end
  617.  
  618.     body = left(string,pointpos)
  619.     diff = number2 - number
  620.     
  621. /* -------------------------------------*/
  622. GETFILES '"Select Output Path"'
  623. IF RC ~= 0 THEN DO
  624.     CALL CloseWindow(host)
  625.     EXIT
  626. END
  627.  
  628. TheSaveFiles = ADPRO_RESULT
  629. OUT_FILE     = TheSaveFiles
  630.  
  631. /* 
  632.   If Reqtools.library is active 
  633. */
  634.  
  635. if reqflag=0 then do   
  636.     OUT_FILE = right(OUT_FILE,length(OUT_FILE)-1)
  637.     OUT_FILE = left(OUT_FILE,length(OUT_FILE)-2)
  638. end
  639.  
  640. PicSaveCounter = 1
  641. NewFileCounter=0
  642.  
  643.  
  644. /*
  645.    If "RAW" is selected in the ColorNR gadget, the conversation
  646.    must be done in 24-bit mode
  647. */
  648.     if COLORNR = 'RAW' | COLORNR = 'raw' | COLORNR = 'Raw' then 
  649.     CALL 24bit_conv()
  650.  
  651.  
  652. do while NewFileCounter <= diff
  653.  
  654.     in_file = body || right(Number+NewFilecounter,3,'0')
  655.  
  656.     /* 
  657.        ^ automatic adding of 000's in only one line!!!
  658.     */
  659.  
  660.   /* -------------------------------------*/
  661.     lformat ImageLoadFormat
  662.     load in_file 
  663.  
  664.     if RC ~= 0 then do
  665.        okay1 "Error loading" || NL ||, 
  666.              in_file
  667.        EXIT
  668.     END
  669.     
  670.   /* -------------------Screenparameter---*/    
  671.     PTOTAL ColorNr
  672.     DITHER Dithering         
  673.     If left(OperatorName,1) ~= '+' & Operatorname ~= 'NONE' then OPERATOR OperatorName
  674.     CALL OperatorCalls()
  675.     if AbsSc_x ~= "-1" | AbsSc_y ~= "-1" then 
  676.         ABS_SCALE AbsSc_x AbsSc_y
  677.     RENDER_TYPE ColorNr                         /* Number of colors */
  678.     SCREEN_TYPE HIRES + INTERLACE + HOVERSCAN + VOVERSCAN + 4
  679.   /* -------------------------------------*/
  680.     Execute
  681.   /* -------------------------------------*/    
  682.     PSTATUS locked
  683.     Display = 1
  684.     If Display = 1 then ADPRO_DISPLAY
  685.     SFORMAT ImageSaveFormat
  686.     
  687.      SaveName = OUT_FILE || . || right(PicSaveCounter,3,'0')
  688.      save SaveName "IMAGE"
  689.  
  690.     PicSaveCounter = PicSaveCounter + 1
  691.     NewFileCounter = NewFileCounter + 1
  692. end
  693.  
  694. EXIT
  695. RETURN
  696.  
  697. /*
  698.   -----------------------
  699.   ---- Procedures -------
  700.   -----------------------
  701. */
  702.  
  703. /* 
  704.    Procedure if the RAW ColorNR Gadget is activated.
  705. */
  706.  
  707. 24bit_conv:
  708.    do while NewFileCounter <= diff
  709.  
  710.     in_file=body || right(number+NewFileCounter,3,'0')
  711.  
  712.  
  713.   /* -------------------------------------*/
  714.     lformat ImageLoadFormat
  715.     load in_file 
  716.  
  717.     if RC ~= 0 then do
  718.        okay1 "Could not Load" in_file
  719.        CALL CloseWindow(host)
  720.        EXIT
  721.     END
  722.     
  723.   /* -------------------Screenparameter---*/    
  724.     DITHER Dithering 
  725.     If left(OperatorName,1) ~= '+' & OperatorName ~= 'NONE' then OPERATOR OperatorName
  726.     CALL OperatorCalls()
  727.     if AbsSc_x ~= "-1" | AbsSc_y ~= "-1" then 
  728.         ABS_SCALE AbsSc_x AbsSc_y
  729.     SCREEN_TYPE HIRES + INTERLACE + HOVERSCAN + VOVERSCAN + 4
  730.     SFORMAT ImageSaveFormat
  731.  
  732.      SaveName = OUT_FILE || . || right(PicSaveCounter,3,'0')
  733.      save SaveName "RAW"
  734.  
  735.     PicSaveCounter = PicSaveCounter + 1
  736.     NewFileCounter=NewFileCounter+1
  737.    end
  738.    EXIT
  739. RETURN
  740.  
  741.  
  742. /* -------------------------
  743.    -- Operator Procedures --
  744.    -------------------------
  745. */    
  746.  
  747. OperatorCalls:
  748.      If OperatorName = '+Twirl' | OperatorName='+TWIRL' | OperatorName='+twirl' then 
  749.         CALL TwirlOperator()
  750.      If OperatorName = '+Ripple' | OperatorName='+ripple' | OperatorName='+RIPPLE' then 
  751.         CALL RippleOperator()
  752.      If OperatorName = '+Blur' | OperatorName='+blur' | OperatorName='+BLUR' then 
  753.         CALL BlurOperator()
  754.      If OperatorName = '+3DMosaik' | OperatorName='+3dmosaik' | OperatorName='+3DMOSAIK' then 
  755.         CALL 3DMosaikOperator()
  756.      If OperatorName = '+HVMosaik' | OperatorName='+hvmosaik' | OperatorName='+HVMOSAIK' then 
  757.         CALL HVMosaikOperator()
  758.      If OperatorName = '+Emboss' | OperatorName='+emboss' | OperatorName='+EMBOSS' then 
  759.         CALL EmbossOperator()
  760.      If OperatorName = '+Fresco' | OperatorName='+fresco' | OperatorName='+FRESCO' then 
  761.         CALL FrescoOperator()
  762.      If OperatorName = '+Refract' | OperatorName='+refract' | OperatorName='+REFRACT' then 
  763.         CALL RefractOperator()
  764.     IF OperatorName = '+Balance' | OperatorName='+BALANCE' | OperatorName='+balance' then
  765.         CALL BalanceControl() 
  766. RETURN
  767.  
  768. /* 
  769.    ******************************************
  770.    *********    SPECIAL OPERATORS   *********
  771.    ******************************************
  772. */
  773.  
  774. TwirlOperator:
  775.     if EWidth='CenterX' then do            /* ENTRY */
  776.         XSIZE
  777.         EWidth=ADPRO_RESULT % 2
  778.     end
  779.     if EHight='CenterY' then do
  780.         YSIZE
  781.         EHight=ADPRO_RESULT % 2
  782.     end
  783.     if ERadius='Image' then do
  784.         XSIZE
  785.         ERadius=ADPRO_RESULT % 2
  786.     end
  787.  
  788.     if XWidth='CenterX' then do           /* EXIT */
  789.         XSIZE
  790.         XWidth=ADPRO_RESULT % 2
  791.     end
  792.     if XHight='CenterY' then do
  793.         YSIZE
  794.         XHight=ADPRO_RESULT % 2
  795.     end
  796.     if XRadius='Image' then do
  797.         XSIZE
  798.         XRadius=ADPRO_RESULT % 2
  799.     end
  800.     
  801. /*
  802.     Algorythm to interpolate Entry and Exit values.
  803. */
  804.  
  805.     if TwirlFlag ~= 999 then do             
  806.         _Width = (XWidth - EWidth) % diff
  807.             if _Width < 0 then Width = EWidth
  808.             else
  809.                 Width = EWidth
  810.         _Hight = (XHight - EHight) % diff
  811.             if _Hight < 0 then Hight = EHight
  812.             else    
  813.             Hight = EHight
  814.         _Radius = (XRadius - ERadius) % diff
  815.             if _Radius < 0 then Radius = ERadius
  816.             else
  817.             Radius = ERadius
  818.         _Amount = (XAmount - EAmount) % diff
  819.              if _Amount < 0 then Amount = -EAmount
  820.             else
  821.             Amount = EAmount
  822.         _BlurRadius = (XBlurRadius - EBlurRadius) % diff
  823.             if _BlurRadius < 0 then BlurRadius = EBlurRadius
  824.             else
  825.             BlurRadius = EBlurRadius
  826.         TwirlFlag = 999
  827.     end
  828.  
  829.     else do
  830.         if _Width < 0 then Width = Width + _Width  
  831.         else
  832.         Width = Width + _Width    
  833.     
  834.         if _Hight < 0 then Hight = Hight + _Hight 
  835.         else
  836.         Hight = Hight + _Hight
  837.  
  838.         if _Radius < 0 then Radius = Radius + _Radius 
  839.         else
  840.         Radius = Radius + _Radius
  841.  
  842.         if _Amount < 0 then Amount = Amount - _Amount /* ( - and - is + !!!) */
  843.         else
  844.         Amount = Amount + _Amount
  845.  
  846.         if _BlurRadius < 0 then BlurRadius = BlurRadius + _Radius 
  847.         else
  848.         BlurRadius = BlurRadius + _BlurRadius
  849.     end
  850.  
  851.     Operator "TWIRL",
  852.     "CENTER" Width Hight "RADIUS" Width "AMOUNT" Amount,
  853.     "BLUR_RADIUS" BlurRadius "QUALITY_HIGH"
  854. RETURN
  855.  
  856. /*-----------------------------------------------------------*/
  857.  
  858. RippleOperator:
  859.     If XPos='CenterX' then do
  860.         XSIZE
  861.         XPos=ADPRO_RESULT % 2
  862.     end
  863.     If YPos='CenterY' then do
  864.         YSIZE
  865.         YPos=ADPRO_RESULT % 2
  866.     end
  867.  
  868.     if RippleFlag ~= 999 then do             
  869.         Phase = 0
  870.         RippleFlag = 999
  871.     end
  872.  
  873.       phase=phase + (360 % diff) 
  874.  
  875.     Operator "RIPPLE",
  876.     "CENTER" XPos YPos "PROPSPEED" Speed "PERIOD" Period "AMPLITUDE" Amplitude,
  877.     "PHASE" Phase "RAMP" Ramp "LEVELOFF" Leveloff "WAVETYPE" Wavetype "FRAME" Frame "NEWWAVE"
  878. RETURN
  879. /*-----------------------------------------------------------*/
  880.  
  881. BlurOperator:
  882.     Operator "BLUR" CW TH
  883. RETURN
  884. /*-----------------------------------------------------------*/
  885.  
  886. 3DMosaikOperator:
  887.  
  888.     IF( ~EXISTS( "adpro:convolutions/DeepPress" )) THEN DO
  889.         ADPRO_TO_FRONT
  890.         OKAY1 "The convolution DeepPress," || NL ||,
  891.             "cannot be found."
  892.         EXIT
  893.     END
  894.  
  895.     XSIZE
  896.     XCoord = ADPRO_RESULT
  897.     YSIZE
  898.     YCoord = ADPRO_RESULT
  899.  
  900.     do loop = 1 TO 3
  901.         OPERATOR "HALVE"
  902.     END
  903.  
  904.     ABS_SCALE XCoord YCoord
  905.  
  906.     OPERATOR "CONVOLVE" "adpro:convolutions/DeepPress" 100 0
  907. RETURN
  908. /*-----------------------------------------------------------*/
  909.  
  910. HVMosaikOperator:
  911.     IF( ~EXISTS( "adpro:convolutions/Vertical" )) THEN DO
  912.         OKAY1 "The convolution Vertical," || NL ||,
  913.             "cannot be found."
  914.         EXIT
  915.     END
  916.     IF( ~EXISTS( "adpro:convolutions/Horizontal" )) THEN DO
  917.         OKAY1 "The convolution Horizontal," || NL ||,
  918.             "cannot be found."
  919.         EXIT
  920.     END
  921.  
  922.     XSIZE
  923.     XCoord = ADPRO_RESULT
  924.     YSIZE
  925.     YCoord = ADPRO_RESULT
  926.  
  927.     DO loop = 1 TO 2
  928.         OPERATOR "HALVE"
  929.     END
  930.  
  931.     OPERATOR "BLUR" 0 0
  932.     ABS_SCALE XCoord YCoord
  933.  
  934.     OPERATOR "CONVOLVE" "adpro:convolutions/Vertical" 100 0
  935.  
  936.     OPERATOR "CONVOLVE" "adpro:convolutions/Horizontal" 100 0
  937.  
  938. RETURN
  939. /*-----------------------------------------------------------*/
  940.  
  941. EmbossOperator:
  942.     TempImage = "T:TempImage"
  943.  
  944.     SAVE TempImage "RAW"
  945.     IF( RC ~= 0 ) THEN DO
  946.         ADPRO_TO_FRONT
  947.         OKAY1 "Saving copy of image failed." || NL ||,
  948.             "Argument Information:" || NL ||,
  949.             "Filename = " || TempImage || NL ||,
  950.             "Type = " || "RAW"
  951.         EXIT 10
  952.     END
  953.  
  954.     OPERATOR "NEGATIVE"
  955.  
  956.     IF EmbossFlag=1 then do               /* ---- Emboss out -----*/
  957.          LOAD TempImage (-1) (-1) 50
  958.         IF( RC ~= 0 ) THEN DO
  959.             OKAY1 "Error loading temp image."
  960.             EXIT
  961.         END
  962.     end
  963.  
  964.     ELSE DO                               /* ---- Emboss in -----*/
  965.         LOAD TempImage 1 1 50
  966.         IF( RC ~= 0 ) THEN DO
  967.             OKAY1 "Error loading temp image."
  968.             EXIT
  969.         END
  970.     end
  971.  
  972.     IF( RC ~= 0 ) THEN DO
  973.         ADPRO_TO_FRONT
  974.         OKAY1 "Reloading image failed." || NL ||,
  975.             "Argument Information:" || NL ||,
  976.             "X = " || 1 || NL ||,
  977.             "Y = " || 1 || NL ||,
  978.             "Mix = " || 50
  979.         EXIT
  980.     END
  981.  
  982.     IF( WORD( ImageType, 1 ) ~= "GRAY" ) THEN DO
  983.         OPERATOR "COLOR_TO_GRAY"
  984.         IF( RC ~= 0 ) THEN DO
  985.             OKAY1 "The operator COLOR_TO_GRAY," || NL ||,
  986.                 "failed to execute."
  987.             EXIT
  988.         END
  989.     END
  990.  
  991.     CONTRAST 50
  992.     OPERATOR "APPLY_MAP"
  993.     ADDRESS COMMAND "delete" TempImage
  994. RETURN
  995. /*-----------------------------------------------------------*/    
  996.  
  997. FrescoOperator:
  998.     IF( ~EXISTS( "adpro:convolutions/WoodCut" )) THEN DO
  999.         OKAY1 "The convolution WoodCut," || NL ||,
  1000.             "cannot be found."
  1001.         EXIT
  1002.     END
  1003.  
  1004.     DO loop = 1 TO 3
  1005.         IF( loop < 3 ) THEN
  1006.             OPERATOR "DISPLACE_PIXEL" 1 100 0
  1007.         ELSE
  1008.             OPERATOR "DISPLACE_PIXEL" 2 100 0
  1009.  
  1010.         OPERATOR "MEDIAN_FILTER" 0
  1011.     END
  1012.  
  1013.     OPERATOR "CONVOLVE" "adpro:convolutions/WoodCut" 100 0
  1014. RETURN
  1015. /*-----------------------------------------------------------*/    
  1016.  
  1017. RefractOperator:
  1018.     OPERATOR "REFRACT" "Pooldepth" Pooldepth "Refractindex" Refractindex "Filename" FileName
  1019. RETURN
  1020. /*-----------------------------------------------------------*/    
  1021.  
  1022. BalanceControl:
  1023.  
  1024. /*
  1025.     Algorythm to interpolate Entry and Exit values.
  1026. */
  1027.     
  1028.     if BalanceFlag ~= 999 then do             
  1029.         _Red       = (ABS(XRed) + ABS(ERed)) / diff
  1030.         _Green     = (ABS(XGreen) + ABS(EGreen)) / diff
  1031.         _Blue      = (ABS(XBlue) + ABS(EBlue)) / diff
  1032.         _Bright    = (ABS(XBright) + ABS(EBright)) / diff
  1033.         _Contrast  = (ABS(XContrast) + ABS(EContrast)) / diff
  1034.         _Gamma     = (ABS(XGamma) + ABS(EGamma)) / diff
  1035.         BalanceFlag  = 999
  1036.     end
  1037.  
  1038.     else do 
  1039.         ERed      = TRUNC(ERed + _Red)
  1040.         EGreen    = TRUNC(EGreen + _Green)
  1041.         EBlue     = TRUNC(EBlue + _Blue)
  1042.         EBright   = TRUNC(EBright + _Bright)
  1043.         EContrast = TRUNC(EContrast + _Contrast)
  1044.         EGamma    = TRUNC(EGamma + _Gamma)
  1045.     end
  1046.  
  1047.  
  1048.     Red         ERed
  1049.     Green         EGreen
  1050.     Blue         EBlue
  1051.     Brightness    EBright
  1052.     Contrast    EContrast
  1053.     Gamma        EGamma
  1054.  
  1055.     OPERATOR "APPLY_MAP"
  1056. RETURN
  1057. /*-----------------------------------------------------------*/    
  1058.  
  1059. /*
  1060.   Operator GUIs...
  1061. */
  1062.  
  1063. /* -------------------------------- */
  1064. RippleGUI:
  1065.  
  1066. host='RIPPLEHOST'
  1067. port='RIPPLEPORT'
  1068. IF replyport='' THEN DO
  1069.  DO i=1 WHILE SHOW('P',host||i)
  1070.  END
  1071.  host=host||i
  1072.  port=port||i
  1073. END
  1074. ELSE DO
  1075.  host=host'.'replyport
  1076.  port=port'.'replyport
  1077.  IF SHOW('P',port) THEN DO
  1078.   INTERPRET ADDRESS port FRONT
  1079.   EXIT(0)
  1080.  END
  1081. END
  1082.  
  1083. CALL setup_host()
  1084.  
  1085. w.=''
  1086. w.idcmp='CLOSEWINDOW+MENUPICK+GADGETUP+MOUSEBUTTONS'
  1087. w.flags='WINDOWCLOSE+WINDOWDRAG'
  1088.  
  1089. w.title='Ripple Operator Interface V1.0'
  1090. IF replyport~='' THEN w.title='Ripple Operator Interface V1.0'
  1091.  
  1092. pscreen='Workbench'
  1093. xmax=240
  1094. ymax=200
  1095. CALL OpenWindow(host,(ScreenCols(pscreen)-xmax)%2, ,
  1096.                      (ScreenRows(pscreen)-ymax)%2, ,
  1097.                      xmax,ymax,w.idcmp,w.flags,w.title)
  1098.  
  1099. /* -------- MENUES --------- */
  1100.  
  1101. CALL AddMenu(host,'Project')
  1102. CALL AddItem(host,'Start   ','OK','S')
  1103. CALL AddItem(host,'Quit    ','CLOSEWINDOW','Q')
  1104.  
  1105. CALL SetAPen(host,1)
  1106.  
  1107. /* ------ CenterX -------*/
  1108. CALL Move(host,10,36)
  1109. CALL Text(host,'Centerposition X')
  1110.  
  1111. CALL AddGadget(host,160,30,1,'CenterX','XXX||%g',70,RIDGEBORDER)
  1112.  
  1113. /* ------ CenterY -------*/
  1114. CALL Move(host,10,52)
  1115. CALL Text(host,'Centerposition Y')
  1116.  
  1117. CALL AddGadget(host,160,46,2,'CenterY','YYY||%g',70,RIDGEBORDER)
  1118.  
  1119. /* ------ Propspeed -------*/
  1120. CALL Move(host,10,68)
  1121. CALL Text(host,'Propspeed (1..5000)')
  1122.  
  1123. CALL AddGadget(host,180,62,3,'20','PRO||%g',50,RIDGEBORDER)
  1124.  
  1125. /* ------ Period -------*/
  1126. CALL Move(host,10,84)
  1127. CALL Text(host,'Period (3..5000)')
  1128.  
  1129. CALL AddGadget(host,180,78,4,'10','PER||%g',50,RIDGEBORDER)
  1130.  
  1131. /* ------ Amplitude -------*/
  1132. CALL Move(host,10,100)
  1133. CALL Text(host,'Amplitude (1.0..500)')
  1134.  
  1135. CALL AddGadget(host,180,94,5,'15','AMP||%g',50,RIDGEBORDER)
  1136.  
  1137. /* ------ Ramp -------*/
  1138. CALL Move(host,10,116)
  1139. CALL Text(host,'Ramp (0.0..1000.0)')
  1140.  
  1141. CALL AddGadget(host,180,110,6,'0','RMP||%g',50,RIDGEBORDER)
  1142.  
  1143. /* ------ Leveloff -------*/
  1144. CALL Move(host,10,132)
  1145. CALL Text(host,'Leveloff (0..1000)')
  1146.  
  1147. CALL AddGadget(host,180,126,7,'0','LEV||%g',50,RIDGEBORDER)
  1148.  
  1149. /* ------ Wavetype -------*/
  1150. CALL Move(host,10,148)
  1151. CALL Text(host,'Wavetype (-1,0,1)')
  1152.  
  1153. CALL AddGadget(host,180,142,8,'0','WAV||%g',50,RIDGEBORDER)
  1154.  
  1155. /* ------ Frame -------*/
  1156. CALL Move(host,10,164)
  1157. CALL Text(host,'Frame (-10000..10000)')
  1158.  
  1159. CALL AddGadget(host,180,158,9,'20','FRM||%g',50,RIDGEBORDER)
  1160.  
  1161.  
  1162. CALL AddGadget(host,11,ymax-16,98,'START CONVERTING','OK')
  1163. CALL AddGadget(host,xmax-64,ymax-16,99,'CANCEL','CLOSEWINDOW')
  1164. CALL AddGadget(host,153,ymax-16,100,'!','ALERT')
  1165.  
  1166. CALL tofront()
  1167.  
  1168. Defaults:
  1169.     XPos      = 'CenterX'
  1170.     YPos      = 'CenterY'
  1171.     Speed     = 20
  1172.     Period    = 10
  1173.     Amplitude = 15
  1174.     Ramp      = 0
  1175.     Leveloff  = 0
  1176.     Wavetype  = 0
  1177.     Frame     = 20
  1178.  
  1179.  
  1180. quitflag = 0
  1181. CALL ActivateGadget(host,1)
  1182.  
  1183. startripple:
  1184. do forever
  1185.   if quitflag=1 then leave
  1186.   t = waitpkt(port)  
  1187.   do forever
  1188.       p = getpkt(port)
  1189.       if c2d(p) = 0 then leave
  1190.  
  1191.       arg = getarg(p,0)
  1192.       t = reply(p, 0)
  1193.  
  1194.       if arg=CLOSEWINDOW then do
  1195.         CALL CloseWindow(host)
  1196.     EXIT
  1197.       end 
  1198.  
  1199.       if LEFT(arg,3)='XXX' THEN do
  1200.         XPos      = RIGHT(arg,LENGTH(arg)-5)  
  1201.         CALL ActivateGadget(host,2)
  1202.       end
  1203.       if LEFT(arg,3)='YYY' THEN do
  1204.         YPos      = RIGHT(arg,LENGTH(arg)-5)
  1205.         CALL ActivateGadget(host,3)
  1206.       end
  1207.       if LEFT(arg,3)='PRO' THEN do
  1208.         Speed     = RIGHT(arg,LENGTH(arg)-5)
  1209.         CALL ActivateGadget(host,4)
  1210.       end
  1211.       if LEFT(arg,3)='PER' THEN do
  1212.         Period    = RIGHT(arg,LENGTH(arg)-5)
  1213.         CALL ActivateGadget(host,5)
  1214.       end
  1215.       if LEFT(arg,3)='AMP' THEN do
  1216.         Amplitude = RIGHT(arg,LENGTH(arg)-5)   
  1217.         CALL ActivateGadget(host,6)
  1218.       end
  1219.       if LEFT(arg,3)='RMP' THEN do
  1220.         Ramp      = RIGHT(arg,LENGTH(arg)-5)  
  1221.         CALL ActivateGadget(host,7)
  1222.       end
  1223.       if LEFT(arg,3)='LEV' THEN do
  1224.         Leveloff  = RIGHT(arg,LENGTH(arg)-5)
  1225.         CALL ActivateGadget(host,8)
  1226.       end
  1227.       if LEFT(arg,3)='WAV' THEN do
  1228.         Wavetype  = RIGHT(arg,LENGTH(arg)-5)
  1229.         CALL ActivateGadget(host,9)
  1230.       end
  1231.       if LEFT(arg,3)='FRM' THEN Frame     = RIGHT(arg,LENGTH(arg)-5)
  1232.  
  1233.       if arg='ALERT' then do
  1234.     ADPRO_TO_FRONT
  1235.     okay1 "If Wavetype -1 (decrease) or" || NL ||,
  1236.           "1 (increase) is selected, RAMP" || NL ||,
  1237.           "and LEVELOFF must be set" || NL ||,
  1238.           "higher than 0 otherwhise it" || NL ||,
  1239.           "will not work."
  1240.     ADPRO_TO_BACK
  1241.        end
  1242.  
  1243.       if arg=OK THEN DO
  1244.         CALL CloseWindow(host)
  1245.     RETURN    
  1246.       end    
  1247.   end
  1248. END     
  1249. RETURN
  1250.  
  1251. /* -------------------------------- */
  1252.  
  1253. TwirlGUI:
  1254.  
  1255. host='TWIRLHOST'
  1256. port='TWIRLEPORT'
  1257. IF replyport='' THEN DO
  1258.  DO i=1 WHILE SHOW('P',host||i)
  1259.  END
  1260.  host=host||i
  1261.  port=port||i
  1262. END
  1263. ELSE DO
  1264.  host=host'.'replyport
  1265.  port=port'.'replyport
  1266.  IF SHOW('P',port) THEN DO
  1267.   INTERPRET ADDRESS port FRONT
  1268.   EXIT(0)
  1269.  END
  1270. END
  1271.  
  1272. CALL setup_host()
  1273.  
  1274. w.=''
  1275. w.idcmp='CLOSEWINDOW+MENUPICK+GADGETUP+MOUSEBUTTONS'
  1276. w.flags='WINDOWCLOSE+WINDOWDRAG'
  1277.  
  1278. w.title='Twirl Operator Interface V1.0'
  1279. IF replyport~='' THEN w.title='Twirl Operator Interface V1.0'
  1280.  
  1281. pscreen='Workbench'
  1282. xmax=492
  1283. ymax=150
  1284. CALL OpenWindow(host,(ScreenCols(pscreen)-xmax)%2, ,
  1285.                      (ScreenRows(pscreen)-ymax)%2, ,
  1286.                      xmax,ymax,w.idcmp,w.flags,w.title)
  1287.  
  1288.  
  1289. /* -------- MENUES --------- */
  1290.  
  1291. CALL AddMenu(host,'Project')
  1292. CALL AddItem(host,'Start   ','OK','S')
  1293. CALL AddItem(host,'Quit    ','CLOSEWINDOW','Q')
  1294.  
  1295. CALL box(host,2,1,6,17,230,110)
  1296. CALL box(host,1,1,10,21,223,13)
  1297.  
  1298. CALL box(host,2,1,255,17,230,110)
  1299. CALL box(host,1,1,259,21,223,13)
  1300.  
  1301. CALL SetAPen(host,2)
  1302. CALL Move(host,100,30)
  1303. CALL Text(host,'Entry')
  1304.                       
  1305. CALL Move(host,350,30)
  1306. CALL Text(host,'Exit')
  1307.  
  1308. CALL SetAPen(host,1)
  1309.  
  1310. /* ------- ENTRY --------*/
  1311.  
  1312. /* ------ CenterX -------*/
  1313. CALL Move(host,10,56)
  1314. CALL Text(host,'Centerposition X')
  1315.  
  1316. CALL AddGadget(host,160,50,1,'CenterX','EXX||%g',70,RIDGEBORDER)
  1317.  
  1318. /* ------ Center Y -------*/
  1319. CALL Move(host,10,72)
  1320. CALL Text(host,'Centerposition Y')
  1321.  
  1322. CALL AddGadget(host,160,66,2,'CenterY','EYY||%g',70,RIDGEBORDER)
  1323.  
  1324. /* ------ Radius -------*/
  1325. CALL Move(host,10,88)
  1326. CALL Text(host,'Radius (5..15000)')
  1327.  
  1328. CALL AddGadget(host,180,82,3,'Image','ERR||%g',50,RIDGEBORDER)
  1329.  
  1330. /* ------ Amount -------*/
  1331. CALL Move(host,10,104)
  1332. CALL Text(host,'Amount (-360..360°)')
  1333.  
  1334. CALL AddGadget(host,180,98,4,'360','EAA||%g',50,RIDGEBORDER)
  1335.  
  1336. /* ------ BlurRadius -------*/
  1337. CALL Move(host,10,120)
  1338. CALL Text(host,'Blur Radius (0..99%)')
  1339.  
  1340. CALL AddGadget(host,180,114,5,'30','EBB||%g',50,RIDGEBORDER)
  1341.  
  1342.  
  1343. /* -------- EXIT --------*/
  1344.  
  1345. /* ------ CenterX -------*/
  1346. CALL Move(host,260,56)
  1347. CALL Text(host,'Centerposition X')
  1348.  
  1349. CALL AddGadget(host,410,50,6,'CenterX','XXX||%g',70,RIDGEBORDER)
  1350.  
  1351. /* ------ Center Y -------*/
  1352. CALL Move(host,260,72)
  1353. CALL Text(host,'Centerposition Y')
  1354.  
  1355. CALL AddGadget(host,410,66,7,'CenterY','XYY||%g',70,RIDGEBORDER)
  1356.  
  1357. /* ------ Radius -------*/
  1358. CALL Move(host,260,88)
  1359. CALL Text(host,'Radius (5..15000)')
  1360.     
  1361. CALL AddGadget(host,430,82,8,'Image','XRR||%g',50,RIDGEBORDER)
  1362.  
  1363. /* ------ Amount -------*/
  1364. CALL Move(host,260,104)
  1365. CALL Text(host,'Amount (-360..360°)')
  1366.  
  1367. CALL AddGadget(host,430,98,9,'360','XAA||%g',50,RIDGEBORDER)
  1368.  
  1369. /* ------ BlurRadius -------*/
  1370. CALL Move(host,260,120)
  1371. CALL Text(host,'Blur Radius (0..99%)')
  1372.  
  1373. CALL AddGadget(host,430,114,10,'30','XBB||%g',50,RIDGEBORDER)
  1374.  
  1375. /* -------------------------*/
  1376.  
  1377. CALL AddGadget(host,11,ymax-16,98,'START CONVERTING','OK')
  1378. CALL AddGadget(host,xmax-64,ymax-16,99,'CANCEL','CLOSEWINDOW')
  1379.  
  1380. CALL tofront()
  1381.  
  1382. Defaults:
  1383.     EWidth      = 'CenterX'
  1384.     EHight      = 'CenterY'
  1385.     ERadius     = 'Image'
  1386.     EAmount     = 360
  1387.     EBlurRadius = 30
  1388.  
  1389.     XWidth      = 'CenterX'
  1390.     XHight      = 'CenterY'
  1391.     XRadius     = 'Image'
  1392.     XAmount     = 360
  1393.     XBlurRadius = 30
  1394.  
  1395.  
  1396. quitflag = 0
  1397. CALL ActivateGadget(host,1)
  1398.  
  1399. starttwirl:
  1400. do forever
  1401.   if quitflag=1 then leave
  1402.   t = waitpkt(port)  
  1403.   do forever
  1404.       p = getpkt(port)
  1405.       if c2d(p) = 0 then leave
  1406.  
  1407.       arg = getarg(p,0)
  1408.       t = reply(p, 0)
  1409.  
  1410.       /* ENTRY */
  1411.       if LEFT(arg,3)='EXX' THEN do
  1412.         EWidth      = RIGHT(arg,LENGTH(arg)-5)  
  1413.         CALL ActivateGadget(host,2)
  1414.       end
  1415.       if LEFT(arg,3)='EYY' THEN do
  1416.         EHight      = RIGHT(arg,LENGTH(arg)-5)
  1417.         CALL ActivateGadget(host,3)
  1418.       end
  1419.       if LEFT(arg,3)='ERR' THEN do
  1420.         ERadius     = RIGHT(arg,LENGTH(arg)-5)
  1421.         CALL ActivateGadget(host,4)
  1422.       end
  1423.       if LEFT(arg,3)='EAA' THEN do
  1424.         EAmount     = RIGHT(arg,LENGTH(arg)-5)
  1425.         CALL ActivateGadget(host,5)
  1426.       end
  1427.       if LEFT(arg,3)='EBB' THEN do
  1428.         EBlurRadius = RIGHT(arg,LENGTH(arg)-5)   
  1429.         CALL ActivateGadget(host,6)
  1430.       end
  1431.  
  1432.       /* EXIT */
  1433.       if LEFT(arg,3)='XXX' THEN do
  1434.         XWidth      = RIGHT(arg,LENGTH(arg)-5)  
  1435.         CALL ActivateGadget(host,7)
  1436.       end
  1437.       if LEFT(arg,3)='XYY' THEN do
  1438.         XHight      = RIGHT(arg,LENGTH(arg)-5)
  1439.         CALL ActivateGadget(host,8)
  1440.       end
  1441.       if LEFT(arg,3)='XRR' THEN do
  1442.         XRadius     = RIGHT(arg,LENGTH(arg)-5)
  1443.         CALL ActivateGadget(host,9)
  1444.       end
  1445.       if LEFT(arg,3)='XAA' THEN do
  1446.         XAmount     = RIGHT(arg,LENGTH(arg)-5)
  1447.         CALL ActivateGadget(host,10)
  1448.       end
  1449.       if LEFT(arg,3)='XBB' THEN XBlurRadius = RIGHT(arg,LENGTH(arg)-5)    
  1450.  
  1451.       if arg=CLOSEWINDOW then do
  1452.         CALL CloseWindow(host)
  1453.     EXIT
  1454.       end 
  1455.  
  1456.       if arg=OK THEN DO
  1457.         CALL CloseWindow(host)
  1458.     RETURN    
  1459.       end
  1460.   end
  1461. END     
  1462. RETURN
  1463.  
  1464. /* -------------------------------- */
  1465.  
  1466. EmbossGUI:
  1467. ADPRO_TO_FRONT
  1468.  
  1469. Okay2 "Select direction to emboss:" || NL ||,
  1470.       "OK=Emboss in   Cancel=Emboss out"
  1471. if RC=0 then EmbossFlag=1
  1472. else EmbossFlag=0
  1473.  
  1474. RETURN
  1475.  
  1476. /* -------------------------------- */
  1477.  
  1478. BlurGUI:
  1479.  
  1480. ADPRO_TO_FRONT
  1481.  
  1482. GETNUMBER '"Enter Center Weight:"' 1 0 16
  1483. CW = ADPRO_RESULT
  1484.  
  1485. GETNUMBER '"Enter Threshold:"' 0 0 255
  1486. TH = ADPRO_RESULT 
  1487.  
  1488. RETURN
  1489.  
  1490. /* -------------------------------- */
  1491.  
  1492. RefractGUI:
  1493.  
  1494. host='REFRACTHOST'
  1495. port='REFRACTPORT'
  1496. IF replyport='' THEN DO
  1497.  DO i=1 WHILE SHOW('P',host||i)
  1498.  END
  1499.  host=host||i
  1500.  port=port||i
  1501. END
  1502. ELSE DO
  1503.  host=host'.'replyport
  1504.  port=port'.'replyport
  1505.  IF SHOW('P',port) THEN DO
  1506.   INTERPRET ADDRESS port FRONT
  1507.   EXIT(0)
  1508.  END
  1509. END
  1510.  
  1511. CALL setup_host()
  1512.  
  1513. w.=''
  1514. w.idcmp='CLOSEWINDOW+MENUPICK+GADGETUP+MOUSEBUTTONS'
  1515. w.flags='WINDOWCLOSE+WINDOWDRAG'
  1516.  
  1517. w.title='Refract Operator Interface V1.0'
  1518. IF replyport~='' THEN w.title='Refract Operator Interface V1.0'
  1519.  
  1520. pscreen='Workbench'
  1521. xmax=300
  1522. ymax=80
  1523. CALL OpenWindow(host,(ScreenCols(pscreen)-xmax)%2, ,
  1524.                      (ScreenRows(pscreen)-ymax)%2, ,
  1525.                      xmax,ymax,w.idcmp,w.flags,w.title)
  1526.  
  1527.  
  1528. /* -------- MENUES --------- */
  1529.  
  1530. CALL AddMenu(host,'Project')
  1531. CALL AddItem(host,'Start   ','OK','S')
  1532. CALL AddItem(host,'Quit    ','CLOSEWINDOW','Q')
  1533.  
  1534. CALL SetAPen(host,1)
  1535.  
  1536. /* ------ PoolDepth -------*/
  1537. CALL Move(host,10,30)
  1538. CALL Text(host,'Pool Depth (1.0..500.0)')
  1539.  
  1540. CALL AddGadget(host,238,23,1,'50','PDH||%g',50,RIDGEBORDER)
  1541.  
  1542. /* ------ Refraction Index -------*/
  1543. CALL Move(host,10,50)
  1544. CALL Text(host,'Refraction Index (1.0..10.0)')
  1545.  
  1546. CALL AddGadget(host,248,43,2,'1.3','RCT||%g',40,RIDGEBORDER)
  1547.  
  1548. /* -------------------------*/
  1549.  
  1550. CALL AddGadget(host,11,ymax-16,98,'START CONVERTING','OK')
  1551. CALL AddGadget(host,xmax-64,ymax-16,99,'CANCEL','CLOSEWINDOW')
  1552. CALL AddGadget(host,180,ymax-16,100,'!','ALERT')
  1553.  
  1554. CALL tofront()
  1555.  
  1556. POOLDEPTH    = 50
  1557. REFRACTINDEX = 1.3
  1558.  
  1559.  
  1560.  
  1561. quitflag = 0
  1562. CALL ActivateGadget(host,1)
  1563.  
  1564. startrefract:
  1565. do forever
  1566.   if quitflag=1 then leave
  1567.   t = waitpkt(port)  
  1568.   do forever
  1569.       p = getpkt(port)
  1570.       if c2d(p) = 0 then leave
  1571.  
  1572.       arg = getarg(p,0)
  1573.       t = reply(p, 0)
  1574.  
  1575.       
  1576.       if LEFT(arg,3)='PDH' THEN do
  1577.         POOLDEPTH    = RIGHT(arg,LENGTH(arg)-5)  
  1578.         CALL ActivateGadget(host,2)
  1579.       end
  1580.       if LEFT(arg,3)='RCT' THEN REFRACTINDEX = RIGHT(arg,LENGTH(arg)-5)
  1581.  
  1582.       if arg=CLOSEWINDOW then do
  1583.         CALL CloseWindow(host)
  1584.     EXIT
  1585.       end 
  1586.  
  1587.       if arg='ALERT' then do
  1588.     ADPRO_TO_FRONT
  1589.     okay1 "Refraction picture must have" || NL ||,
  1590.           "same size as source pic(s)!"
  1591.     ADPRO_TO_BACK
  1592.       end
  1593.  
  1594.       if arg=OK THEN DO
  1595.         CALL CloseWindow(host)
  1596.     ADPRO_TO_FRONT
  1597.     GETFILE '"Select a file to refract"'
  1598.     filename=ADPRO_RESULT
  1599.     if RC ~= 0 then do
  1600.        Okay1 "There is no picture" || NL ||,
  1601.              "to refract!"
  1602.            exit 
  1603.      end
  1604.        RETURN
  1605.       end
  1606.   end
  1607. END     
  1608. RETURN
  1609.  
  1610. /* -------------------------------- */
  1611.  
  1612. BalanceGUI:
  1613.  
  1614. host='BALANCEHOST'
  1615. port='BALANCEPORT'
  1616. IF replyport='' THEN DO
  1617.  DO i=1 WHILE SHOW('P',host||i)
  1618.  END
  1619.  host=host||i
  1620.  port=port||i
  1621. END
  1622. ELSE DO
  1623.  host=host'.'replyport
  1624.  port=port'.'replyport
  1625.  IF SHOW('P',port) THEN DO
  1626.   INTERPRET ADDRESS port FRONT
  1627.   EXIT(0)
  1628.  END
  1629. END
  1630.  
  1631. CALL setup_host()
  1632.  
  1633. w.=''
  1634. w.idcmp='CLOSEWINDOW+MENUPICK+GADGETUP+MOUSEBUTTONS'
  1635. w.flags='WINDOWCLOSE+WINDOWDRAG'
  1636.  
  1637. w.title='Balancing Control'
  1638. IF replyport~='' THEN w.title='Balancing Control'
  1639.  
  1640. pscreen='Workbench'
  1641. xmax=492
  1642. ymax=170
  1643. CALL OpenWindow(host,(ScreenCols(pscreen)-xmax)%2, ,
  1644.                      (ScreenRows(pscreen)-ymax)%2, ,
  1645.                      xmax,ymax,w.idcmp,w.flags,w.title)
  1646.  
  1647.  
  1648. /* -------- MENUES --------- */
  1649.  
  1650. CALL AddMenu(host,'Project')
  1651. CALL AddItem(host,'Start   ','OK','S')
  1652. CALL AddItem(host,'Quit    ','CLOSEWINDOW','Q')
  1653.  
  1654. CALL SetAPen(host,1)
  1655.  
  1656. CALL box(host,2,1,6,17,230,130)
  1657. CALL box(host,1,1,10,21,223,13)
  1658.  
  1659. CALL box(host,2,1,255,17,230,130)
  1660. CALL box(host,1,1,259,21,223,13)
  1661.  
  1662. CALL SetAPen(host,2)
  1663. CALL Move(host,100,30)
  1664. CALL Text(host,'Entry')
  1665.                       
  1666. CALL Move(host,350,30)
  1667. CALL Text(host,'Exit')
  1668.  
  1669. CALL SetAPen(host,1)
  1670.  
  1671. /* ------- ENTRY --------*/
  1672.  
  1673. /* ------ Red -------*/
  1674. CALL Move(host,10,56)
  1675. CALL Text(host,'Red Adjust   (-50..50)')
  1676.  
  1677. CALL AddGadget(host,200,50,1,'0','ERR||%g',30,RIDGEBORDER)
  1678.  
  1679. /* ------ Green -------*/
  1680. CALL Move(host,10,72)
  1681. CALL Text(host,'Green Adjust (-50..50)')
  1682.  
  1683. CALL AddGadget(host,200,66,2,'0','EGG||%g',30,RIDGEBORDER)
  1684.  
  1685. /* ------ Blue -------*/
  1686. CALL Move(host,10,88)
  1687. CALL Text(host,'Blue Adjust  (-50..50)')
  1688.  
  1689. CALL AddGadget(host,200,82,3,'0','EBB||%g',30,RIDGEBORDER)
  1690.  
  1691. /* ------ Brightness -------*/
  1692. CALL Move(host,10,104)
  1693. CALL Text(host,'Brightness   (-50..50)')
  1694.  
  1695. CALL AddGadget(host,200,98,4,'0','EBR||%g',30,RIDGEBORDER)
  1696.  
  1697. /* ------ Contrast -------*/
  1698. CALL Move(host,10,120)
  1699. CALL Text(host,'Contrast     (-50..50)')
  1700.  
  1701. CALL AddGadget(host,200,114,5,'0','ECC||%g',30,RIDGEBORDER)
  1702.  
  1703. /* ------ Gamma -------*/
  1704. CALL Move(host,10,136)
  1705. CALL Text(host,'Gamma        (-50..50)')
  1706.  
  1707. CALL AddGadget(host,200,130,6,'0','EGM||%g',30,RIDGEBORDER)
  1708.  
  1709.  
  1710. /* -------- EXIT --------*/
  1711.  
  1712. /* ------ Red -------*/
  1713. CALL Move(host,260,56)
  1714. CALL Text(host,'Red Adjust   (-50..50)')
  1715.  
  1716. CALL AddGadget(host,450,50,7,'0','XRR||%g',30,RIDGEBORDER)
  1717.  
  1718. /* ------ Green -------*/
  1719. CALL Move(host,260,72)
  1720. CALL Text(host,'Green Adjust (-50..50)')
  1721.  
  1722. CALL AddGadget(host,450,66,8,'0','XGG||%g',30,RIDGEBORDER)
  1723.  
  1724. /* ------ Blue -------*/
  1725. CALL Move(host,260,88)
  1726. CALL Text(host,'Blue Adjust  (-50..50)')
  1727.  
  1728. CALL AddGadget(host,450,82,9,'0','XBB||%g',30,RIDGEBORDER)
  1729.  
  1730. /* ------ Brightness -------*/
  1731. CALL Move(host,260,104)
  1732. CALL Text(host,'Brightness   (-50..50)')
  1733.  
  1734. CALL AddGadget(host,450,98,10,'0','XBR||%g',30,RIDGEBORDER)
  1735.  
  1736. /* ------ Contrast -------*/
  1737. CALL Move(host,260,120)
  1738. CALL Text(host,'Contrast     (-50..50)')
  1739.  
  1740. CALL AddGadget(host,450,114,11,'0','XCC||%g',30,RIDGEBORDER)
  1741.  
  1742. /* ------ Gamma -------*/
  1743. CALL Move(host,260,136)
  1744. CALL Text(host,'Gamma        (-50..50)')
  1745.  
  1746. CALL AddGadget(host,450,130,12,'0','XGM||%g',30,RIDGEBORDER)
  1747.  
  1748. /* -------------------------*/
  1749.  
  1750. CALL AddGadget(host,11,ymax-16,98,'START CONVERTING','OK')
  1751. CALL AddGadget(host,xmax-64,ymax-16,99,'CANCEL','CLOSEWINDOW')
  1752.  
  1753. CALL tofront()
  1754.  
  1755. Defaults:
  1756.     ERed      = 0
  1757.     EGreen    = 0
  1758.     EBlue     = 0
  1759.     EBright   = 0
  1760.     EContrast = 0
  1761.     EGamma    = 0
  1762.  
  1763.     XRed      = 0
  1764.     XGreen    = 0
  1765.     XBlue     = 0
  1766.     XBright   = 0
  1767.     XContrast = 0
  1768.     XGamma    = 0
  1769.  
  1770. /* -------------------------*/
  1771.  
  1772. quitflag = 0
  1773. CALL ActivateGadget(host,1)
  1774.  
  1775. do forever
  1776.   if quitflag=1 then leave
  1777.   t = waitpkt(port)  
  1778.   do forever
  1779.       p = getpkt(port)
  1780.       if c2d(p) = 0 then leave
  1781.  
  1782.       arg = getarg(p,0)
  1783.       t = reply(p, 0)
  1784.  
  1785.       /* ENTRY */
  1786.       if LEFT(arg,3)='ERR' THEN do
  1787.         ERed      = RIGHT(arg,LENGTH(arg)-5)  
  1788.         CALL ActivateGadget(host,2)
  1789.       end
  1790.       if LEFT(arg,3)='EGG' THEN do
  1791.         EGreen    = RIGHT(arg,LENGTH(arg)-5)
  1792.         CALL ActivateGadget(host,3)
  1793.       end
  1794.       if LEFT(arg,3)='EBB' THEN do
  1795.         EBlue     = RIGHT(arg,LENGTH(arg)-5)
  1796.         CALL ActivateGadget(host,4)
  1797.       end
  1798.       if LEFT(arg,3)='EBR' THEN do
  1799.         EBright   = RIGHT(arg,LENGTH(arg)-5)
  1800.         CALL ActivateGadget(host,5)
  1801.       end
  1802.       if LEFT(arg,3)='ECC' THEN do
  1803.         EContrast = RIGHT(arg,LENGTH(arg)-5)   
  1804.         CALL ActivateGadget(host,6)
  1805.       end
  1806.       if LEFT(arg,3)='EGM' THEN do
  1807.         EGamma    = RIGHT(arg,LENGTH(arg)-5)    
  1808.         CALL ActivateGadget(host,7)
  1809.       end
  1810.  
  1811.       /* EXIT */
  1812.       if LEFT(arg,3)='XRR' THEN do
  1813.         XRed      = RIGHT(arg,LENGTH(arg)-5)  
  1814.         CALL ActivateGadget(host,8)
  1815.       end
  1816.       if LEFT(arg,3)='XGG' THEN do
  1817.         XGreen    = RIGHT(arg,LENGTH(arg)-5)
  1818.         CALL ActivateGadget(host,9)
  1819.       end
  1820.       if LEFT(arg,3)='XBB' THEN do
  1821.         XBlue     = RIGHT(arg,LENGTH(arg)-5)
  1822.         CALL ActivateGadget(host,10)
  1823.       end
  1824.       if LEFT(arg,3)='XBR' THEN do
  1825.         XBright   = RIGHT(arg,LENGTH(arg)-5)
  1826.         CALL ActivateGadget(host,11)
  1827.       end
  1828.       if LEFT(arg,3)='XCC' THEN do
  1829.         XContrast = RIGHT(arg,LENGTH(arg)-5)  
  1830.         CALL ActivateGadget(host,12)
  1831.       end
  1832.       if LEFT(arg,3)='XGM' THEN XGamma    = RIGHT(arg,LENGTH(arg)-5)
  1833.  
  1834.       if arg=CLOSEWINDOW then do
  1835.         CALL CloseWindow(host)
  1836.     EXIT
  1837.       end 
  1838.  
  1839.       if arg=OK THEN DO
  1840.         CALL CloseWindow(host)
  1841.       RETURN
  1842.       end
  1843.   end
  1844. END     
  1845. RETURN
  1846.  
  1847.  
  1848.  
  1849. /*
  1850.   remove all waiting messages from a port.
  1851. */
  1852.  
  1853. clearport:
  1854. PARSE ARG portname
  1855. p=1
  1856. DO FOREVER
  1857.   p=GETPKT(portname)
  1858.   IF p='0000 0000'x THEN RETURN
  1859.   t=REPLY(p,0)
  1860. END
  1861. RETURN
  1862.  
  1863.  
  1864. tofront:
  1865.   CALL ActivateWindow(host)
  1866.   CALL WindowToFront(host)
  1867.   CALL ScreenToFront(pscreen)
  1868. RETURN
  1869.  
  1870. /*
  1871.   Drawing a 3D rectangle...
  1872. */
  1873.  
  1874. box:
  1875.   ARG boxhost,pen1,pen2,upleft,uptop,width,height
  1876.   CALL SetAPen(boxhost,pen2)
  1877.   CALL Move(boxhost,upleft+width+1,uptop)
  1878.   CALL Draw(boxhost,upleft+width+1,uptop+height)
  1879.   CALL Draw(boxhost,upleft-1,uptop+height)
  1880.   CALL Move(boxhost,upleft+width,uptop+1)
  1881.   CALL Draw(boxhost,upleft+width,uptop+height)
  1882.   CALL SetAPen(boxhost,pen1)
  1883.   CALL Move(boxhost,upleft,uptop)
  1884.   CALL Draw(boxhost,upleft+width,uptop)
  1885.   CALL Move(boxhost,upleft,uptop+height-1)
  1886.   CALL Draw(boxhost,upleft,uptop)
  1887.   CALL Move(boxhost,upleft-1,uptop)
  1888.   CALL Draw(boxhost,upleft-1,uptop+height)
  1889. RETURN
  1890.  
  1891.  
  1892.  
  1893. /*
  1894.   Creates a place where messages can be recieved by rexxarplib
  1895.   and acted upon.
  1896. */
  1897.  
  1898. setup_host:
  1899.   CALL OPENPORT(port)
  1900.   ADDRESS AREXX "'x=CreateHost("host","port","pscreen")'"
  1901.   DO 200 WHILE ~SHOW('Ports',host)
  1902.     CALL DELAY 10  /* 200 ms */
  1903.   END
  1904.   IF ~SHOW('Ports',host) THEN
  1905.     CALL ALL_DONE('Could not open host 'host'.')
  1906.   IF ~SHOW('Ports',port) THEN
  1907.     CALL ALL_DONE('Could not open port 'port'.')
  1908. RETURN
  1909.  
  1910. /*
  1911.   initialize
  1912. */
  1913.  
  1914. setup_variables:
  1915.             success=open(PrefsFile,'ADProScripts:F0.config','R')
  1916.         if success=0 then CALL DefaultSettings()
  1917.         else do
  1918.             flag=0
  1919.             flag1=0
  1920.             LockedItemFlag=readln(PrefsFile)
  1921.             RequesterItemFlag=readln(PrefsFile)
  1922.             IMAGELOADFORMAT=readln(PrefsFile)
  1923.             IMAGESAVEFORMAT=readln(PrefsFile)
  1924.             ABSSC_X=readln(PrefsFile)
  1925.             ABSSC_Y=readln(PrefsFile)
  1926.             DITHERING=readln(PrefsFile)
  1927.             HIRES=readln(PrefsFile)
  1928.             INTERLACE=readln(PrefsFile)
  1929.             HOVERSCAN=readln(PrefsFile)
  1930.             VOVERSCAN=readln(PrefsFile)
  1931.             OPERATORNAME=readln(PrefsFile)
  1932.             COLORNR=readln(PrefsFile)    
  1933.             success=close(PrefsFile)
  1934.         end
  1935. RETURN
  1936.  
  1937. DefaultSettings:
  1938.  IMAGELOADFORMAT='UNIVERSAL'
  1939.  IMAGESAVEFORMAT='IFF'
  1940.  ABSSC_X=-1
  1941.  ABSSC_Y=-1
  1942.  DITHERING=0
  1943.  HIRES=0
  1944.  INTERLACE=0
  1945.  HOVERSCAN=0
  1946.  VOVERSCAN=0
  1947.  OPERATORNAME='NONE'
  1948.  COLORNR='HAM'
  1949.  LockedItemFlag=1
  1950.  RequesterItemFlag=1
  1951.  flag=0
  1952.  flag1=0
  1953. RETURN
  1954. /*  */
  1955.