home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / mods / psid / nemesids-extras.lzh / Utils / PSID2DBase.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1994-07-08  |  2.6 KB  |  84 lines

  1. /*
  2. ** Usage: PSID2DBase <filename>
  3. **
  4. ** $VER: PSID2DBase.rexx 1.0 (6.7.94)
  5. **
  6. ** Created on Wednesday 06-Jul-94 06:36:11 by Ulf Diabelez Harries
  7. **
  8. ** This script extracts Song-info from PlaySID One-Part files and
  9. ** displays them in SuperBase ASCII Delimited format in your console window.
  10. ** To be at any use at all, you'll have to re-direct the output and write
  11. ** a script to handle it; or use a program like Directory Opus.
  12. **
  13. ** Example:
  14. **
  15. **   You could use it with Directory Opus by configurating a button like
  16. **
  17. **   |AmigaDOS| |rx REXX:PSID2DBase.rexx {f} >>SBData:PlaySIDMusic.Asc|
  18. **
  19. **   and selecting the flags "Do all files" and "Recursive Directories".
  20. */
  21.  
  22. OPTIONS RESULTS
  23.  
  24. IF ARG() = 0 THEN DO                /* If no arguments */
  25.     SAY "Usage: PSID2DBase <filename>"    /* display usage   */
  26.     EXIT                    /* and exit        */
  27. END
  28.  
  29. PARSE ARG in_name
  30. SourceName = COMPRESS(in_name,'"')        /* Remove eventual " in filename */
  31. NULL = "00"X
  32.  
  33. IF SourceName = '?' THEN DO            /* If argument = ? */
  34.     SAY "Usage: PSID2DBase <filename>"    /* display usage   */
  35.     EXIT                    /* and exit        */
  36. END
  37.  
  38. IF ~EXISTS(SourceName) THEN DO            /* Check if file exists */
  39.     SAY 'Unable to locate file: "'SourceName'"'
  40.     EXIT
  41. END
  42.  
  43. /************************* Extract PlaySID infos *************************/
  44.  
  45. CALL OPEN(f,SourceName,R)            /* Open file */
  46.  
  47. line = READCH(f,8)                /* Read the first 8 chars in file */
  48. filetype = C2X(line)                /* and convert them to Hex */
  49.  
  50. IF filetype ~= '5053494400010076' THEN DO    /* Check if file is PSID */
  51.     SAY 'File "'SourceName'" is not a PlaySID One-Part file.'
  52.     CALL CLOSE(f)
  53.     EXIT
  54. END
  55.  
  56. Playaddress  = READCH(f,6)            /* Read play-addresses */
  57. Tunenum      = READCH(f,2)            /* Read number of Tunes */
  58. TunenumStart = READCH(f,2)            /* Read number of start-tune */
  59. Speed        = READCH(f,4)            /* Read speed data */
  60. Name1        = READCH(f,30)            /* Read Name */
  61. trash1       = READCH(f,2)
  62. Author1      = READCH(f,30)            /* Read Author */
  63. trash2       = READCH(f,2)
  64. Copyright1   = READCH(f,30)            /* Read Copyright */
  65.  
  66. CALL CLOSE(f)                    /* Close file */
  67.  
  68. Songs        = C2D(Tunenum)            /* Convert Tunes to Dec */
  69. SongStart    = C2D(TunenumStart)        /* Convert Start-Tune to Dec */
  70.  
  71. Name         = COMPRESS(Name1,NULL)        /* Remove NULL's */
  72. Author       = COMPRESS(Author1,NULL)        /* Remove NULL's */
  73. Copyright    = COMPRESS(Copyright1,NULL)    /* Remove NULL's */
  74.  
  75. DBaseLine  = '"'Name'","'Author'","'Copyright'","'Songs'","'SourceName'"'        /* Database file output format */
  76.  
  77. IF SongStart > 1 THEN DO
  78.     DBaseLine = '"'Name'","'Author'","'Copyright'","'Songs','SongStart'","'SourceName'"'    /* Database file output format */
  79. END
  80.  
  81. SAY DBaseLine                    /* Write DBase Output */
  82.  
  83. EXIT
  84.