home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 19 / AACD19.BIN / AACDprefs < prev    next >
Text File  |  2001-02-26  |  26KB  |  692 lines

  1. /*
  2.     Preferences editor for Amiga Active CDs
  3.     $VER: AACDprefs 1.9 (20.2.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.     select
  272.         when exists(CDPrefs) then PrefsFile = CDPrefs
  273.         when exists(DefCDPrefs) then do
  274.             PrefsFile = DefCDPrefs
  275.             call ShowMsg('No system settings found, using defaults')
  276.             end
  277.         otherwise call ExitMsg('You have no existing system preferences\nPlease run AACDPrefs from an Amiga Active CD')
  278.         end
  279.  
  280.     if ~open(prefs,PrefsFile,'R') then call ExitMsg('Failed to read system preferences file')
  281.     do until eof(prefs)
  282.         PrefsLine = readln(prefs)
  283.         if PrefsLine = '' then iterate
  284.         if pos(left(PrefsLine,1),';#') > 0 then iterate
  285.         if left(PrefsLine,11) = 'CLASS=HTML2' 0 then iterate
  286.         parse var PrefsLine setting '=' value
  287.         interpret 'cycle id' setting 'label "'value'"'
  288.         end
  289.     call close(prefs)
  290.     AACDView = GetVar('AACDView')
  291.     AACDload = GetVar('AACDload')
  292.     if pos(AACDload,'03') = 0 then AACDload = 1
  293.  
  294.     AACDIndex = GetVar('AACDIndex')
  295.     AminetCDIndex = GetVar('AminetCDIndex')
  296.     AminetSetIndex = GetVar('AminetSetIndex')
  297.     AminetIndex = GetVar('AminetIndex')
  298.  
  299.     /* Load filetype settings */
  300.     select
  301.         when exists(IderPrefs) then PrefsFile = IderPrefs
  302.         when exists(DefIderPrefs) then do
  303.             PrefsFile = DefIderPrefs
  304.             call ShowMsg('No filetype settings found, using defaults')
  305.             end
  306.         otherwise call ExitMsg('You have no existing filetype preferences\nPlease run AACDPrefs from an Amiga Active CD')
  307.         end
  308.  
  309.     if ~open(prefs,PrefsFile,'R') then call ExitMsg('Failed to read filetype preferences file')
  310.     PrefsLine = readln(prefs)
  311.     setvar CfgVersion PrefsLine
  312.     ClassCount = 0
  313.     Filetyping = 0
  314.  
  315.     do until eof(prefs)
  316.         PrefsLine = readln(prefs)
  317.         if PrefsLine = '' then iterate
  318.         if pos(left(PrefsLine,1),';#') > 0 then iterate
  319.         ClassCount = ClassCount + 1
  320.         PrefsLine = substr(PrefsLine,pos('CLASS=',upper(PrefsLine)) + 6)
  321.         if left(PrefsLine,1) = '"' then parse var Prefsline '"' Class '"' PrefsLine /*Class = substr(PrefsLine,2,pos('"',PrefsLine,2) - 2)*/
  322.         else parse var PrefsLine Class PrefsLine
  323.         PrefsLine = strip(PrefsLine)
  324.         parse var PrefsLine Defn 'ACTION=' Action
  325.         interpret Class'.cmd="'word(Action,1)'"'
  326.         interpret Class'.arg="'subword(Action,2)'"'
  327.         if ClassCount = 1 & upper(Class) = 'DEFAULT' then do
  328.             if upper(Action) = 'DOPUS_DCLICK' then Filetyping = 1
  329.             else Filetyping = 2
  330.             end
  331.         end
  332.     call close(prefs)
  333.  
  334.     cycle  ID FTYPE label Filetype.Filetyping
  335.     cycle  ID ARUN  label Autorun.AACDload
  336.     cycle  ID CDVW  label AACDView
  337.     popasl ID AACD  CONTENT AACDIndex
  338.     popasl ID AMCD  CONTENT AminetCDIndex
  339.     popasl ID AMSET CONTENT AminetSetIndex
  340.     popasl ID AMONL CONTENT AminetIndex
  341.     call LoadGadgets('IFF','IFF_picture')
  342.     call LoadGadgets('GIF','GIF_picture')
  343.     call LoadGadgets('JPG','JPEG_picture')
  344.     call LoadGadgets('PNG','PNG_Picture')
  345.     call LoadGadgets('ANM','ANIM')
  346.     call LoadGadgets('MPG','MPEG_Video')
  347.     call LoadGadgets('MOV','Quicktime_Movie')
  348.     call LoadGadgets('AVI','AVI_Video')
  349.     call LoadGadgets('PDF','PDF_file')
  350.     call LoadGadgets('SVX','IFF_Sample')
  351.     call LoadGadgets('WAV','WAV_Sample')
  352.     call LoadGadgets('S3M','S3M_Module')
  353.     call LoadGadgets('XMM','XM_Module')
  354.     call LoadGadgets('MED','MED_Module')
  355.     call LoadGadgets('DBM','DBM_Module')
  356.     call LoadGadgets('MOD','Module')
  357.     call LoadGadgets('MP3','MPEG_Audio')
  358.     call LoadGadgets('MID','MIDI')
  359.     call LoadGadgets('AGD','Guide')
  360.     call LoadGadgets('HTM','HTML')
  361.     call LoadGadgets('LHA','LhA_Archive')
  362.     call LoadGadgets('DEF','Default')
  363.     return
  364. ;;;
  365. /* ;;; Set gadgets */
  366. LoadGadgets:
  367.     NM = arg(1)
  368.     Class = arg(2)
  369.     if symbol(Class'.cmd') = 'VAR' then do
  370.         interpret 'popasl ID 'NM'0 CONTENT 'Class'.cmd'
  371.         interpret 'string ID 'NM'1 CONTENT 'Class'.arg'
  372.         end
  373.     else do
  374.         interpret 'popasl ID 'NM'0 CONTENT "Execute"'
  375.         interpret 'string ID 'NM'1 CONTENT ":CDTools/S/NoAction"'
  376.         end
  377.     return
  378. ;;;
  379. /* ;;; Use prefs */
  380. UsePrefs:
  381.     parse arg sav
  382.  
  383.     /* Save system settings */
  384.     if ~open(prefs,CDPrefs,'W') then call ShowMsg('Failed to save preferences')
  385.     else do
  386.         call writeln(prefs,'# Amiga Active CD preferences - created by AACDprefs' word(sourceline(3),3)'0a'x)
  387.         do i = 1 to words(Settings)
  388.             setting = word(Settings,i)
  389.             cycle id setting
  390.             call writeln(prefs,setting'='result)
  391.             end
  392.         call close(prefs)
  393.         end
  394.  
  395.     /* Save filetype settings */
  396.     do i = 1 to words(FileTypes)
  397.         type = word(FileTypes,i)
  398.         interpret 'popasl ID' type'0'
  399.         command = result
  400.         if command = '' then command = 'Multiview'
  401.         interpret type '= command'
  402.         interpret 'string ID' type'1'
  403.         interpret type '= strip('type' result)'
  404.         end
  405.  
  406.     cycle id FTYPE
  407.     select
  408.         when result = Filetype.1 then Filetyping = 1
  409.         when result = Filetype.2 then Filetyping = 2
  410.         otherwise Filetyping = 0
  411.         end
  412.  
  413.     cycle id ARUN
  414.     select
  415.         when result = Autorun.0 then AACDload = 0
  416.         when result = Autorun.3 then AACDload = 3
  417.         otherwise AACDload = 1
  418.         end
  419.     address command 'setenv AACDload' AACDload
  420.  
  421.     cycle id CDVW
  422.     address command 'setenv AACDView' result
  423.  
  424.     popasl ID AACD
  425.     if result > '' then address command 'setenv AACDIndex' result
  426.     else do
  427.         address command 'unsetenv AACDIndex'
  428.         if sav=1 & exists('ENVARC:AACDIndex') then call delete('ENVARC:AACDIndex')
  429.         end
  430.     popasl ID AMCD
  431.     if result > '' then address command 'setenv    AminetCDIndex' result
  432.     else do
  433.         address command 'unsetenv AminetCDIndex'
  434.         if sav=1 & exists('ENVARC:AminetCDIndex') then call delete('ENVARC:AminetCDIndex')
  435.         end
  436.     popasl ID AMSET
  437.     if result > '' then address command 'setenv    AminetSetIndex' result
  438.     else do
  439.         address command 'unsetenv AminetSetIndex'
  440.         if sav=1 & exists('ENVARC:AminetSetIndex') then call delete('ENVARC:AminetSetIndex')
  441.         end
  442.     popasl ID AMONL
  443.     if result > '' then address command 'setenv    AminetIndex' result
  444.     else do
  445.         address command 'unsetenv AminetIndex'
  446.         if sav=1 & exists('ENVARC:AminetIndex') then call delete('ENVARC:AminetIndex')
  447.         end
  448.  
  449.     if ~open(prefs,IderPrefs,'W') then call ShowMsg('Failed to save preferences')
  450.     else do
  451.         call writeln(prefs,'# IDer Prefs file - created by AACDprefs' word(sourceline(3),3)'0a'x)
  452.         call writeln(prefs,'# IDer  --  © 1995 Eclipse Software'||'0a'x)
  453.  
  454.         /* Use Opus filetypes */
  455.         if Filetyping = 1 then do
  456.             signal off error
  457.             options failat 21
  458.             address command 'version >NIL: dopus5.library 55'
  459.             signal on error
  460.             options failat 10
  461.  
  462.             select
  463.                 when RC = 5 then call ShowMsg('Opus filetypes need as least version 5.5 of Directory Opus')
  464.                 when ~show('P','DOPUS.1') then call ShowMsg('You need to be running Directory Opus as\nWorkbench replacement to use Opus filetypes.')
  465.                 otherwise do
  466.                     call writeln(prefs,'CLASS=Default ACTION=dopus_dclick')
  467.                     /* Ensure dopus_dclick is in path */
  468.                     address command 'which >NIL: dopus_dclick'
  469.                     if RC = 5 then address command 'copy CDTools/DOpus/dopus_dclick C: clone'
  470.                     end
  471.                 end
  472.             end
  473.  
  474.         /* Use other filetyping system */
  475.         if Filetyping = 2 then call writeln(prefs,'CLASS=Default ACTION='DEF)
  476.  
  477.         call writeln(prefs,'CLASS=IFF_Picture OFFSET=0,"FORM????ILBM" ACTION='IFF)
  478.         call writeln(prefs,'CLASS=GIF_Picture SUFFIX=.GIF OFFSET=0,"GIF87a" ACTION='GIF)
  479.         call writeln(prefs,'CLASS=JPEG_Picture OFFSET=6,4A464946 ACTION='JPG)
  480.         call writeln(prefs,'CLASS=PNG_Picture OFFSET=0,89504E47 ACTION='PNG)
  481.         call writeln(prefs,'CLASS=ANIM SUFFIX=.ANIM OFFSET=0,"FORM????ANIM" ACTION='ANM)
  482.         call writeln(prefs,'CLASS=MPEG_Video SUFFIX=.MPG ACTION='MPG)
  483.         call writeln(prefs,'CLASS=Quicktime_Movie SUFFIX=.(MOV|MV|QT) ACTION='MOV)
  484.         call writeln(prefs,'CLASS=AVI_Video SUFFIX=.AVI OFFSET=0,"RIFF" FLAGS=T ACTION='AVI)
  485.         call writeln(prefs,'CLASS=PDF_file SUFFIX=.PDF OFFSET=0,"%PDF" ACTION='PDF)
  486.         call writeln(prefs,'CLASS=IFF_Sample OFFSET=0,"FORM????8SVX" ACTION='SVX)
  487.         call writeln(prefs,'CLASS=WAV_Sample OFFSET=0,"RIFF????WAVE" ACTION='WAV)
  488.         call writeln(prefs,'CLASS=S3M_Module SUFFIX=.S3M NAME=S3M.#? OFFSET=44,"SCRM" FLAGS=T ACTION='S3M)
  489.         call writeln(prefs,'CLASS=XM_Module SUFFIX=.XM OFFSET=0,"Extended Module:" FLAGS=I ACTION='XMM)
  490.         call writeln(prefs,'CLASS=MED_Module SUFFIX=.MED NAME=MED.#? OFFSET=0,"MMD?" ACTION='MED)
  491.         call writeln(prefs,'CLASS=DBM_Module SUFFIX=.DBM OFFSET=0,"DBM0" ACTION='DBM)
  492.         call writeln(prefs,'CLASS=Module SUFFIX=.MOD NAME=MOD.#? OFFSET=1080,"M.K." FLAGS=T ACTION='MOD)
  493.         call writeln(prefs,'CLASS=MPEG_Audio NAME=(#?.MP3|#?.MP2) FLAGS=I ACTION='MP3)
  494.         call writeln(prefs,'CLASS=MIDI SUFFIX=.MID OFFSET=0,"MThd" ACTION='MID)
  495.         call writeln(prefs,'CLASS=Guide SUFFIX=.GUIDE OFFSET=0,"@database" FLAGS=I ACTION='AGD)
  496.         call writeln(prefs,'CLASS=HTML NAME=(#?.html|#?.htm) OFFSET=0,"<html" FLAGS=I ACTION='HTM)
  497.         call writeln(prefs,'CLASS=HTML2 NAME=(#?.html|#?.htm) OFFSET=0,"<!doctype" FLAGS=I ACTION='HTM)
  498.         call writeln(prefs,'CLASS=LhA_Archive NAME=(#?.LhA|?#.Lzh) OFFSET=2,"-lh?-" ACTION='LHA)
  499.         call writeln(prefs,'CLASS=Default ACTION='DEF)
  500.         call writeln(prefs,'0a'x||'#END')
  501.         call close(prefs)
  502.         end
  503.     if sav = 1 then do
  504.         call UpdateEnv(CDPrefs)
  505.         call UpdateEnv(IderPrefs)
  506.         call UpdateEnv('AACDView')
  507.         call UpdateEnv('AACDload')
  508.         call UpdateEnv('AACDIndex')
  509.         call UpdateEnv('AminetCDIndex')
  510.         call UpdateEnv('AminetSetIndex')
  511.         call UpdateEnv('AminetIndex')
  512.         end
  513.     call Quit()
  514.     return
  515. ;;;
  516. /* ;;; Show about requester */
  517. About:
  518.     request title '"'WinTitle'"' gadgets '"OK"' string VerStr' by Neil Bothwick\nCreated using MUIRexx 3.0a'
  519.     return
  520. ;;;
  521. /* ;;; Load a library */
  522. LoadLib:
  523.     parse arg library
  524.     if show('L',library) then return
  525.     if ~exists('LIBS:'library) then address command 'copy System/Libs/'library 'LIBS: clone quiet'
  526.     if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
  527.     return
  528. ;;;
  529. /* ;;; Check for a circular reference */
  530. Check:
  531.     arg prog
  532.     prog = strip(prog)
  533.     select
  534.         when prog = 'AACDFILE' then call ShowMsg('You cannot use AACDfile here')
  535.         when prog = 'CUCDFILE' then call ShowMsg('You cannot use CUCDfile here')
  536.         when prog = 'IDER' then call ShowMsg('You cannot use IDer here')
  537.         when pos(right(prog,9), '/AACDFILE :AACDFILE') > 0 then call ShowMsg('You cannot use AACDfile here')
  538.         when pos(right(prog,9), '/CUCDFILE :CUCDFILE') > 0 then call ShowMsg('You cannot use CUCDfile here')
  539.         when pos(right(prog,5), '/IDER :IDER') > 0 then call ShowMsg('You cannot use IDer here')
  540.         otherwise nop
  541.         end
  542.     return
  543. ;;;
  544. /* ;;; Update Index files */
  545. UpdateIndices:
  546.     parse arg IndexType
  547.  
  548.     /* Get CD name */
  549.     parse source . ' ' . ' ' . ' ' ScriptName ' ' .
  550.     CDName = left(ScriptName, pos(':', ScriptName))
  551.     /* If script is not run from an AACD */
  552.     if ~abbrev(CDName, 'AACD') then do
  553.         signal off error
  554.         address command 'Assign >NIL: AACD: EXISTS'
  555.         signal on error
  556.  
  557.         if RC = 0 then CDName = 'AACD:'
  558.         else do
  559.             'application' MUIA_Application_Sleep TRUE
  560.             signal off error
  561.             do i = 25 to 0 by -1
  562.                 CDName = 'AACD'right('0'i,2)':'
  563.                 address command 'Assign >NIL: 'CDName' EXISTS'
  564.                 if RC = 0 then leave
  565.                 end
  566.             signal on error
  567.             'application' MUIA_Application_Sleep FALSE
  568.             if CDname = 'AACD00:' then do
  569.                 call ShowMsg('Please insert the latest AACD and try again')
  570.                 return
  571.                 end
  572.             end
  573.         end
  574.  
  575.     /* Update AACD indices */
  576.     if pos(IndexType, 'AACD ALL') > 0 then do
  577.         'application' MUIA_Application_Sleep TRUE
  578.         popasl ID AACD
  579.         if result = '' then return
  580.         else DestDir = result
  581.         SrcDir = CDName'CDTools/Indices'
  582.         Pattern = ParsePattern('AACD??',NOCASE)
  583.         call CopyFiles()
  584.         if ~exists(AddPart(DestDir, 'AACD01')) then address command CDName'System/C/LhA -q x "'AddPart(SrcDir, 'OldIndices.lha')'" "'AddPart(DestDir,'')'"'
  585.         'application' MUIA_Application_Sleep FALSE
  586.         end
  587.  
  588.     /* Update Aminet CD indices */
  589.     if pos(IndexType, 'AMCD ALL') > 0 then do
  590.         'application' MUIA_Application_Sleep TRUE
  591.         popasl ID AMCD
  592.         DestDir = result
  593.         SrcDir = CDName'AACD/CDROM/AminetCDs/CDs'
  594.         Pattern = ParsePattern('Index??',NOCASE)
  595.         call CopyFiles()
  596.         'application' MUIA_Application_Sleep FALSE
  597.         end
  598.  
  599.     /* Update Aminet Set indices */
  600.     if pos(IndexType, 'AMSET ALL') > 0 then do
  601.         'application' MUIA_Application_Sleep TRUE
  602.         popasl ID AMSET
  603.         DestDir = result
  604.         SrcDir = CDName'AACD/CDROM/AminetCDs/Sets'
  605.         Pattern = ParsePattern('Set?',NOCASE)
  606.         call CopyFiles()
  607.         'application' MUIA_Application_Sleep FALSE
  608.         end
  609.  
  610.     /* Update Aminet Online indices */
  611.     if pos(IndexType, 'AMONL ALL') > 0 then do
  612.         popasl ID AMONL
  613.         DestDir = result
  614.         if DestDir = '' then do
  615.             if IndexType ~= 'ALL' then call ShowMsg('You must specify a destination directory first')
  616.             return
  617.             end
  618.  
  619.         SrcDir = CDName'AACD/Online/Aminet'
  620.         'application' MUIA_Application_Sleep TRUE
  621.         call DateCopy('INDEX')
  622.         call DateCopy('dirlist')
  623.         call open(List,AddPart(SrcDir,'dirlist'),'R')
  624.         do until eof(List)
  625.             File = readln(List)
  626.             if File = '' then iterate
  627.             call DateCopy(File)
  628.             end
  629.         call close(List)
  630.         'application' MUIA_Application_Sleep FALSE
  631.         end
  632.     
  633.     call ShowMsg('All index files are up to date')
  634.     return
  635.  
  636. /* Copy the new files */
  637. CopyFiles:
  638.     if DestDir = '' then do
  639.         if IndexType ~= 'ALL' then call ShowMsg('You must specify a destination directory first')
  640.         return
  641.         end
  642.  
  643.     FileList = showdir(SrcDir)
  644.     do i = 1 to words(FileList)
  645.         if MatchPattern(Pattern,word(FileList,i),NOCASE,PARSED) then call DateCopy(word(FileList,i))
  646.         end
  647.     return
  648.  
  649. DateCopy:
  650.     parse arg FileName
  651.     if word(statef(AddPart(SrcDir,FileName)),5) > word(statef(AddPart(DestDir,FileName)),5) then address command 'Copy >NIL:' AddPart(SrcDir,FileName) DestDir 'CLONE'
  652.     return
  653. ;;;
  654. /* ;;; ShowMsg */
  655. ShowMsg:
  656.     parse arg msg
  657.     'request id MAIN title "'WinTitle'" gadgets "OK" string' msg
  658.     return
  659. ;;;
  660. /* ;;; Exit with a message */
  661. ExitMsg:
  662.     parse arg msg
  663.     call ShowMsg(msg)
  664.     call Quit()
  665.     return
  666. ;;;
  667. /* ;;; Error handler */
  668. Error:
  669.     if RC = 5 then return
  670.     ErrLine = sourceline(sigl)
  671.     if pos(' ID',upper(subword(ErrLine,2,2))) > 0 then return
  672.     call ShowMsg('Error' RC 'in line' sigl'0a'x||ErrLine)
  673.     call Quit()
  674.     return
  675. ;;;
  676. /* ;;; Update environment variable */
  677. UpdateEnv: procedure expose GuiPort
  678.     parse arg EnvVar
  679.     OldDir = pragma('D', 'ENV:')
  680.     if exists(EnvVar) then address command 'Copy >NIL: 'EnvVar' ENVARC: CLONE'
  681.     else if exists('ENVARC:'EnvVar) then call delete('ENVARC:'EnvVar)
  682.     call pragma('D', OldDir)
  683.     return
  684. ;;;
  685. /* ;;; Quit */
  686. Quit:
  687.     address(GuiPort)
  688.     'QUIT'
  689.     exit
  690. ;;;
  691.  
  692.