home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 9 / AACD09.ISO / AACDprefs < prev    next >
Text File  |  2000-03-11  |  24KB  |  641 lines

  1. /*
  2.     Preferences editor for Amiga Active CDs
  3.     $VER: AACDprefs 1.6 (11.3.00) by Neil Bothwick
  4. */
  5.  
  6. /* ;;; Initialise */
  7. options results
  8. signal on error
  9. CurrStack = pragma('S',16384)
  10. if CurrStack > 16384 then call pragma('S',CurrStack)
  11.  
  12. VerStr       = sourceline(3)
  13. VerStr       = subword(VerStr,2,words(VerStr) - 4)
  14. WinTitle     = 'Amiga Active CD preferences'
  15. GuiPort      = 'AACDPREFS'
  16. PrgPort      = GuiPort'.1'
  17. CDPrefs      = 'ENV:AACD.prefs'
  18. IderPrefs    = 'ENV:AACDfile.prefs'
  19. DefCDPrefs   = 'CDTools/S/AACD.prefs'
  20. DefIderPrefs = 'CDTools/S/AACDfile.prefs'
  21. FileTypes    = 'IFF GIF JPG PNG ANM MPG MOV AVI PDF SVX WAV S3M XMM MED DBM MOD MP3 MID AGD HTM LHA DEF'
  22. Settings     = 'CPU FPU PPC GFX AUTUP'
  23. CmdHelp      = '"Command for this type of file"'
  24. ArgHelp      = '"Arguments for this command\nThe filename will be added to the end.\nUse %s to include the filename somewhere else."'
  25. Filetype.0   = 'AACDfile'
  26. Filetype.1   = 'Directory Opus'
  27. Autorun.1    = 'Ask each time'
  28. Autorun.3    = 'Always load Welcome'
  29. Autorun.0    = 'Never Load Welcome'
  30.  
  31. MUIA_Menuitem_Shortcut              = 0x80422030
  32. MUIM_Application_AboutMUI           = 0x8042d21d
  33. MUIM_Application_OpenConfigWindow   = 0x804299ba
  34. MUIA_Group_SameHeight               = 0x8042037e
  35. MUIA_Group_SameWidth                = 0x8042b3ec
  36. MUIA_Group_Spacing                  = 0x8042866d
  37. MUIA_Group_Columns                  = 0x8042f416
  38. MUIA_Group_Rows                     = 0x8042b68f
  39. MUIA_Selected                       = 0x8042654b
  40. MUIA_Disabled                       = 0x80423661
  41. MUIA_Application_Sleep              = 0x80425711
  42. MUIA_Application_Author             = 0x80424842
  43. MUIA_Application_Copyright          = 0x8042ef4d
  44. MUIA_Application_Description        = 0x80421fc6
  45. MUIA_Application_Title              = 0x804281b8
  46. MUIA_Application_Version            = 0x8042b33f
  47. MUIA_Weight                         = 0x80421d1f
  48. ASLFR_DrawersOnly                   = 0x8008002F
  49. TRUE = 1
  50. FALSE = 0
  51.  
  52. call LoadLib('rexxsupport.library')
  53. call LoadLib('rexxdossupport.library')
  54. call LoadLib('rexxreqtools.library')
  55. ;;;
  56. /* ;;; Check for MUI */
  57. address command 'Assign >NIL: MUI: EXISTS'
  58. if RC > 0 then do
  59.     address command 'RequestChoice >NIL: "Amiga Active CD" "This program require Magic User Interface*NRun the Welcome script for a temporary MUI setup,*Nor install it from the CDTools drawer of the CD" "OK"'
  60.     exit
  61.     end
  62. ;;;
  63. /* ;;; Create main window */
  64. thisport = openport(PrgPort)
  65. if thisport = 0 then exit
  66. address(GuiPort)
  67. window id MAIN port PrgPort command 'QUIT' title '"'WinTitle'"'
  68. ;;;
  69. /* ;;; Menus */
  70.     menu ID PROJM label 'Project'
  71.         item ID ABOUM port PrgPort command '"ABOUT"' ATTRS MUIA_Menuitem_Shortcut '"?"' label 'About'
  72.         item  port GuiPort command '"method 'MUIM_Application_AboutMUI' 0"' label 'About MUI'
  73.         menu ID SETTM label 'Settings'
  74.             item port PrgPort command '"method 'MUIM_Application_OpenConfigWindow'"' label 'MUI...'
  75.             endmenu
  76.         item ID QUITM port PrgPort command 'QUIT' ATTRS MUIA_Menuitem_Shortcut 'Q' label 'Quit'
  77.         endmenu
  78.     menu ID EDITM label 'Edit'
  79.         item ID RESTM port PrgPort command '"RESTORE"' ATTRS MUIA_Menuitem_Shortcut 'D' label 'Restore to Defaults'
  80.         item ID LASTM port PrgPort command '"LOAD"' ATTRS MUIA_Menuitem_Shortcut 'L' label 'Last saved'
  81.         endmenu
  82. ;;;
  83. /* ;;; Info */
  84.     group id TABS REGISTER LABELS 'Info,System,Filetypes,Search'
  85.         view file 'CDTools/S/AACDprefs.txt'
  86. ;;;
  87. /* ;;; System */
  88.         group ATTRS MUIA_Group_Columns 4
  89.             space HORIZ
  90.             label 'Filetypes'
  91.             cycle id FTYPE help '"Use Directory Opus filetypes\nor AACDfile settings."' labels Filetype.0','Filetype.1
  92.             space HORIZ
  93.             space HORIZ
  94.             label 'Autorun'
  95.             cycle id ARUN help '"Whether Autorun should load the Welcome page\nwhen you insert an Amiga Active CD."' labels Autorun.1','Autorun.3','Autorun.0
  96.             space HORIZ
  97.             space HORIZ
  98.             label 'CPU'
  99.             cycle id CPU help '"Some functions have CPU optimised versions,\nset this to ensure you get the best options"' labels '68000,68020,68030,68040,68060'
  100.             space HORIZ
  101.             space HORIZ
  102.             label 'FPU'
  103.             cycle id FPU help '"WARNING:\nSelecting this when you do not have an FPU\nmay crash some programs"' labels 'No FPU,FPU'
  104.             space HORIZ
  105.             space HORIZ
  106.             label 'PPC'
  107.             cycle id PPC help '"Type of PPC processor, if fitted"' labels 'None,603,604'
  108.             space HORIZ
  109.             space HORIZ
  110.             label 'Graphics system'
  111.             cycle id GFX help '"Select the type of graphics\nyour Amiga uses"' labels 'AGA,OCS,CyberGraphX,Picasso96'
  112.             space HORIZ
  113.             space HORIZ
  114.             endgroup
  115. ;;;
  116. /* ;;; Filetypes */
  117.         group id FTABS REGISTER LABELS 'Images,Sounds,Other'
  118. ;;;
  119. /* ;;; Images */
  120.             group ATTRS MUIA_Group_Columns 3
  121.                 label DOUBLE LEFT '\033b\033uFiletype'
  122.                 label DOUBLE LEFT '\033b\033uCommand'
  123.                 label DOUBLE LEFT '\033b\033uArguments'
  124.                 label DOUBLE LEFT 'IFF Picture'
  125.                     popasl ID IFF0 port PrgPort command '"Check %s"' help '"Command to view IFF pictures"'
  126.                     string ID IFF1 help ArgHelp
  127.                 label DOUBLE LEFT 'GIF Picture'
  128.                     popasl ID GIF0 port PrgPort command '"Check %s"' help '"Command to view GIF pictures"'
  129.                     string ID GIF1 help ArgHelp
  130.                 label DOUBLE LEFT 'JPEG Picture'
  131.                     popasl ID JPG0 port PrgPort command '"Check %s"' help '"Command to view JPEG pictures"'
  132.                     string ID JPG1 help ArgHelp
  133.                 label DOUBLE LEFT 'PNG Picture'
  134.                     popasl ID PNG0 port PrgPort command '"Check %s"' help '"Command to view PNG pictures"'
  135.                     string ID PNG1 help ArgHelp
  136.                 label DOUBLE LEFT 'IFF Anim'
  137.                     popasl ID ANM0 port PrgPort command '"Check %s"' help '"Command to view IFF animations"'
  138.                     string ID ANM1 help ArgHelp
  139.                 label DOUBLE LEFT 'MPEG Video'
  140.                     popasl ID MPG0 port PrgPort command '"Check %s"' help '"Command to view MPEG video"'
  141.                     string ID MPG1 help ArgHelp
  142.                 label DOUBLE LEFT 'Quicktime Video'
  143.                     popasl ID MOV0 port PrgPort command '"Check %s"' help '"Command to view Quicktime movies"'
  144.                     string ID MOV1 help ArgHelp
  145.                 label DOUBLE LEFT 'AVI Video'
  146.                     popasl ID AVI0 port PrgPort command '"Check %s"' help '"Command to view AVI video"'
  147.                     string ID AVI1 help ArgHelp
  148.                 label DOUBLE LEFT 'Adobe PDF'
  149.                     popasl ID PDF0 port PrgPort command '"Check %s"' help '"Command to view Adobe Acrobat PDF files"'
  150.                     string ID PDF1 help ArgHelp
  151.                 space
  152.                 endgroup
  153. ;;;
  154. /* ;;; Sounds */
  155.             group ATTRS MUIA_Group_Columns 3
  156.                 label DOUBLE LEFT '\033b\033uFiletype'
  157.                 label DOUBLE LEFT '\033b\033uCommand'
  158.                 label DOUBLE LEFT '\033b\033uArguments'
  159.                 label DOUBLE LEFT 'IFF Sample'
  160.                     popasl ID SVX0 port PrgPort command '"Check %s"' help '"Command to play IFF samples"'
  161.                     string ID SVX1 help ArgHelp
  162.                 label DOUBLE LEFT 'WAV Sample'
  163.                     popasl ID WAV0 port PrgPort command '"Check %s"' help '"Command to play WAV samples"'
  164.                     string ID WAV1 help ArgHelp
  165.                 label DOUBLE LEFT 'S3M Module'
  166.                     popasl ID S3M0 port PrgPort command '"Check %s"' help '"Command to play S3M modules"'
  167.                     string ID S3M1 help ArgHelp
  168.                 label DOUBLE LEFT 'XM Module'
  169.                     popasl ID XMM0 port PrgPort command '"Check %s"' help '"Command to play XM modules"'
  170.                     string ID XMM1 help ArgHelp
  171.                 label DOUBLE LEFT 'MED Module'
  172.                     popasl ID MED0 port PrgPort command '"Check %s"' help '"Command to play OctaMED modules"'
  173.                     string ID MED1 help ArgHelp
  174.                 label DOUBLE LEFT 'DBM Module'
  175.                     popasl ID DBM0 port PrgPort command '"Check %s"' help '"Command to play DigiBooster modules"'
  176.                     string ID DBM1 help ArgHelp
  177.                 label DOUBLE LEFT 'Other Module'
  178.                     popasl ID MOD0 port PrgPort command '"Check %s"' help '"Command to play other modules"'
  179.                     string ID MOD1 help ArgHelp
  180.                 label DOUBLE LEFT 'MPEG Audio'
  181.                     popasl ID MP30 port PrgPort command '"Check %s"' help '"Command to play MPEG audio"'
  182.                     string ID MP31 help ArgHelp
  183.                 label DOUBLE LEFT 'MIDI'
  184.                     popasl ID MID0 port PrgPort command '"Check %s"' help '"Command to play midi files"'
  185.                     string ID MID1 help ArgHelp
  186.                 space
  187.                 endgroup
  188. ;;;
  189. /* ;;; Others */
  190.             group ATTRS MUIA_Group_Columns 3
  191.                 label DOUBLE LEFT '\033b\033uFiletype'
  192.                 label DOUBLE LEFT '\033b\033uCommand'
  193.                 label DOUBLE LEFT '\033b\033uArguments'
  194.                 label DOUBLE LEFT 'AmigaGuide'
  195.                     popasl ID AGD0 port PrgPort command '"Check %s"' help '"Command to view AmigaGuide documents"'
  196.                     string ID AGD1 help ArgHelp
  197.                 label DOUBLE LEFT 'HTML'
  198.                     popasl ID HTM0 port PrgPort command '"Check %s"' help '"Command to view HTML documents"'
  199.                     string ID HTM1 help ArgHelp
  200.                 label DOUBLE LEFT 'LhA archive'
  201.                     popasl ID LHA0 port PrgPort command '"Check %s"' help '"Command to list LhA archives"'
  202.                     string ID LHA1 help ArgHelp
  203.                 label DOUBLE LEFT 'Default'
  204.                     popasl ID DEF0 port PrgPort command '"Check %s"' help '"Command to show all other file types"'
  205.                     string ID DEF1 help ArgHelp
  206.                 space
  207.                 endgroup
  208.             endgroup
  209. ;;;
  210. /* ;;; Search */
  211.         group ATTRS MUIA_Group_Columns 3 MUIA_Group_SameWidth FALSE
  212.             space HORIZ
  213.             label DOUBLE CENTER '\033b\033uPaths to index files'
  214.             space HORIZ
  215.             label DOUBLE LEFT 'AACD'
  216.                 popasl ID AACD  port PrgPort ATTRS ASLFR_DrawersOnly TRUE help '"Path to your AACD index files\nLeave blank to read from CD"'
  217.                 button ID UPD1 port PrgPort command '"UpdateIndices(AACD)"' ATTRS MUIA_Weight 0 help '"Update the local copies of\nthe AACD index files"' label 'Update'
  218.             label DOUBLE LEFT 'Aminet CD'
  219.                 popasl ID AMCD  port PrgPort ATTRS ASLFR_DrawersOnly TRUE help '"Path to your Aminet CD index files\nLeave blank to read from CD"'
  220.                 button ID UPD2 port PrgPort command '"UpdateIndices(AMCD)"' ATTRS MUIA_Weight 0 help '"Update the local copies of\nthe Aminet CD index files"' label 'Update'
  221.             label DOUBLE LEFT 'Aminet Set'
  222.                 popasl ID AMSET port PrgPort ATTRS ASLFR_DrawersOnly TRUE help '"Path to your Aminet Set index files\nLeave blank to read from CD"'
  223.                 button ID UPD3 port PrgPort command '"UpdateIndices AMSET"' ATTRS MUIA_Weight 0 help '"Update the local copies of\nthe Aminet Set index files"' label 'Update'
  224.             label DOUBLE LEFT 'Aminet Online'
  225.                 popasl ID AMONL port PrgPort ATTRS ASLFR_DrawersOnly TRUE help '"Path to your Aminet Online index file\nLeave blank to read from CD"'
  226.                 button ID UPD4 port PrgPort command '"UpdateIndices(AMONL)"' ATTRS MUIA_Weight 0 help '"Update the local copies of\nthe Aminet index files"' label 'Update'
  227.             label DOUBLE LEFT 'Index update'
  228.                 cycle id AUTUP help '"Automatically update the local index\nfiles each time a new CD is used"' labels 'Manual,Automatic'
  229.                 button ID UPDAL port PrgPort command '"UpdateIndices(ALL)"' ATTRS MUIA_Weight 0 help '"Update the local copies of all\nof the index files"' label 'Update All'
  230.             space
  231.             endgroup
  232.         endgroup
  233. ;;;
  234. /* ;;; Buttons */
  235.     group HORIZ
  236.         button ID SAVE   port PrgPort command '"UsePrefs(1)"' help '"Save the settings to\nyour hard drive"' label 'Save'
  237.         button ID USE    port PrgPort command '"UsePrefs"'  help '"Use the settings for this session"' label 'Use'
  238.         button ID CANCEL port PrgPort command '"Quit"'      help '"Exit without changing the settings"' label 'Cancel'
  239.         endgroup
  240.     endwindow
  241. ;;;
  242. /* ;;; Set application details */
  243. address(GuiPort)
  244. 'application' MUIA_Application_Version VerStr
  245. 'application' MUIA_Application_Author 'Neil Bothwick'
  246. 'application' MUIA_Application_Copyright '© 1999 by Neil Bothwick, Wirenet'
  247. 'application' MUIA_Application_Title 'AACDprefs'
  248. 'application' MUIA_Application_Description 'Search Amiga Active CD, Aminet CD and Aminet index files'
  249. ;;;
  250. /* ;;; Main loop */
  251. call LoadPrefs()
  252. do forever
  253.     call waitpkt(PrgPort)
  254.     packet = getpkt(PrgPort)
  255.     if packet = '0000 0000'x then iterate
  256.     cmd = getarg(packet)
  257.     call reply(packet,0)
  258.     parse var cmd cmd args
  259.     args = strip(args)
  260.     interpret 'call 'cmd'("'args'")'
  261.     end
  262. ;;;
  263. /* ;;; Load prefs */
  264. LoadPrefs:
  265.     /* Load system settings */
  266.     if exists(CDPrefs) then PrefsFile = CDPrefs
  267.     else do
  268.         PrefsFile = DefCDPrefs
  269.         call ShowMsg('No system settings found, using defaults')
  270.         end
  271.     if ~open(prefs,PrefsFile,'R') then do
  272.         call ShowMsg('Failed to read system preferences file')
  273.         exit
  274.         end
  275.     do until eof(prefs)
  276.         PrefsLine = readln(prefs)
  277.         if PrefsLine = '' then iterate
  278.         if pos(left(PrefsLine,1),';#') > 0 then iterate
  279.         if left(PrefsLine,11) = 'CLASS=HTML2' 0 then iterate
  280.         parse var PrefsLine setting '=' value
  281.         interpret 'cycle id' setting 'label "'value'"'
  282.         end
  283.     call close(prefs)
  284.     AACDload = GetVar('AACDload')
  285.     if pos(AACDload,'03') = 0 then AACDload = 1
  286.  
  287.     AACDIndex = GetVar('AACDIndex')
  288.     AminetCDIndex = GetVar('AminetCDIndex')
  289.     AminetSetIndex = GetVar('AminetSetIndex')
  290.     AminetIndex = GetVar('AminetIndex')
  291.  
  292.     /* Load filetype settings */
  293.     if exists(IderPrefs) then PrefsFile = IderPrefs
  294.     else do
  295.         PrefsFile = DefIderPrefs
  296.         call ShowMsg('No filetype settings found, using defaults')
  297.         end
  298.     if ~open(prefs,PrefsFile,'R') then do
  299.         call ShowMsg('Failed to read filetype preferences file')
  300.         exit
  301.         end
  302.  
  303.     PrefsLine = readln(prefs)
  304.     setvar CfgVersion PrefsLine
  305.     ClassCount = 0
  306.     UseOpus = 0
  307.  
  308.     do until eof(prefs)
  309.         PrefsLine = readln(prefs)
  310.         if PrefsLine = '' then iterate
  311.         if pos(left(PrefsLine,1),';#') > 0 then iterate
  312.         ClassCount = ClassCount + 1
  313.         PrefsLine = substr(PrefsLine,pos('CLASS=',upper(PrefsLine)) + 6)
  314.         if left(PrefsLine,1) = '"' then parse var Prefsline '"' Class '"' PrefsLine /*Class = substr(PrefsLine,2,pos('"',PrefsLine,2) - 2)*/
  315.         else parse var PrefsLine Class PrefsLine
  316.         PrefsLine = strip(PrefsLine)
  317.         parse var PrefsLine Defn 'ACTION=' Action
  318.         interpret Class'.cmd="'word(Action,1)'"'
  319.         interpret Class'.arg="'subword(Action,2)'"'
  320.         if ClassCount = 1 & upper(Class) = 'DEFAULT' then UseOpus = 1
  321.         end
  322.     call close(prefs)
  323.  
  324.     cycle id FTYPE label Filetype.UseOpus
  325.     cycle id ARUN  label Autorun.AACDload
  326.     popasl ID AACD  CONTENT AACDIndex
  327.     popasl ID AMCD  CONTENT AminetCDIndex
  328.     popasl ID AMSET CONTENT AminetSetIndex
  329.     popasl ID AMONL CONTENT AminetIndex
  330.     call LoadGadgets('IFF','IFF_picture')
  331.     call LoadGadgets('GIF','GIF_picture')
  332.     call LoadGadgets('JPG','JPEG_picture')
  333.     call LoadGadgets('PNG','PNG_Picture')
  334.     call LoadGadgets('ANM','ANIM')
  335.     call LoadGadgets('MPG','MPEG_Video')
  336.     call LoadGadgets('MOV','Quicktime_Movie')
  337.     call LoadGadgets('AVI','AVI_Video')
  338.     call LoadGadgets('PDF','PDF_file')
  339.     call LoadGadgets('SVX','IFF_Sample')
  340.     call LoadGadgets('WAV','WAV_Sample')
  341.     call LoadGadgets('S3M','S3M_Module')
  342.     call LoadGadgets('XMM','XM_Module')
  343.     call LoadGadgets('MED','MED_Module')
  344.     call LoadGadgets('DBM','DBM_Module')
  345.     call LoadGadgets('MOD','Module')
  346.     call LoadGadgets('MP3','MPEG_Audio')
  347.     call LoadGadgets('MID','MIDI')
  348.     call LoadGadgets('AGD','Guide')
  349.     call LoadGadgets('HTM','HTML')
  350.     call LoadGadgets('LHA','LhA_Archive')
  351.     call LoadGadgets('DEF','Default')
  352.     return
  353. ;;;
  354. /* ;;; Set gadgets */
  355. LoadGadgets:
  356.     NM = arg(1)
  357.     Class = arg(2)
  358.     if symbol(Class'.cmd') = 'VAR' then do
  359.         interpret 'popasl ID 'NM'0 CONTENT 'Class'.cmd'
  360.         interpret 'string ID 'NM'1 CONTENT 'Class'.arg'
  361.         end
  362.     else do
  363.         interpret 'popasl ID 'NM'0 CONTENT "Execute"'
  364.         interpret 'string ID 'NM'1 CONTENT ":CDTools/S/NoAction"'
  365.         end
  366.     return
  367. ;;;
  368. /* ;;; Use prefs */
  369. UsePrefs:
  370.     parse arg sav
  371.  
  372.     /* Save system settings */
  373.     if ~open(prefs,CDPrefs,'W') then call ShowMsg('Failed to save preferences')
  374.     else do
  375.         call writeln(prefs,'# Amiga Active CD preferences - created by AACDprefs' word(sourceline(3),3)'0a'x)
  376.         do i = 1 to words(Settings)
  377.             setting = word(Settings,i)
  378.             cycle id setting
  379.             call writeln(prefs,setting'='result)
  380.             end
  381.         call close(prefs)
  382.         end
  383.  
  384.     /* Save filetype settings */
  385.     do i = 1 to words(FileTypes)
  386.         type = word(FileTypes,i)
  387.         interpret 'popasl ID' type'0'
  388.         command = result
  389.         if command = '' then command = 'Multiview'
  390.         interpret type '= command'
  391.         interpret 'string ID' type'1'
  392.         interpret type '= strip('type' result)'
  393.         end
  394.  
  395.     cycle id FTYPE
  396.     UseOpus = (result == 'Directory Opus')
  397.  
  398.     cycle id ARUN
  399.     select
  400.         when result = Autorun.0 then AACDload = 0
  401.         when result = Autorun.3 then AACDload = 3
  402.         otherwise AACDload = 1
  403.         end
  404.     address command 'setenv AACDload' AACDload
  405.  
  406.     popasl ID AACD
  407.     if result > '' then address command 'setenv AACDIndex' result
  408.     else do
  409.         address command 'unsetenv AACDIndex'
  410.         if sav=1 then call delete('ENVARC:AACDIndex')
  411.         end
  412.     popasl ID AMCD
  413.     if result > '' then address command 'setenv    AminetCDIndex' result
  414.     else do
  415.         address command 'unsetenv AminetCDIndex'
  416.         if sav=1 then call delete('ENVARC:AminetCDIndex')
  417.         end
  418.     popasl ID AMSET
  419.     if result > '' then address command 'setenv    AminetSetIndex' result
  420.     else do
  421.         address command 'unsetenv AminetSetIndex'
  422.         if sav=1 then call delete('ENVARC:AminetSetIndex')
  423.         end
  424.     popasl ID AMONL
  425.     if result > '' then address command 'setenv    AminetIndex' result
  426.     else do
  427.         address command 'unsetenv AminetIndex'
  428.         if sav=1 then call delete('ENVARC:AminetIndex')
  429.         end
  430.  
  431.     if ~open(prefs,IderPrefs,'W') then call ShowMsg('Failed to save preferences')
  432.     else do
  433.         call writeln(prefs,'# IDer Prefs file - created by AACDprefs' word(sourceline(3),3)'0a'x)
  434.         call writeln(prefs,'# IDer  --  © 1995 Eclipse Software'||'0a'x)
  435.  
  436.         /* Use Opus prefs */
  437.         if UseOpus = 1 then do
  438.             address command 'version >NIL: dopus5.library 55'
  439.             select
  440.                 when RC = 5 then call ShowMsg('Opus filetypes need as least version 5.5 of Directory Opus')
  441.                 when ~show('P','DOPUS.1') then call ShowMsg('You need to be running Directory Opus as\nWorkbench replacement to use Opus filetypes.')
  442.                 otherwise do
  443.                     call writeln(prefs,'CLASS=Default ACTION=dopus_dclick')
  444.                     /* Ensure dopus_dclick is in path */
  445.                     address command 'which >NIL: dopus_dclick'
  446.                     if RC = 5 then address command 'copy CDTools/DOpus/dopus_dclick C: clone'
  447.                     end
  448.                 end
  449.             end
  450.  
  451.         call writeln(prefs,'CLASS=IFF_Picture OFFSET=0,"FORM????ILBM" ACTION='IFF)
  452.         call writeln(prefs,'CLASS=GIF_Picture SUFFIX=.GIF OFFSET=0,"GIF87a" ACTION='GIF)
  453.         call writeln(prefs,'CLASS=JPEG_Picture OFFSET=6,4A464946 ACTION='JPG)
  454.         call writeln(prefs,'CLASS=PNG_Picture OFFSET=0,89504E47 ACTION='PNG)
  455.         call writeln(prefs,'CLASS=ANIM SUFFIX=.ANIM OFFSET=0,"FORM????ANIM" ACTION='ANM)
  456.         call writeln(prefs,'CLASS=MPEG_Video SUFFIX=.MPG ACTION='MPG)
  457.         call writeln(prefs,'CLASS=Quicktime_Movie SUFFIX=.(MOV|MV|QT) ACTION='MOV)
  458.         call writeln(prefs,'CLASS=AVI_Video SUFFIX=.AVI OFFSET=0,"RIFF" FLAGS=T ACTION='AVI)
  459.         call writeln(prefs,'CLASS=PDF_file SUFFIX=.PDF OFFSET=0,"%PDF" ACTION='PDF)
  460.         call writeln(prefs,'CLASS=IFF_Sample OFFSET=0,"FORM????8SVX" ACTION='SVX)
  461.         call writeln(prefs,'CLASS=WAV_Sample OFFSET=0,"RIFF????WAVE" ACTION='WAV)
  462.         call writeln(prefs,'CLASS=S3M_Module SUFFIX=.S3M NAME=S3M.#? OFFSET=44,"SCRM" FLAGS=T ACTION='S3M)
  463.         call writeln(prefs,'CLASS=XM_Module SUFFIX=.XM OFFSET=0,"Extended Module:" FLAGS=I ACTION='XMM)
  464.         call writeln(prefs,'CLASS=MED_Module SUFFIX=.MED NAME=MED.#? OFFSET=0,"MMD?" ACTION='MED)
  465.         call writeln(prefs,'CLASS=DBM_Module SUFFIX=.DBM OFFSET=0,"DBM0" ACTION='DBM)
  466.         call writeln(prefs,'CLASS=Module SUFFIX=.MOD NAME=MOD.#? OFFSET=1080,"M.K." FLAGS=T ACTION='MOD)
  467.         call writeln(prefs,'CLASS=MPEG_Audio NAME=(#?.MP3|#?.MP2) FLAGS=I ACTION='MP3)
  468.         call writeln(prefs,'CLASS=MIDI SUFFIX=.MID OFFSET=0,"MThd" ACTION='MID)
  469.         call writeln(prefs,'CLASS=Guide SUFFIX=.GUIDE OFFSET=0,"@database" FLAGS=I ACTION='AGD)
  470.         call writeln(prefs,'CLASS=HTML NAME=(#?.html|#?.htm) OFFSET=0,"<html" FLAGS=I ACTION='HTM)
  471.         call writeln(prefs,'CLASS=HTML2 NAME=(#?.html|#?.htm) OFFSET=0,"<!doctype" FLAGS=I ACTION='HTM)
  472.         call writeln(prefs,'CLASS=LhA_Archive NAME=(#?.LhA|?#.Lzh) OFFSET=2,"-lh?-" ACTION='LHA)
  473.         call writeln(prefs,'CLASS=Default ACTION='DEF)
  474.         call writeln(prefs,'0a'x||'#END')
  475.         call close(prefs)
  476.         end
  477.     if sav = 1 then do
  478.         address command 'copy >NIL:' CDPrefs 'ENVARC:'
  479.         address command 'copy >NIL:' IderPrefs 'ENVARC:'
  480.         if exists('ENV:AACDload') then address command 'copy >NIL: ENV:AACDload ENVARC:'
  481.         else call delete('ENVARC:AACDload')
  482.         if exists('ENV:AACDIndex') then address command 'copy >NIL: ENV:AACDIndex ENVARC:'
  483.         else call delete('ENVARC:AACDIndex')
  484.         if exists('ENV:AminetCDIndex') then address command 'copy >NIL: ENV:AminetCDIndex ENVARC:'
  485.         else call delete('ENVARC:AminetCDIndex')
  486.         if exists('ENV:AminetSetIndex') then address command 'copy >NIL: ENV:AminetSetIndex ENVARC:'
  487.         else call delete('ENVARC:AminetSetIndex')
  488.         if exists('ENV:AminetIndex') then address command 'copy >NIL: ENV:AminetIndex ENVARC:'
  489.         else call delete('ENVARC:AminetIndex')
  490.         end
  491.     call Quit()
  492.     return
  493. ;;;
  494. /* ;;; Show about requester */
  495. About:
  496.     request title '"'WinTitle'"' gadgets '"OK"' string VerStr' by Neil Bothwick\nCreated using MUIRexx 3.0a'
  497.     return
  498. ;;;
  499. /* ;;; Load a library */
  500. LoadLib:
  501.     parse arg library
  502.     if show('L',library) then return
  503.     if ~exists('LIBS:'library) then address command 'copy System/Libs/'library 'LIBS: clone quiet'
  504.     if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
  505.     return
  506. ;;;
  507. /* ;;; Check for a circular reference */
  508. Check:
  509.     arg prog
  510.     prog = strip(prog)
  511.     select
  512.         when prog = 'AACDFILE' then call ShowMsg('You cannot use AACDfile here')
  513.         when prog = 'CUCDFILE' then call ShowMsg('You cannot use CUCDfile here')
  514.         when prog = 'IDER' then call ShowMsg('You cannot use IDer here')
  515.         when pos(right(prog,9), '/AACDFILE :AACDFILE') > 0 then call ShowMsg('You cannot use AACDfile here')
  516.         when pos(right(prog,9), '/CUCDFILE :CUCDFILE') > 0 then call ShowMsg('You cannot use CUCDfile here')
  517.         when pos(right(prog,5), '/IDER :IDER') > 0 then call ShowMsg('You cannot use IDer here')
  518.         otherwise nop
  519.         end
  520.     return
  521. ;;;
  522. /* ;;; Update Index files */
  523. UpdateIndices:
  524.     parse arg IndexType
  525.  
  526.     /* Get CD name */
  527.     address command 'Assign >NIL: AACD: EXISTS'
  528.     if RC = 0 then CDName = 'AACD:'
  529.     else do
  530.         'application' MUIA_Application_Sleep TRUE
  531.         signal off error
  532.         do i = 20 to 0 by -1
  533.             CDName = 'AACD'right('0'i,2)':'
  534.             address command 'Assign >NIL: 'CDName' EXISTS'
  535.             if RC = 0 then leave
  536.             end
  537.         signal on error
  538.         'application' MUIA_Application_Sleep FALSE
  539.         if CDname = 'AACD00:' then do
  540.             call ShowMsg('Please insert the latest AACD and try again')
  541.             return
  542.             end
  543.         end
  544.  
  545.     /* Update AACD indices */
  546.     if pos(IndexType, 'AACD ALL') > 0 then do
  547.         popasl ID AACD
  548.         if result = '' then return
  549.         else DestDir = result
  550.         SrcDir = CDName'CDTools/Indices'
  551.         Pattern = ParsePattern('AACD??',NOCASE)
  552.         call CopyFiles()
  553.         end
  554.  
  555.     /* Update Aminet CD indices */
  556.     if pos(IndexType, 'AMCD ALL') > 0 then do
  557.         popasl ID AMCD
  558.         DestDir = result
  559.         SrcDir = CDName'AACD/CDROM/AminetCDs/CDs'
  560.         Pattern = ParsePattern('Index??',NOCASE)
  561.         call CopyFiles()
  562.         end
  563.  
  564.     /* Update Aminet Set indices */
  565.     if pos(IndexType, 'AMSET ALL') > 0 then do
  566.         popasl ID AMSET
  567.         DestDir = result
  568.         SrcDir = CDName'AACD/CDROM/AminetCDs/Sets'
  569.         Pattern = ParsePattern('Set?',NOCASE)
  570.         call CopyFiles()
  571.         end
  572.  
  573.     /* Update Aminet Online indices */
  574.     if pos(IndexType, 'AMONL ALL') > 0 then do
  575.         popasl ID AMONL
  576.         DestDir = result
  577.         if DestDir = '' then do
  578.             if IndexType ~= 'ALL' then call ShowMsg('You must specify a destination directory first')
  579.             return
  580.             end
  581.  
  582.         SrcDir = CDName'AACD/Online/Aminet'
  583.         'application' MUIA_Application_Sleep TRUE
  584.         call DateCopy('INDEX')
  585.         call DateCopy('dirlist')
  586.         call open(List,AddPart(SrcDir,'dirlist'),'R')
  587.         do until eof(List)
  588.             File = readln(List)
  589.             if File = '' then iterate
  590.             call DateCopy(File)
  591.             end
  592.         call close(List)
  593.         'application' MUIA_Application_Sleep FALSE
  594.         end
  595.     
  596.     call ShowMsg('All index files are up to date')
  597.     return
  598.  
  599. /* Copy the new files */
  600. CopyFiles:
  601.     if DestDir = '' then do
  602.         if IndexType ~= 'ALL' then call ShowMsg('You must specify a destination directory first')
  603.         return
  604.         end
  605.  
  606.     FileList = showdir(SrcDir)
  607.     'application' MUIA_Application_Sleep TRUE
  608.     do i = 1 to words(FileList)
  609.         if MatchPattern(Pattern,word(FileList,i),NOCASE,PARSED) then call DateCopy(word(FileList,i))
  610.         end
  611.     'application' MUIA_Application_Sleep FALSE
  612.     return
  613.  
  614. DateCopy:
  615.     parse arg FileName
  616.     if word(statef(AddPart(SrcDir,FileName)),5) > word(statef(AddPart(DestDir,FileName)),5) then address command 'Copy >NIL:' AddPart(SrcDir,FileName) DestDir 'CLONE'
  617.     return
  618. ;;;
  619. /* ;;; ShowMsg */
  620. ShowMsg:
  621.     parse arg msg
  622.     'request id MAIN title "'WinTitle'" gadgets "OK" string' msg
  623.     return
  624. ;;;
  625. /* ;;; Error handler */
  626. Error:
  627.     if RC = 5 then return
  628.     ErrLine = sourceline(sigl)
  629.     if pos(' ID',upper(subword(ErrLine,2,2))) > 0 then return
  630.     call ShowMsg('Error' RC 'in line' sigl'0a'x||ErrLine)
  631.     call Quit()
  632.     return
  633. ;;;
  634. /* ;;; Quit */
  635. Quit:
  636.     address(GuiPort)
  637.     'QUIT'
  638.     exit
  639. ;;;
  640.  
  641.