Masterclass November Sometimes even AmigaDOS isn't enough - John Kennedy moves onto ARexx. The idea for this month's Masterclass came from a letter from Duncan Strand from Leicester. Duncan has several disks full of hundreds of sound samples, and none of them has an icon - which can make orginising them a bit of a problem. Duncan has been experimenting with AmigaDOS, trying to create multiple icons by performing variations with COPY and the pattern matching - none of which have worked. Now it would be possible to write an AmigaDOS script to create all the files, but to be honest I'm not a big fan of writing cumbersome programs in AmigaDOS. I know there are big fans out there, but I'm not one of them. When I want to write a program, I want to use a programming language: not a series of DOS commands. All Workbench 2.04 and better Amigas come with ARexx present. ARexx is the Amiga implementation of Rexx, a language which has been around for a bit. In fact, the alternative IBM-PC operating system, OS/2 comes with Rexx, although it's use is even less wide spread than the Amiga. ARexx is a little like AmigaDOS in that its programs are stored in plain text files, and there is no need to compile them first. ARexx is an interpreted language, and although this stops it from being the fastest language in the world, it also makes it one of the simpler one to use. Starting ARexx -------------- Before you can use any ARexx programs, you need to make sure the main ARexx interpreter program is present and running. The name of this program is Rexxmast, and you'll find it in the System drawer of the Workbench drawer. You can start it by clicking on it, or run it from the SHELL by entering Rexxmast and pressing return. If you want to make it run automatically every time you boot your computer (which is especially handy if you have a hard drive, when the overheads will be negligible) you should add it to the file called 'user-startup' in the s: directory. If this file doesn't already exist, you can create it by entering: ed s:user-startup at the Shell. If the file does already exist it will be loaded, and you'll be able to add more text. In either case, add the following: run >nil: nil:' and ' ram:filelist This performs a normal directory listing, but only with the file names, and then redirects the list into a file in the ram disk. Unfortunately we can't simply run the ARexx script using this list, like this: rx copy.rexx t:filelist" call open(filepointer,"t:filelist","r") do while ~eof(filepointer) name=readln(filepointer) || ".info" com="copy dummy.info" name com end call close (filepointer) And that's it! This script will create a temporary list of all the files in the T: directory, and then go through them one by one, copying the dummy.info icon with a new name. This should give all the files in the directory an icon - problem solved. Table 1 - Common ARexx Commands SAY Display text or the contents of a variable on screen. To see what difference quotes make, try the following: again=10 say Hello World say "Hello, World" say Hello, World again say "Hello, World again" DO / END Packet up several lines. You can also create loops, like this: do 10 say "Hello" end do i=1 to 10 by 2 say i end IF THEN ELSE Conditional testing. if 1=1 then say "Phew, that was close" if x=19 then do say "Well I never" say "Good old X, eh?" end else say "too bad" || Concatanate two strings, without spaces. For example, string1 = Hello World string2 = Hello || World say string1 say string2 ----- pictures: novmast1.iff caption: A text editor such as Cygnus Ed makes editing ARexx scripts so much easier than Commodore's ED.