home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************/
- /* Compute!'s .MUS file conversion script V1.0b for SIDPLAYER */
- /* Written by David Poland on 9/1/94 */
- /*************************************************************************/
-
- /* Please note that this script requires "rexxsupport.library" in the
- libs directory */
-
- /* Change the prompt for input from shell */
-
- options prompt '> '
-
- /* If the library is not already loaded into memory then do so. Then we
- check to see if the library is available. If it is, load it up, if not
- report the error. */
-
- if ~show('L', "rexxsupport.library") then do
- if addlib('rexxsupport.library',0,-30,0) then
- say "Added rexxsupport.library"
- else do
- say "ERROR! Rexxsupport.library is required for this script."
- exit 10
- end
- end
-
-
- /* Announce who we are :-) */
-
- say ""
- say "* ConvertMUS arexx script V1.0b *"
-
- /* Get the current directory we are in */
-
- CurrentPath = pragma('D')
-
- /* Now get the destination directory where we will send the converted
- files to */
-
- GetDestDir(DestDir,CurrentPath)
-
- /* Assign the filenames (excluding subdirs etc) to a variable */
-
- FileList = showdir(CurrentPath, 'f', ':')
-
- /*************************************************************************/
- /* Now process all the filenames in the FileList */
- /*************************************************************************/
-
- ExitLoop = 0 /* Init our Boolean flag to FALSE */
- FileNumber = 0 /* Number of files converted */
-
- /* While ExitLoop is not equal to TRUE, keep looping */
-
-
- say ""
- say "File conversion in process..."
-
- do while ExitLoop ~= 1
-
- /* Each filename is separated by a colon as specified by the pragma
- command earlier. Find the position of the first colon */
-
- Position = index(FileList, ":")
-
- /* Now if no colon was found, we are done and exit the loop.
- If a colon was found, we need to extract the filename from
- the list and assign it to "FileName". Then we'll need to remove
- the filename from the list so we use DelStr to remove it. */
-
- if Position > 0 then do
- FileName = Left(FileList,Position-1)
- ConvertFile(pad)
- FileList = delstr(FileList,1,Position)
- end
- else do
- /* Here we need to check and see if only ONE filename is in the
- FileList and to process it if this is so. */
-
- if length(FileList) ~= 0 then do
- FileLength = Length(FileList)
- FileName = Left(FileList,FileLength)
- ConvertFile(pad)
- FileList = ""
- end
- else
- ExitLoop = 1
- end
-
- end /*DO*/
-
- say ""
- say "File conversion completed! " || FileNumber || " files converted."
- say ""
-
- exit
-
- /*************************************************************************/
- /* Procedure to handle the actual file conversion */
- /*************************************************************************/
-
- ConvertFile:
-
- arg pad /* Can't call a function without an arg so we provide a dummy */
-
- InfoString = ".mus"
-
- /* Check to see if we have a Compute! .MUS file */
-
- InfoFlag = pos(upper(InfoString),upper(FileName))
-
- /* For the .MUS file we need to make an icon for it indicating that
- it is a .MUS SID file, then we need to run the conversion program
- over it to turn it into one file. */
-
- if InfoFlag ~= 0 then do
- NewFileName = left(FileName,length(FileName)-4) /*Strip .mus off*/
- NewFileName = space(NewFileName,0) /* Strip out spaces */
-
- address command "sid:MakeSIDIcon " || """" || FileName || """" ||,
- " SID"
-
- address command "sid:sidconv " || """" || FileName || """" || " " ||,
- DestDir || "/" || NewFileName
-
- FileNumber = FileNumber + 1
- end
-
- return 0
-
- /*************************************************************************/
- /* Procedure to handle destination directory */
- /*************************************************************************/
-
- GetDestDir:
-
- arg DestDir, CurrentPath
-
- say ""
- say "Please enter the path for the destination of the converted files."
- say "NOTE!!! Do not select the current directory as the destination or"
- say "your original files will be overwritten!!!"
- say ""
- say "Current directory path is: " || CurrentPath
- say ""
-
- pull DestDir
-
- /* Strip off a "/" on the end if the user added one. */
-
- if pos("/",DestDir,length(DestDir)) ~= 0 then
- DestDir = left(DestDir,Length(DestDir)-1)
-
- /* Check to see if the selected destination directory exists, if
- it does, then continue on, if not ask if they want to create it */
-
- if ~exists(DestDir) then do
- say ""
- say "The selected destination directory does not exist. Shall I"
- say "create it for you? (Y/N)"
- pull Answer
-
- if Answer = "Y" then do
- address command "makedir " || DestDir
- say "Directory " || DestDir || " has been created."
- end
- else do
- say "Directory not created - script aborted."
- exit
- end
-
- end
-
- return DestDir
-