home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 14 / AACD14.ISO / AACDprefs < prev    next >
Text File  |  2000-05-29  |  25KB  |  653 lines

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