' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Program Title: SPLIT-IT ' Copyright: Public Domain ' Author: A.A. van Zoelen ' Last Modified: 21-11-1997 ' Version: 1.0 ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Description: Split a file into smaller parts or glue ' the separate parts together again. ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Notes: DOS utility ' Written in PowerBasic 3.1 ' Part size must be given in bytes. ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Disclaimer: Use this program at your own risk. The programmer can't ' and will not been held responsible for any lost of ' information nor for any damage caused by using this ' program. You have been warned! ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' History: First issue 21-10-1997 ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Compiler switches '$CPU 80386 ' program works on any CPU '$OPTIMIZE SPEED ' make fastest possible executable '$COMPILE EXE ' compile to an executable '$DEBUG MAP OFF ' turn off map file generation '$DEBUG PBDEBUG OFF ' don't include pbdebug support in our executable '$DEBUG PATH OFF '$DEBUG UNIT OFF '$LIB COM OFF ' turn off PowerBASIC's communications library. '$LIB CGA OFF ' turn off PowerBASIC's CGA graphics library. '$LIB EGA OFF ' turn off PowerBASIC's EGA graphics library. '$LIB VGA OFF ' turn off PowerBASIC's VGA graphics library. '$LIB HERC OFF ' turn off PowerBASIC's hercules graphics library. '$LIB LPT OFF ' turn off PowerBASIC's printer support library. '$LIB IPRINT OFF ' turn off PowerBASIC's interpreted print library. '$LIB FULLFLOAT OFF ' turn off PowerBASIC's floating point support. '$ERROR BOUNDS ON ' turn on bounds checking '$ERROR NUMERIC ON ' turn on numeric checking '$ERROR OVERFLOW ON ' turn on overflow checking '$ERROR STACK ON ' turn on stack checking '$FLOAT PROCEDURE ' use procedural floating point to optimize for ' machines without a co-processor '$COM 0 ' set communications buffer to nothing '$STRING 32 ' set largest string size at 32750 CHAR. $STACK 4096 ' let's use a 4k stack '$SOUND 1 ' smallest music buffer possible '$DYNAMIC ' all arrays will be dynamic by default ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 'Program starts here. FUNCTION PBMAIN() AS LONG CmdLine$ = COMMAND$ CLS PRINT PRINT "Split-IT v1.0" PRINT "by A.A. van Zoelen" PRINT IF CmdLine$ = "?" OR CmdLine$ = "/?" THEN PRINT "Split a file into smaller parts" PRINT "or glue them together again." PRINT PRINT "USAGE : Split-IT " PRINT EXIT FUNCTION END IF PRINT "þ [S]plit or [G]lue :" DO A$ = UCASE$(INKEY$) IF A$ = CHR$(27) THEN EXIT FUNCTION LOOP UNTIL A$ = "S" OR A$ = "G" PRINT PRINT "þ Filename to "; IF A$ = "S" THEN LINE INPUT "split, incl. extention :"; FileName$ TestName$ = DIR$(FileName$) ELSE LINE INPUT "glue, excl. extention :"; FileName$ TestName$ = DIR$(FileName$ + ".*") END IF IF TestName$ = "" THEN PRINT PRINT "File not found : "; Filename$ EXIT FUNCTION END IF SELECT CASE A$ CASE "S" PRINT PRINT "þ Split file into pieces DO LINE INPUT "þ with a size of [bytes]:"; Size$ Size??? = VAL(Size$) LOOP UNTIL Size??? > 0 FileCount% = 1 LOCATE 12, 1 PRINT REPEAT$(FileCount%, "þ"); PRINT FileName$ OPEN FileName$ FOR BINARY AS 1 CALL FindPoint(FileName$, Extensie$) FileSize??? = 0 PartSize??? = 0 Check% = 0 OPEN FileName$ + LTRIM$(STR$(FileCount%)) FOR BINARY AS 2 PUT$ #2, Extensie$ PartSize??? = PartSize??? + LEN(extensie$) DO BlockSize% = MIN(Size???, Size??? - PartSize???, LOF(1) - FileSize???, 32750) FileSize??? = FileSize??? + BlockSize% PartSize??? = PartSize??? + BlockSize% GET$ #1, BlockSize%, Dump$ PUT$ #2, Dump$ IF PartSize??? => Size??? THEN PartSize??? = 0 CLOSE 2 INCR FileCount% OPEN FileName$ + LTRIM$(STR$(FileCount%)) FOR BINARY AS 2 PRINT REPEAT$(FileCount%, "þ"); PRINT FileName$ + LTRIM$(STR$(FileCount%)) END IF LOOP UNTIL EOF(1) OR BlockSize% = 0 CLOSE 2 CLOSE 1 CASE "G" FileCount% = 1 CALL FindPoint(FileName$, Extensie$) LOCATE 9, 1 PRINT "Now creating : "; FileName$ + "." + Extensie$ DO TestName$ = DIR$(FileName$ + "." + LTRIM$(STR$(FileCount%))) IF TestName$ <> "" THEN OPEN FileName$ + "." + LTRIM$(STR$(FileCount%)) FOR BINARY AS 1 IF FileCount% = 1 THEN GET$ #1, 3, Extensie$ OPEN FileName$ + "." + Extensie$ FOR BINARY AS 2 END IF PRINT REPEAT$(FileCount%, "þ"); " Now adding : "; PRINT FileName$; "."; LTRIM$(STR$(FileCount%)) FileSize??? = 0 DO BlockSize% = MIN(LOF(1) - FileSize???, 32750) FileSize??? = FileSize??? + BlockSize% GET$ #1, BlockSize%, Dump$ PUT$ #2, Dump$ LOOP UNTIL EOF(1) OR BlockSize% = 0 INCR FileCount% FileSize??? = 0 CLOSE 1 END IF LOOP UNTIL TestName$ = "" CLOSE 2 CLOSE 1 END SELECT END FUNCTION ' ÄÄÄ[ Sub routines ]ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Split the filename into a filename of 8 characters ' and an extention of 3 characters SUB FindPoint(FileName$, Extensie$) PUBLIC Place% = 0 Place% = INSTR(FileName$, ".") IF Place% <> 0 THEN Extensie$ = MID$(FileName$ + " ", Place% + 1, 3) FileName$ = LEFT$(FileName$, Place%) END IF END SUB ' ÄÄÄÄ[ End of File ]ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ