home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d9xx
/
d939
/
upcat.lha
/
Upcat
/
SetCategory.upcat
< prev
next >
Wrap
Text File
|
1993-12-20
|
5KB
|
188 lines
/*-----------------------------------------------------------------------*/
/* ARexx macro SetCategory for Upcat. */
/* */
/* This macro will put all selected files in a specified category. */
/* */
/* A selection must be made in the File Selection requester of Upcat, */
/* before this macro may be called. */
/* */
/* Example : Select all files, which names end with '.doc'. Then start */
/* this macro and select an appropriate category (e.g. Documentation). */
/* When the macro is finished, all '.doc' files will be in category */
/* Documentation. */
/* */
/* You may adapt this macro or use parts of it for your own needs, but */
/* this macro must be distributed unchanged. */
/* */
/* Author : Frans Zuydwijk */
/* Date : 24 September 1993 */
/*-----------------------------------------------------------------------*/
Trace Off
Options Results /* Get information returned in Result */
"FileSelect ON"
If RC = 11
Then Do
"Requester" "Continue" "No file selection criteria set|End of macro"
Exit
End
Call OpenWindow
Call GetCategories
Call AskCategory
OldCount = Cats.Category.Count
Call DoChanges
WriteLn('Console', '')
WriteLn('Console', 'Old count was ' || OldCount || ,
', new count is ' || Cats.Category.Count)
WriteLn('Console', '')
WriteCh('Console', 'Press RETURN')
ReadLn('Console')
Close('Console')
Exit
/*-----------------------------------------------------------------------*/
/* Open window on Upcat screen. */
/*-----------------------------------------------------------------------*/
OpenWindow : Procedure
"ScreenName"
WindowParms = 'CON:0/10/640/150/Set category/Screen' Result
If Open('Console', WindowParms) = 0
Then Do
"Requester" "Continue" "Cannot open window|End of macro"
Exit
End
Return
/*-----------------------------------------------------------------------*/
/* Get categories in stem Cats. */
/*-----------------------------------------------------------------------*/
GetCategories : Procedure Expose Cats.
Cats. = ''
i = 0
"FirstCat"
Do While RC = 0
i = i + 1
Parse Var Result Cats.i.Name '/' Cats.i.Number '/' Cats.i.Count
"NextCat"
End
Cats.0 = i
If RC ~= 5
Then Do
Call Close('Console')
"Requester" "Continue" "FirstCat/NextCat returned error" RC ,
|| "|End of macro"
Exit
End
Return
/*-----------------------------------------------------------------------*/
/* Ask user to select category */
/*-----------------------------------------------------------------------*/
AskCategory : Procedure Expose Cats. Category
Do i = 1 To Cats.0
If i // 4 = 1 Then Line = ''
Line = Line Right(i,2) Left(Cats.i.Name,15)
If i // 4 = 0 Then WriteLn('Console', Line)
End
Do Forever
WriteLn('Console', '')
WriteCh('Console', 'Select category : ')
Category = ReadLn('Console')
Select
When Category = ''
Then Nop
When Datatype(Category) ~= 'NUM'
Then WriteLn('Console', 'Not a number')
When Category < 1 | Category > 32
Then WriteLn('Console', 'Invalid category number')
When Cats.Category.Name = ''
Then WriteLn('Console', 'Undefined category')
Otherwise Leave
End
End
Return
/*-----------------------------------------------------------------------*/
/* Add selected files to selected category. */
/*-----------------------------------------------------------------------*/
DoChanges : Procedure Expose Cats. Category
"FirstFile"
Do While RC = 0
Parse Var Result . '/' . '/' FileName '/' .
"SetCategory ON" Cats.Category.Number
Select
When RC = 0
Then Do
Cats.Category.Count = Cats.Category.Count + 1
"Path"
Message = 'Added :' Result || FileName
WriteLn('Console', Message)
End
When RC = 5 /* Already in category */
Then Nop
Otherwise
Do
Call Close('Console')
"Requester" "Continue" "SetCategory returned error" RC ,
|| "|End of macro"
Exit
End
End
"NextFile"
End
If RC ~= 5
Then Do
Call Close('Console')
"Requester" "Continue" "FirstFile/NextFile returned error" RC ,
|| "|End of macro"
Exit
End
Return