/* This ARexx-script is Public Domain. It's enclosed to the FreeWare program Viewer. It's meant to show off all chunks of ANY IFF-file, so that easily Viewer can be extended to view ascii-texts out off ANY IFF-file that contains plain character datas. THE IDEA FOR THIS APPLICATION INSPIRATED THROUGH SIFT WRITTEN BY LEO L. SCHWAB. This script written in 1994 by: Joerg van de Loo Hoevel 15 47559 Kranenburg Germany */ ARG FileName IF FileName == '' THEN DO SAY 'ShowIFFChunks: Need file name as parameter!' EXIT 20 END IF ~EXISTS(FileName) THEN DO SAY 'Couldn''t find the file - file does not exists, respectively!' EXIT 10 END Open('File', FileName, 'R') /* First, we have to open the file */ String = READCH('File', 4) /* Read in first 4 bytes of file */ IF String ~= 'FORM' THEN DO /* Must be labelled as "FORM" ! */ SAY 'File does own right fromat!' EXIT 5 END SEEK('File', 4, 'C') /* Overread length of FORM-Chunk */ String = READCH('File', 4) /* Get ID (group) of file */ SAY 'Type of file:' String DO FOREVER /* Never ending */ true = EOF('File') /* End of file ? */ IF true == 1 THEN /* In case it's 1 then yes... */ BREAK ELSE String = READCH('File', 4) /* Name of Chunk */ IF String == 'ILBM' THEN DO /* In case it's the ILBM-Chunk no length will follow */ SAY 'Name of Chunk: ILBM.' /* but the BMHD, this one owns one */ String = READCH('File', 4) /* New Chunk-name! */ END Length = READCH('File', 4) /* Length of Chunk */ IF String == "" THEN /* No name? */ BREAK /* If so, no output and end! */ ELSE /* Esle, output and continue! */ SAY 'Name of Chunk:' String', Length:' C2D(Length) 'Bytes.' IF String == 'NAME' THEN DO PrintStr( C2D(Length)) END IF String == '(c) ' THEN DO PrintStr( C2D(Length)) END IF String == 'AUTH' THEN DO PrintStr( C2D(Length)) END IF String == 'ANNO' THEN DO PrintStr( C2D(Length)) END IF String == 'CHRS' THEN DO PrintStr( C2D(Length)) END /* The FORM-Chunk represents in an ANIM-file the length of one! Frame. This length includes all other Chunks, e.g. ANHD und DLTA; because we want to see those Chunks too, we only have to ignore the length setting - this can be easily done via "Seek" and an offset to current by zero. */ IF String == 'FORM' THEN Length = D2C(0) /* If FORM-Chunk, ignore length! */ /* Now we have to check for not by two divisible lengths. Because a Chunk can own a un-even length, we have to check and! correct this, too. Otherwise the file cursor points not to a Chunk anymore, since the offset for a Chunk within a file is ever even! */ IF BITTST(C2D(Length), 0) == 1 THEN DO /* Odd or not... */ SAY ' »» Warning: Chunk-Length odd, going to extent it...' Ext = C2D(Length) /* Odd length to Ext */ Ext = Ext+1 /* Length + 1 */ Length = D2C(Ext) /* Set corrected length */ END SEEK('File', C2D(Length), 'C') /* Overread last Chunk */ END EXIT /* If we reach this point, we'll quit the program */ /*----------------------------------------------*/ PrintStr: PROCEDURE ARG len NewString = READCH('File', len) Say ' Text contents: "'NewString'"' len = len - (len * 2) SEEK('File', len, 'C') RETURN 0 /*----------------------------------------------*/