****************************************************************************** * * * Frequent AREXX Routines * * * * Belongs To The Scripti Collection * * * * By Jan Van Overbeke, 3-DEE * * * * Read The Doc Concerning The Scripti Collection For Info About Rights * * * ****************************************************************************** ------------------------------------------------------------------------------ INTRO ------------------------------------------------------------------------------ In this dosument, you can see some AREXX routines related to graphics and ADPro. If you think you can do these routines faster, shorter or better, please understand there may be many ways to write a program, but my main purpose is that everyone would understand it. So, take the following as an example, they are used in one of my scripts here and there. ------------------------------------------------------------------------------ POWERPACKED ------------------------------------------------------------------------------ A powerpacked image can be recognised by doing this: /* start */ open('inputter',filename,'R') test=readln('inputter') close('inputter') if test='PP20' then do end else do end So.... what to do when it is powerpacked? You'll have to unpack it =:*] You have two possibilities: buy 'PowerPacker4.3b' (or higher) or get 'PPDO'. The first is commercial, the latter is Freeware. You can figure out the rest if you choose the first. The latter can only crunch/decrunch data-files. I use PPDO this way: /* entering program again */ if test='PP20' then address command 'c:PPDO BEST DECRUNCH 'filename If it isn't powerpacked, you'll probably do nothing. ------------------------------------------------------------------------------ 24BIT ------------------------------------------------------------------------------ If you want to know if an image is saved in 24Bit-format, you can recognize it like this: /* start */ arg filename options results address 'ADPro' lformat 'UNIVERSAL' load filename /* watch this! */ IMAGE help=ADPRO_RESULT if pos('RENDERED',help)=0|pos('BITPLANE',help=0) then do end else do end Question is: why would you want to know whether it is 24Bit? Well, Suppose you want to save it in the same format you loaded it. If so and you loaded a 24Bit-image, you don't need to call EXECUTE This command renders an Amiga IFF image, which is not necessary. ------------------------------------------------------------------------------ GRAY ------------------------------------------------------------------------------ Gray images are a real pest. Especially if want to do some composition. If you have a gray image in ADPro's memory, you won't be able to load another image over the current. To check, do this: /* start */ arg filename options results address 'ADPro' lformat 'UNIVERSAL' load filename /* watch this! */ IMAGE help=ADPRO_RESULT if pos('GRAY',help)~=0 then do end else do end You may need to know this for something else then to load with composition mode, but mostly you won't. If you want to load a second image in composition-mode, call this: /* going on */ if pos('GRAY',help)~=0 then operator GRAY_TO_COLOR /* now you can.... */ load 'ram:what?' 0 0 100 0 0 0 /* without any problem */ ------------------------------------------------------------------------------ PALETTE ------------------------------------------------------------------------------ Suppose we want to convert any image to IFF with AREXX, so we won't have to trigger all the switches.... The palette must always be right to get optimum results. /* start */ PARSE arg filename mode options results address 'ADPro' lformat 'UNIVERSAL' load filename /* always BEFORE palette..... */ render_type mode if RC~=0 then do say 'WRONG ARGUMENT!!!!' exit end /* adjust palette here..... */ if mode='HAM' then mode=16 ptotal mode if mode='HAM8' then pused 256 else pused mode But if we're dealing with a gray image, when converted with operator "Color_To_Gray", ADPro will set a new render-mode: Original New (AGA) New (Non-AGA) ---------------------------------------------------- HAM8 256 16 HAM 16 16 256 256 256 128 128 128 64 64 64 32 32 32 16 16 16 8 8 8 4 4 4 2 2 2 If you have a look at the "NEW"-lists, you see the palette is easy to adjust: /* ...adjust palette here..... */ IMAGE colors=ADPRO_RESULT ptotal colors pused colors That's it! ------------------------------------------------------------------------------ REQUESTERS ------------------------------------------------------------------------------ Before you start writing with requesters, you'll have to add this to your user-startup, which is located in your s: directory: rexx:RXLIB libs:rexxreqtools.library 0 -30 The library and its doc are included. The "InstallScripts"-icon will help you to install this library. After installation, you should reset. If you plan to use requesters, ALWAYS begin your scripts like this: /* start */ NL='0a'x /* NL = New Line */ Now, the most important requesters are the following.... 1. You want to tell something, and get an answer. 2. You want to get a file. 3. You want to get a number. 4. You want to get a string. 1. TELL-REQUESTER ----------------- First, an example: /* start */ if pos('ADPro',show(Ports))=0 then do mess= ' Seems like ADPro is not running!'||NL mess=mess||"Do you want me to call 'rexx:StartADPro.rexx'?" buttons="Please do|No, I'll do it myself|Exit Script" title='Problem....' call rtezrequest(mess,buttons,title) if rtresult=0 then exit if rtresult=1 then address command 'rx rexx:StartADPro.rexx' if rtresult=2 then do RC=1 do until RC=0 address 'ADPro' end end What the hell is all that? I'll explain it a little bit...... mess stands for message, the text that will appear in your requester. buttons, you can define a large number of buttons in one requester. The right most button returns value zero. The other buttons return from left to right 1, 2, 3, 4, 5 ..... title, guess what, you could place something like "system request".... ALWAYS use rtezrequest with CALL: you can't pass a value with rtezrequest! 2. FILE-REQUESTER ----------------- First, an example: /* start */ filename=rtfilerequest('Work:','Unknown','Please pick a file to delete') address command 'c:delete '||filename 'Work:' could be anything else, it's the default directory. 'Unknown' could also be anything else, it's the default filename. The third is the title. As you can see, the result is in this example passed to 'filename'. You could do much more things with this, like select multiple files, or select drawers only, etc... If you need these features, please check out the "rexxreqtools.library"-document (INCLUDED). 3. LONG-REQUESTER ----------------- First, an example: /* start */ mess='Please enter your year of birth' title='System request' number=rtgetlong(1993,mess,title,,"rtgl_min=1900 rtgl_max=1993") age=1993-number say 'Age: '||age 1993: default value. rtgl_min=1900: minimum value: 1900 rtgl_max=1993: maximum value: 1993 Make sure the min and max are written as the example, meaning between brackets, otherwise you will get an error or something completely different. 4. STRING-REQUESTER ------------------- First, an example: /* start */ mess='Please enter your name' title='System request' name=rtgetstring('Unknown',mess,title) say 'Hello '||name||'!' Simple requester, isn't it? 'Unknown' is, guess again, the default value. ------------------------------------------------------------------------------ THE END ------------------------------------------------------------------------------ This is it! Hope you will write your scripts based on mine, I myself don't write such long scripts like the scripti's. I always render in 24Bit, and do the following, depending on what screenmode I'm longing for: /* start */ arg filename say filename address 'ADPro' load filename load 'ram:initials' 0 500 100 0 0 0 abs_scale 640 512 dither 1 render_type 'HAM8' ptotal 'HAM8' pused 256 execute save fileneame'.new' IMAGE exit Very short and unpredictable, but you can't write a complex script each time you rendered something. Jan Van Overbeke.