I create the figures for my articles using DeluxePaint. Once I have all of the figures on disk, I like to view them in slide show fashion to check for mistakes before printing them. This is just begging for a custom Workbench utility program, and CanDo is up to the job. The program is entitled PrintPics.
PrintPics consists of two cards. One is named WBInterface. It is the user interface described above. The other card is named Picture and is used for displaying the picture files while viewing or printing.
The OnAppEvent script added in the last step simply creates a document named AppEventList and puts the contents of Arg1 into it. When an AppEvent occurs within a CanDo program, the list of filenames associated with the icons that were moved into the window is assigned to the system variable Arg1. Each filename is separated by a line feed character (ASCII 10). By typing Arg1 into the document, the latter will contain all the selected filenames, one per line. Document AppEventList is associated with the List object on the WBInterface card. Thus, whenever the document is updated, the filenames in the List object update also.
The first TextButton is named View and is used to activate a slide show of the files listed in the AppEvents object. The second TextButton is named Print and is used to print the files listed in the AppEvents object. The third TextButton is named Quit and is used to exit the program. The fourth TextButton is named PrintSettings and is used for changing the printer's graphics preferences. Each of these four buttons have an OnRelease event script that executes when the button is selected.
The OnRelease script for the View button assigns the string "View" to the variable named Command, moves the cursor to the start of the current document (AppEventList), and then goes to the card, Picture. The OnRelease script for the Print button is exactly the same except the variable, Command, is equated to the string "Print". The script for the Quit button simply executes the Quit command. The script for the PrintSettings button executes CanDo's Dos command with the string "SYS:Prefs/PrinterGfx" as its argument. This tells CanDo to execute the program named PrinterGfx in the SYS:Prefs directory. This program is included with AmigaDOS. It allows the user to change various graphics settings for the currently selected printer.
When the View or Print button is pressed on the WBInterface card, its OnRelease event script activates. Each script activates the Picture card after assigning a value to the variable, Command, and moving the cursor to the top of the AppEventList document. When the Picture card is activated, its AfterAttachment script executes after the card is displayed.
Following through the AfterAttachment script in Listing 1, the first thing that occurs is that the variable, TheLine, is compared to a null string. TheLine is the string in the current line of the current document. If this string is not null, meaning that at least one file has been dragged to the WBInterface card, the ShowPicture command is executed with TheLine as an argument. The ShowPicture command loads the file specified by its argument and associates it with the current card, Picture. It does not matter if the file contains a picture of a different resolution or depth than the Picture card, CanDo will automatically change the card's resolution to match the file. The ScreenTo FRONT command then displays the picture.
Next, the script determines which button the user pressed by looking at the contents of the variable, Command. If this variable is equal to "View", then the script pauses for five seconds, otherwise (the only alternative is "Print") the PrintWindow command is executed. This command prints the current window to the user's Preferences printer using the current graphics settings. After either pausing or printing, the current document's cursor is moved down one line, which places it on the next filename in the list, and the script is exited.
Once the AfterAttachment script finishes execution, the one and only object on the Picture card activates. The object is a timer set to go off after zero seconds. Therefore, its Occurred script executes immediately. This script checks to see if TheLine is null. If it is, there are no more files in the list to view or print, so the program goes to the WBInterface card to await more user input. If TheLine is not null, the Picture card is activated again causing its AfterAttachment script to execute again. The Timer object, named Timer_1, must be used because the GotoCard command cannot be issued from within an AfterAttachment script.
Some of you may be wondering why I didn't just pass the list of filenames from the OnAppEvent script to the Picture card by using Arg1 as an argument and then creating a loop within the AfterAttachment script to display each picture in turn. Good idea! I tried it. It doesn't work. The first picture displays fine, but when a picture that is not the same resolution as the first is encountered, it does not display properly. It will appear using the resolution of the first picture. Thus, if the first picture is high resolution interlaced, a subsequent picture that is high resolution non-interlaced will be squashed vertically. This bug was verified by a technical support person at INOVAtronics. They plan to correct this problem in a future release. As an interim work-around, the Picture card must be activated between each picture. This reinitialization allows the card's resolution to be changed via the ShowPicture command.