Bodacious Bodean's
Binary Bakery

By J.L. White



owdy,

Well by the time you read this, you Flyer owners out there should have received your 4.2 update to the Flyer software. This is mainly a bug fix until Newtek can get 5.0 out, but this time around they asked all the 3rd party developers to toss in some freebies. Most did just that, and so did we. In 4.2 there is a little library type program called VIFly. This is the same file that comes with our Control Tower software. The Flyer has some very nice Arexx routines but they were a little limiting to us, so we wrote this program to help fill in the gaps. Also I HATE some of their requesters and decided to replace them with some Lightwave-looking routines. Now that this library type file comes with the Flyer software, we hope that many of you would-be programmers will take advantage of these new routines. We supplied about 10 Arexx macros to show you some of the possibilities as well as an example script that shows all of the new functions.

We believe in making our Arexx scripts as modular as can be. Sorta C++ style programming. This way, when we write a subroutine to do something, all we have to do is cut and paste that section of code into another script, without having to search for certain parts and perhaps missing a line or two of important code. If you will take a look at our examples, you can see what I mean. Almost every script follows the same subroutines. To use a subroutine, all you have to do is use the "call" function in Arexx. This also allows you to have the subroutine return a value. This can be very helpful in writing Arexx scripts.

This issue I will show you how to create an Arexx script that will allow you to select a new image for your crouton and change it using some of our routines. One of the first things you will notice in the VIFly program is that we have added a standard Amiga ASL requestor to select files. I know the Grazer is suppose to be Newteks gift to the GODS but I CAN"T STAND IT! When I want to select a file, give that ol ASL EVERY TIME! This script can be found in the download section but we will go through each step here to show you what's what.

For those of you not interested in programming, you can simply download the arexx script and copy it to your Arexx drawer in the Newtek directory.

------------------------------------------------------
/*
Control Tower Script To Change Icon
Written By J.L. White
*/

As with all Arexx scripts you must start the script with "/*" Anything between those characters and "*/" is considered a comment line. You do not have to put anything in between them but you must at least start the script out that way.


signal on error
signal on syntax

/*These lines tell the script to go to a section of code if there is an error or spelling problems. */

Options Results
/* Means we want info to be returned */

Main:
call OpenStuff()
call Routine()
call CloseStuff()
exit
return
/*This is our MAIN code. Notice that it contains nothing but calls to subroutines. The first opens all the libs and files we need for Flyer scripts. The next is the main routine (this is the part you will change from script to script). The third closes down all the lib and files that we opened. Then it exits the script.*/

OpenStuff:
/*The subroutine for call OpenStuff() Always end it with : */
address command "run C:VIFLY"
do while (POS('FLY_1',SHOW('Ports'))=0)
address command "wait 1"
end
/*This runs the VIFLY program and waits in a loop till it opens its port */

call remlib('ToasterARexx.port')
call remlib('PROJECT_REXX_PORT')
call addlib('PROJECT_REXX_PORT',0)
call addlib('ToasterARexx.port',0)
/*This closes, then opens the Flyer ports. I don't know exactly why they close them first but all Newtek examples do this */

return

CloseStuff:
Address FLY_1 Quit
/*This closes VIFLY */
call remlib('ToasterARexx.port')
call remlib('PROJECT_REXX_PORT')
/* This closes the Flyer libs used by the script */
return

FindDrive:
address command "C:Info >RAM:FLY-List"
call open TempFile,"RAM:FLY-List",R
do until eof(TempFile)
line = readln(TempFile)
parse var line Drive" "Rest
if Drive = "FA0:" then
Volume = word(Rest,7)":"
end
call close TempFile
address command "Delete >NIL: RAM:FLY-List"
/*This finds out the name of the users Flyer drive, whatever they call it */
return Volume

GetFileName: procedure
ARG CompleteName
c = lastpos("/",CompleteName)
if c = 0 then c = lastpos(":",CompleteName)
return substr(CompleteName, c + 1)
/*This returns the file name without the path*/

GetPathName: procedure
ARG CompleteName
c = lastpos(":",CompleteName)
if c = 0 then c = lastpos(":",CompleteName)
return left(CompleteName,c)
/*This returns the path without the filename*/

Routine:
DriveName = FindDrive() /*Gets DriveName*/
FileName = GetFile("Select Clip For Icon Change! ",DriveName)
/* Uses ASL to get a filename */
if GetFileName(FileName) = "" then do
Address FLY_1 OK_TEXT " OK "
Title = "You Must Enter A Valid FileName!"
Address FLY_1 FYINT Title
return
end
/* This makes sure they entered a valid filename*/
Address FLY_1 SetFileName FileName
Address FLY_1 GetClipLength FileName
End = result
Address FLY_1 StartNum "0"
Address FLY_1 EndNum End
Address FLY_1 CurrentNum "-1"
Address FLY_1 GetTimeNT "Select New Frame To Use For Clip Icon!"
Num = word(result,1)*4
/* This set the file and uses our Clip Requester to Find the image to use*/
call MakeIcon(FileName,Num)
Address FLY_1 OK_TEXT " OK "
Address FLY_1 FYINT "Icon Has Now Been Changed!"
/*This makes the new icon and tells the user that it is done */

return

GetFile:
parse Arg Title, Path
Address FLY_1 SetString Path
Address FLY_1 GetFileNameNT Title
return result
/* Subroutine to get a filename with the ASL */

GetPath:
parse Arg Title, Path
Address FLY_1 SetString Path
Address FLY_1 GetPathNameNT Title
return result
/* Subroutine to get a path with the ASL */

GetText:
parse Arg Title, Text
Address FLY_1 SetString Text
Address FLY_1 GetStringNT Title
return result
/* Subroutine to get a string of text */

syntax:
error:
Address FLY_1 OK_TEXT " OK "
Title = "An Error Was Found With This Macro On Line #"SIGL"!"
Address FLY_1 FYINT Title
Address FLY_1 Quit
exit
/* section where script goes to if there is an error */

----------------------------------------------------------

Well that does it for this months installment.
Enjoy...

Jeff White
(Bodacious Bodean)




Back To The Table Of Contents
Copyright © 1997 Visual Inspirations