home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 18 / AACD18.BIN / AACDprefs < prev    next >
Encoding:
Text File  |  2001-01-24  |  24.3 KB  |  664 lines

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