' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Program Title: SPLIT-IT ' Copyright: Public Domain ' Author: A.A. van Zoelen ' Last Modified: 25-09-1998 ' Version: 2.2 ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Description: Split a file into smaller parts or glue ' the separate parts together again. ' A file can be split up in as many as 999 parts. ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Notes: ' v 1.0 DOS utility ' Written in PowerBasic 3.1 ' Part size must be given in bytes. ' v 2.0 Rewritten for Win95/98/NT4.0 with PBCC 1.0 ' Backwards compatible with version 1.0 ' Drag and Drop aware. Runs also in a DOS box and ' accepts commandline input. ' v 2.1 Split-it now checks to see if all parts ' are available. ' v 2.2 Chunks bug fixed. Now the max number of parts is 999. ' Entering negative sizes are now corrected. ' Product info added as a seperate text file. ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' 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 ' Rev. 2.0 10-09-1998 ' Rev. 2.1 11-09-1998 ' Rev. 2.2 27-09-1998 ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Compiler switches $STACK 4096 ' let's use a 4k stack $OPTION VERSION4 ' Win95/98 and NT 4.0 compatible ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 'Program starts here. FUNCTION PBMAIN() AS LONG CmdLine$ = COMMAND$ DIM Revision AS STRING * 13 ' Always keep a string of 13 characters Revision = "Split-IT v2.2" CLS PRINT PRINT Revision PRINT "by A.A. van Zoelen" PRINT PRINT "- 32bit Windows95/98/NT4.0 version. PRINT ' Is there anything at the commandline? ' Is it an request for help? Dump$ = UCASE$(CmdLine$) SELECT CASE Dump$ CASE "?", "/?", "HELP", "H" PRINT "Split a file into smaller parts" PRINT "or glue them together again." PRINT PRINT "USAGE : Split-IT " PRINT " Double-click or Drag and Drop on it." PRINT PRINT "Press any key to continue." INPUT FLUSH Dump$ = WAITKEY$ EXIT FUNCTION END SELECT ' Or is there noting on the commandline. IF CmdLine$ = "" THEN PRINT PRINT "þ [S]plit or [G]lue :" DO Choice$ = UCASE$(INKEY$) IF Choice$ = CHR$(27) THEN EXIT FUNCTION LOOP UNTIL Choice$ = "S" OR Choice$ = "G" PRINT PRINT "þ Filename to "; IF Choice$ = "S" THEN LINE INPUT "split, incl. extention :"; FileName$ TestName$ = DIR$(FileName$) ELSE LINE INPUT "glue, excl. extention :"; FileName$ TestName$ = DIR$(FileName$ + ".*") END IF END IF ' There is something at the commandline. IF CmdLine$ <> "" THEN Choice$ = "" FileName$ = CmdLine$ TestName$ = DIR$(FileName$) ' Check if file is already split ' and if so which version is used? FileNO% = FREEFILE OPEN FileName$ FOR BINARY AS FileNO% GET$ #FileNO%, LEN(Revision), Dump$ SELECT CASE Dump$ CASE Revision, "Split-IT v2.0", "Split-IT v2.1" Choice$ = "G" END SELECT CLOSE FileNO% ' The file on the commandline is not split yet ' or is split with an older version of Split-It. IF Choice$ = "" THEN PRINT PRINT "þ [S]plit or [G]lue : "; DO Choice$ = UCASE$(INKEY$) IF Choice$ = CHR$(27) THEN EXIT FUNCTION LOOP UNTIL Choice$ = "S" OR Choice$ = "G" PRINT END IF SELECT CASE Choice$ CASE "S" IF CmdLine$ = "" THEN PRINT "þ Filename to "; LINE INPUT "split, incl. extention :"; FileName$ TestName$ = DIR$(FileName$) ELSE FileName$ = CmdLine$ TestName$ = DIR$(FileName$) END IF CASE "G" IF CmdLine$ = "" THEN PRINT "þ Filename to "; LINE INPUT "glue, excl. extention :"; FileName$ TestName$ = DIR$(FileName$) ELSE CALL FindPoint(CmdLine$, Dump$) TestName$ = LEFT$(CmdLine$, LEN(CmdLine$) - 1) FileName$ = TestName$ END IF CASE ELSE PRINT PRINT "Execution terminated." PRINT PRINT "Press any key to continue." INPUT FLUSH Dump$ = WAITKEY$ EXIT FUNCTION END SELECT END IF IF TestName$ = "" THEN PRINT PRINT "File not found : "; Filename$ PRINT PRINT "Press any key to end." INPUT FLUSH Dump$ = WAITKEY$ EXIT FUNCTION END IF SELECT CASE Choice$ CASE "S" PRINT PRINT "þ Split file into pieces DO LINE INPUT "þ with a size of [bytes]:"; Size$ Size??? = ABS(VAL(Size$)) ' If bytes is 0 then end program IF Size??? = 0 THEN EXIT FUNCTION ' Check if number of chuncks < 1000 FileNO% = FREEFILE OPEN FileName$ FOR BINARY AS FileNO% IF LOF(FileNO%) / Size??? > 999 THEN Size??? = 0 PRINT PRINT "Max. number of parts is 999" PRINT "Splitting this file into smaller parts will" PRINT "result in max. 999 parts of "; INT(LOF(FileNO%) / 999);" bytes each." PRINT PRINT "Press any key to continue." INPUT FLUSH Dump$ = WAITKEY$ CLS END IF CLOSE FileNO% LOOP UNTIL Size??? > LEN(Revision) FileCount% = 1 LOCATE 17, 1 PRINT REPEAT$(FileCount%, "þ"); PRINT FileName$ FileNO% = FREEFILE OPEN FileName$ FOR BINARY AS FileNO% CALL FindPoint(FileName$, Extention$) FileSize??? = 0 Check% = 0 Chunks% = (LOF(FileNO%) + LEN(Revision) + LEN(Extention$) + 2) / Size??? FileNO2% = FREEFILE OPEN FileName$ + LTRIM$(STR$(FileCount%)) FOR BINARY AS FileNO2% PUT$ #FileNO2%, Revision PUT$ #FileNO2%, Extention$ PUT #FileNO2%, LEN(Revision) + LEN(Extention$) + 1, Chunks% PartSize??? = LOC(FileNO2%) - 1 DO BlockSize% = MIN(Size???, Size??? - PartSize???, LOF(FileNO%) - FileSize???, 32750) FileSize??? = FileSize??? + BlockSize% PartSize??? = PartSize??? + BlockSize% GET$ #FileNO%, BlockSize%, Dump$ PUT$ #FileNO2%, Dump$ IF PartSize??? => Size??? THEN PartSize??? = 0 CLOSE FileNO2% INCR FileCount% OPEN FileName$ + LTRIM$(STR$(FileCount%)) FOR BINARY AS FileNO2% LOCATE 17,1 PRINT FileName$ + LTRIM$(STR$(FileCount%)) END IF LOOP UNTIL EOF(FileNO%) OR BlockSize% = 0 CLOSE FileNO2% CLOSE FileNO% CASE "G" FileCount% = 1 CALL FindPoint(FileName$, Extention$) LOCATE 17, 1 PRINT "Now creating : "; FileName$ DO TestName$ = DIR$(FileName$ + "." + LTRIM$(STR$(FileCount%))) IF TestName$ <> "" THEN FileNO% = FREEFILE OPEN FileName$ + "." + LTRIM$(STR$(FileCount%)) FOR BINARY AS FileNO% IF FileCount% = 1 THEN GET$ #FileNO%, LEN(Revision), TestRev$ SELECT CASE TestRev$ CASE Revision, "Split-IT v2.1" GET$ #FileNO%, 3, Extention$ Extention$ = LCASE$(Extention$) GET #FileNO%, LEN(Revision) + LEN(Extention$) + 1, Chunks% ' Now see if all parts are available. FOR T% = 1 TO Chunks% TestName$ = DIR$(FileName$ + "." + TRIM$(STR$(T%))) IF TestName$ = "" THEN PRINT "ERROR! Incomplete file set! PRINT "File not found : "; Filename$+ "." + TRIM$(STR$(T%)) PRINT PRINT "Press any key to end." INPUT FLUSH Dump$ = WAITKEY$ EXIT FUNCTION END IF NEXT T% FileNO2% = FREEFILE OPEN FileName$ + "." + Extention$ FOR BINARY AS FileNO2% FileSize??? = LEN(Revision) - LEN(Extention$) - 1 CASE "Split-IT v2.0" GET$ #FileNO%, 3, Extention$ Extention$ = LCASE$(Extention$) FileNO2% = FREEFILE OPEN FileName$ + "." + Extention$ FOR BINARY AS FileNO2% FileSize??? = LEN(TestRev$) - LEN(Extention$) CASE ELSE ' Version 1.0 GET$ #FileNO%, 3, Extention$ Extention$ = LCASE$(Extention$) FileNO2% = FREEFILE OPEN FileName$ + "." + Extention$ FOR BINARY AS FileNO2% FileSize??? = 0 END SELECT END IF LOCATE 17,1 PRINT REPEAT$(FileCount%, "þ"); " Now adding : "; PRINT FileName$; "."; LTRIM$(STR$(FileCount%)) DO BlockSize% = MIN(LOF(1) - FileSize???, 32750) FileSize??? = FileSize??? + BlockSize% GET$ #FileNO%, BlockSize%, Dump$ PUT$ #FileNO2%, Dump$ LOOP UNTIL EOF(1) OR BlockSize% = 0 INCR FileCount% FileSize??? = 0 CLOSE FileNO% END IF LOOP UNTIL TestName$ = "" CLOSE FileNO2% CLOSE FileNO% END SELECT END FUNCTION ' ÄÄÄ[ Sub routines ]ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ' Split the filename into a filename of 8 characters ' and an extention of 3 characters. This to keep ' Split-IT DOS compliant. SUB FindPoint(FileName$, Extention$) PUBLIC Place% = 0 Place% = INSTR(FileName$, ".") IF Place% <> 0 THEN Extention$ = MID$(FileName$ + " ", Place% + 1, 3) FileName$ = LEFT$(FileName$, Place%) END IF END SUB ' ÄÄÄÄ[ End of File ]ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ