home *** CD-ROM | disk | FTP | other *** search
- /*****
- $VER: RecentScript Commands 1.0 (9.2.97) ©Arndt van der Molen
-
-
- RecentScript Commands
-
- is a MUIRexx subapplication and can not be started directly.
-
- It is called only from the starter application.
- *****/
-
-
-
- /* Change to path with trailing ':' or '/' where this script resides */
-
- srcdir = 'MUIREXX:RecentScript/'
-
-
-
- /* !!! NOTHING TO CHANGE BELOW THIS LINE !!! */
-
- OPTIONS RESULTS
-
- PARSE ARG portname cmd1 cmd2 '['cmd3']'
-
- MUIV_List_Select_Off = 0
- MUIV_List_Select_On = 1
-
-
- cmd2 = STRIP(cmd2)
-
- PRAGMA('Directory',srcdir) /* Set current directory */
-
- ADDRESS VALUE portname
-
- SELECT
-
- WHEN cmd1 = 'ADD' THEN CALL addentries
-
- WHEN cmd1 = 'CLR' THEN CALL clearlist cmd2
-
- WHEN cmd1 = 'DEL' THEN CALL delentry
-
- WHEN cmd1 = 'LOAD' THEN CALL loadindex cmd2 cmd3
-
- WHEN cmd1 = 'MINUS' THEN CALL patternentries MUIV_List_Select_Off
-
- WHEN cmd1 = 'PLUS' THEN CALL patternentries MUIV_List_Select_On
-
- WHEN cmd1 = 'SAVE' THEN CALL savelist
-
- WHEN cmd1 = 'SETBAT' THEN CALL batchsettingopen '['cmd3']'
-
- WHEN cmd1 = 'SETBATHDL' THEN CALL batchsettinghandle cmd2 '['cmd3']'
-
- WHEN cmd1 = 'TEST' THEN CALL testprocedure
-
- OTHERWISE DO
- request ID RECSCRWIN TITLE '"Internal Error"' GADGETS '"_OK"' STRING '"Unsupport command 'cmd1 cmd2 cmd3'"'
- END
- END
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* Add all selected entries from the LST_ALL to the LST_SEL */
- /* --------------------------------------------------------- */
-
- addentries: PROCEDURE
-
- MUIA_List_Quiet = '0x8042d8c7'
- MUIM_Busy_Move = '0x80020001'
- MUIV_List_Insert_Bottom = -3
-
-
- list ID LST_SEL ATTRS MUIA_List_Quiet 1
-
- DO FOREVER
-
- list ID LST_ALL
- entry = result
-
- IF entry = '' THEN LEAVE
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- list ID LST_SEL NODUP POS MUIV_List_Insert_Bottom INSERT STRING entry
- END
-
- list ID LST_SEL ATTRS MUIA_List_Quiet 0
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* Delete selected entry from the LST_SEL */
- /* --------------------------------------------------------- */
-
- delentry: PROCEDURE
-
- MUIA_List_Active = '0x8042391c'
-
- list ID LST_SEL ATTRS MUIA_List_Active
- position = result
-
- list ID LST_SEL POS position STRING
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* Load specified AmiNet index file into specified listview */
- /* --------------------------------------------------------- */
-
- loadindex: PROCEDURE EXPOSE srcdir
-
- parse arg listid ' ' filename
-
- MUIA_List_Quiet = '0x8042d8c7'
- MUIM_Busy_Move = '0x80020001'
- ASLFR_InitialDrawer = '0x80080009'
- MUIV_List_Insert_Bottom = -3
-
-
- IF filename = '' THEN DO
-
- OPTIONS FAILAT 11
- aslrequest ID RECSCRWIN TITLE '"Load AmiNet index file..."' ATTRS ASLFR_InitialDrawer srcdir
- returncode = RC
- filename = result
- OPTIONS FAILAT 0
-
- IF returncode ~= 0 | filename = '' THEN DO
- RETURN
- END
- END
-
- IF OPEN(indexhandle, filename, 'R') THEN DO
-
- list ID listid ATTRS MUIA_List_Quiet 1
-
- DO UNTIL EOF(indexhandle)
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- line = READLN(indexhandle)
-
- /* Check if the line is an AmiNet Index line */
-
- slashposition = POS('/',line)
-
- /* This check must be edited if the format of the index file changes */
- IF (SUBSTR(line,34,1) = 'K' | SUBSTR(line,34,1) = 'M'),
- & SUBSTR(line,19,1) = ' ',
- & SUBSTR(line,30,1) = ' ',
- & SUBSTR(line,36,1) ~= ' ', /* Exlude 'most downloaded' and 'top rated' files */
- & slashposition > 20,
- & slashposition < 29
- THEN DO
-
- /* This line must be edited if the format of the index file changes */
- PARSE VAR line WITH 1 1 name +18 WITH 20 directory +10 WITH 31 size +4 WITH 36 comment
-
- LIST ID listid NODUP POS MUIV_List_Insert_Bottom INSERT STRING name","directory","size","comment
- END
- END
-
- list ID listid ATTRS MUIA_List_Quiet 0
-
- CALL CLOSE(indexhandle)
-
- END
- ELSE DO
- request ID RECSCRWIN TITLE '"File Error"' GADGETS "_OK" STRING "Cannot read file '"filename"'"
- END
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* Save LST_SEL to AmiNet index file or user defined batch */
- /* --------------------------------------------------------- */
-
- savelist: PROCEDURE EXPOSE srcdir
-
- MUIA_List_Entries = '0x80421654'
- MUIM_Busy_Move = '0x80020001'
- ASLFR_InitialFile = '0x80080008'
- ASLFR_InitialDrawer = '0x80080009'
-
-
- /* Get batchmode */
-
- cycle ID CYC_BAT
- batchmode = result
-
- /* Save to AmiNet Index file ? */
-
- IF batchmode = 'AmiNet Index' THEN DO
- CALL saveasindex
- RETURN
- END
-
-
- /* User configured batch mode selected... */
- /* Read batchmode config file. */
-
- filename = srcdir || "Configs/" || batchmode || ".cfg"
-
- IF OPEN(handle, filename, 'R') THEN DO
-
- /* Read batchmode config in local stem variable */
-
- globalcfg.readme = READLN(handle)
-
- batchcfg.0 = 0
- i = 0
-
- DO UNTIL EOF(handle)
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- description = READLN(handle)
- value = READLN(handle)
-
- IF description ~= '' & value ~= '' THEN DO
-
- i = i + 1
- batchcfg.0 = i
-
- batchcfg.i.replace = '%'D2C(i+48)'' /* %1 ... */
- batchcfg.i.desc = description
- batchcfg.i.val = value
- END
- END
-
- CALL CLOSE(handle)
-
- OPTIONS FAILAT 11
- aslrequest ID RECSCRWIN TITLE '"Save ''batchmode'' file ..."' ATTRS ASLFR_InitialDrawer srcdir ASLFR_InitialFile TRANSLATE(batchmode, '_', ' ') || '.bat'
- returncode = RC
- filename = result
- OPTIONS FAILAT 0
-
- IF returncode ~= 0 | filename = '' THEN DO
- RETURN
- END
-
- IF OPEN(writehandle, filename, 'W') THEN DO
-
- /* Read and Write batchmode intro file if available */
-
- filename = srcdir || "Configs/" || batchmode || ".intro"
-
- IF OPEN(handle, filename, 'R') THEN DO
-
- /* Do for all lines in file */
- DO UNTIL EOF(handle)
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- line = READLN(handle)
-
- /* Replace batch placeholders with value from config */
- DO i=1 TO (batchcfg.0)
-
- /* Replace all placeholders in line */
- start = POS(batchcfg.i.replace, line)
- DO WHILE start ~= 0
-
- line = SUBSTR(line,1,start-1) || SUBSTR(line,start+2)
- line = INSERT(batchcfg.i.val, line, start-1)
- start = POS(batchcfg.i.replace, line)
- END
- END
-
- CALL WRITELN(writehandle, line)
- END
-
- CALL CLOSE(handle)
- END
-
-
- /* Read and Write batchmode entry file if available */
-
- filename = srcdir || "Configs/" || batchmode || ".entry"
-
- IF OPEN(handle, filename, 'R') THEN DO
-
- /* Add entry placeholders to local stem varaible */
- i = batchcfg.0 + 1
- batchcfg.i.replace = '%n' /* name */
- i = i+1
- batchcfg.i.replace = '%d' /* directory */
- i = i+1
- batchcfg.i.replace = '%s' /* size */
- i = i+1
- batchcfg.i.replace = '%c' /* comment */
- batchcfg.0 = i
-
- /* Read batchmode entry lines in local stem variable */
-
- entrycfg.0 = 0
- i = 1
-
- DO UNTIL EOF(handle)
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- entrycfg.i = READLN(handle)
- entrycfg.0 = i
- i = i + 1
- END
-
- CALL CLOSE(handle)
-
- /* Do for all entries in LST_SEL */
-
- list ID LST_SEL ATTRS MUIA_List_Entries
- lstselcount = result
-
- IF lstselcount > 0 THEN DO
-
- DO lstselnr=0 TO lstselcount-1
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- list ID LST_SEL POS lstselnr
- listline = result
-
- /* This line must be edited if the format of the index file changes */
- PARSE VAR listline WITH 1 name +18 WITH 20 directory +10 WITH 31 size +4 WITH 36 comment
-
- /* Add entry values to local stem varaible */
- i = batchcfg.0
- batchcfg.i.val = comment
- i = i-1
- batchcfg.i.val = size
- i = i-1
- batchcfg.i.val = STRIP(directory)
- i = i-1
- batchcfg.i.val = STRIP(name)
-
-
- DO global=0 TO globalcfg.readme /* Process *.readme file ? */
-
- IF global=1 THEN DO
-
- i = batchcfg.0 - 1 /* Set new 'size' to 0 */
- batchcfg.i.val = ' 0K'
-
- i = batchcfg.0 - 3 /* Set new 'name' to *.readme */
- position = LASTPOS('.', batchcfg.i.val)
-
- IF position ~= 0 THEN DO
- batchcfg.i.val = SUBSTR(batchcfg.i.val, 1, position) || "readme"
- END
- ELSE DO
- batchcfg.i.val = batchcfg.i.val || ".readme"
- END
- END
-
- /* Do for all entry config lines */
-
- DO entrycfgnr=1 TO entrycfg.0
-
- line = entrycfg.entrycfgnr
-
- /* Replace batch and entry placeholders with value from config */
- DO i=1 TO batchcfg.0
-
- /* Replace all placeholders in line */
- start = POS(batchcfg.i.replace, line)
- DO WHILE start ~= 0
-
- line = SUBSTR(line,1,start-1) || SUBSTR(line,start+2)
- line = INSERT(batchcfg.i.val, line, start-1)
- start = POS(batchcfg.i.replace, line)
- END
- END
-
- CALL WRITELN(writehandle, line)
- END
- END
- END
- END
- batchcfg.0 = batchcfg.0 - 4 /* Remove entry variables from config */
- END
-
-
- /* Read and Write batchmode extro file if available */
-
- filename = srcdir || "Configs/" || batchmode || ".extro"
-
- IF OPEN(handle, filename, 'R') THEN DO
-
- /* Do for all lines in file */
- DO UNTIL EOF(handle)
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- line = READLN(handle)
-
- /* Replace batch placeholders with value from config */
- DO i=1 TO (batchcfg.0)
-
- /* Replace all placeholders in line */
- start = POS(batchcfg.i.replace, line)
- DO WHILE start ~= 0
-
- line = SUBSTR(line,1,start-1) || SUBSTR(line,start+2)
- line = INSERT(batchcfg.i.val, line, start-1)
- start = POS(batchcfg.i.replace, line)
- END
- END
-
- CALL WRITELN(writehandle, line)
- END
-
- CALL CLOSE(handle)
- END
-
- CALL CLOSE(writehandle)
- END
- ELSE DO
- request ID RECSCRWIN TITLE '"File Error"' GADGETS "_OK" STRING "'Cannot write file '"filename"'"
- END
-
- END
- ELSE DO
- request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot read file '"filename"'"
- END
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* Save all entries from the LST_SEL to an AmiNet index file */
- /* --------------------------------------------------------- */
-
- saveasindex: PROCEDURE EXPOSE srcdir
-
- MUIA_List_Entries = '0x80421654'
- MUIM_Busy_Move = '0x80020001'
- ASLFR_InitialFile = '0x80080008'
- ASLFR_InitialDrawer = '0x80080009'
-
-
- OPTIONS FAILAT 11
- aslrequest ID RECSCRWIN TITLE '"Save selected files..."' ATTRS ASLFR_InitialDrawer srcdir ASLFR_InitialFile "RecentScript.lst"
- returncode = RC
- filename = result
- OPTIONS FAILAT 0
-
- IF returncode = 0 & filename ~= '' THEN DO
-
- IF OPEN(handle, filename, 'W') THEN DO
-
- list ID LST_SEL ATTRS MUIA_List_Entries
- number = result
-
- IF number > 0 THEN DO
-
- DO i=0 TO number-1
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- list ID LST_SEL POS i
- line = result
-
- /* This line must be edited if the format of the index file changes */
- PARSE VAR line WITH 1 name +18 WITH 20 directory +10 WITH 31 size +4 WITH 36 comment
-
- CALL WRITELN(handle,name directory size comment)
- END
- END
-
- CALL CLOSE(handle)
- END
- ELSE DO
- request ID RECSCRWIN TITLE '"File Error"' GADGETS "_OK" STRING "'Cannot write file '"filename"'"
- END
- END
-
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* Delete all entries in specified listview */
- /* --------------------------------------------------------- */
-
- clearlist: PROCEDURE
-
- parse arg listid
-
- list ID listid STRING
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* (De)Select entries in LST_ALL with search string */
- /* --------------------------------------------------------- */
-
- patternentries: PROCEDURE
-
- parse arg mode
-
- MUIA_List_Entries = '0x80421654'
- MUIM_List_Select = '0x804252d8'
- MUIM_Busy_Move = '0x80020001'
-
- list ID LST_ALL ATTRS MUIA_List_Entries
- number = result
-
- string ID STR_PATT
- pattern = result
-
- IF number > 0 THEN DO
-
- DO i=0 TO number-1
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- list ID LST_ALL POS i
- line = result
-
- IF POS(pattern, line) ~= 0 THEN DO
-
- method ID LST_ALL MUIM_List_Select i mode 0
- END
- END
- END
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* Opens batch settings window for the specified batchmode */
- /* --------------------------------------------------------- */
-
- batchsettingopen: PROCEDURE EXPOSE portname srcdir
-
- parse arg '['batchmode']'
-
- Selected = '0x8042654b'
-
- /* GUI Commands */
-
- CMD_BUT_OK = '"'srcdir'RecentScriptCmd 'portname' SETBATHDL OK ['batchmode']"'
- CMD_BUT_CANCEL = '"'srcdir'RecentScriptCmd 'portname' SETBATHDL CANCEL ['batchmode']"'
-
- filename = srcdir || "Configs/" || batchmode || ".cfg"
-
- IF OPEN(handle, filename, 'R') THEN DO
-
- /* Read batchmode config in local stem variable */
-
- globalcfg.readme = READLN(handle)
-
- batchcfg.0 = 0
- i = 0
-
- DO UNTIL EOF(handle)
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- description = READLN(handle)
- value = READLN(handle)
-
- IF description ~= '' & value ~= '' THEN DO
-
- i = i + 1
- batchcfg.0 = i
-
- batchcfg.i.replace = '%'D2C(i+48)'' /* %1 ... */
- batchcfg.i.desc = description
- batchcfg.i.val = value
- END
- END
-
- CALL CLOSE(handle)
-
- asdf = 'endgroup' /* Workaround for an interpreting error (?) */
-
- /* Create window with string gadgets for each variable */
-
- window ID BATSETWIN TITLE '"Settings for '''batchmode'''"' PORT portname
-
- group FRAME LABEL 'Global'
- group HORIZ
- space HORIZ
-
- check ID CHK_README STRINGS '"0,1"' ATTRS Selected globalcfg.readme HELP '"Generate an extra line for the ''.readme'' file ?"'
- label "Include '#?.readme'"
- space HORIZ
- endgroup
- endgroup
-
-
- group FRAME LABEL 'Variables'
-
- DO i=1 TO batchcfg.0
- group ID '"G'D2C(i+65)'"'
- label CENTER '"'batchcfg.i.desc'"'
- group HORIZ
- label batchcfg.i.replace
- string ID '"S'D2C(i+65)'"' HELP '"Replaces configuration variable ''%'D2C(i+48)''' in output"' CONTENT batchcfg.i.val
- interpret asdf
- interpret asdf
- END i
-
- endgroup
-
- group HORIZ
- button COMMAND CMD_BUT_OK LABEL 'OK'
- button COMMAND CMD_BUT_CANCEL LABEL 'Cancel'
- endgroup
-
- endwindow
-
- END
- ELSE DO
- request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot read file '"filename"'"
- END
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* Handle buttons from the batch settings window */
- /* --------------------------------------------------------- */
-
- batchsettinghandle: PROCEDURE expose srcdir
-
- parse arg mode '['batchmode']'
-
- MUIM_Busy_Move = '0x80020001'
-
-
- SELECT
-
- WHEN mode = 'CANCEL' THEN DO
-
- window ID BATSETWIN CLOSE
- END
-
- WHEN mode = 'OK' THEN DO
-
- /* Save new batchmode config */
-
- filename = srcdir || "Configs/" || batchmode || ".cfg"
-
- IF OPEN(handle, filename, 'R') THEN DO
-
- /* Read old batchmode config in local stem variable */
-
- globalcfg.readme = READLN(handle)
-
- batchcfg.0 = 0
- i = 0
-
- DO UNTIL EOF(handle)
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- description = READLN(handle)
- value = READLN(handle)
-
- IF description ~= '' & value ~= '' THEN DO
-
- i = i + 1
- batchcfg.0 = i
-
- batchcfg.i.replace = '%'D2C(i+48)'' /* %1 ... */
- batchcfg.i.desc = description
- batchcfg.i.val = value
- END
- END
-
- CALL CLOSE(handle)
-
-
- /* Overwrite values with actual ones */
-
- check ID CHK_README
- globalcfg.readme = result
-
- DO i=1 TO batchcfg.0
- string ID '"S'D2C(i+65)'"'
- batchcfg.i.val = result
- END
-
-
- /* Write new batchmode file */
-
- IF OPEN(handle, filename, 'W') THEN DO
-
- CALL WRITELN(handle, globalcfg.readme)
-
- DO i=1 TO batchcfg.0
-
- method ID CLS_BUSY MUIM_Busy_Move
-
- CALL WRITELN(handle, batchcfg.i.desc)
- CALL WRITELN(handle, batchcfg.i.val)
- END
-
- CALL CLOSE(handle)
- END
- ELSE DO
- request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot write file '"filename"'"
- END
-
- END
- ELSE DO
- request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot read file '"filename"'"
- END
-
- window ID BATSETWIN CLOSE
- END
-
- OTHERWISE DO
- request ID RECSCRWIN TITLE '"Internal Error"' GADGETS '"_OK"' STRING '"Unsupport command 'batchmode'"'
- END
- END
-
- RETURN
-
-
-
- /* --------------------------------------------------------- */
- /* Only a testprocedure for testing new features */
- /* --------------------------------------------------------- */
-
- testprocedure: PROCEDURE
-
- RETURN
-