Page 1 of 4

DBin_

Posted: Mon May 29, 2006 1:53 am
by DoubleDutch
Here is my opensource version of VBin_ , its called DBin_ !!!

Code: Select all

Global vDBin_Size,vDBin_Compressed,vDBin_CRC

Procedure iDBin_Header(file,string$,size,compressed,crc)
	len=Len(string$)
	If len
		WriteString(file,string$)
	EndIf
	WriteByte(file,len)	; filename len
	WriteLong(file,size)	; no size
	WriteLong(file,compressed)	; no pack
	WriteLong(file,crc)	; crc of data
	WriteLong(file,$dbdbdbdb) ; id string
EndProcedure

Procedure iDBin_CheckHeader(file,pos)
	result=0
	If pos>17
		FileSeek(file,pos-4)
		If ReadLong(file)=$dbdbdbdb
			FileSeek(file,pos-17)
			len=ReadByte(file)&$ff
			size=ReadLong(file)
			compressed=ReadLong(file)
			stringpos=pos-17-len
			If compressed
				result=stringpos-compressed
			Else
				result=stringpos-size
			EndIf
			FileSeek(file,pos-17)
		EndIf
	EndIf
	ProcedureReturn result
EndProcedure

Procedure DBin_Create(string$)
	file=CreateFile(#PB_Any,string$)
	If file
		iDBin_Header(file,"",0,0,0)
		CloseFile(file)
	EndIf
	ProcedureReturn file
EndProcedure

Procedure DBin_AddFile(dest$,string$,comp=-1)
	result=#False
	endoffile=FileSize(dest$)
	If endoffile>0
		string$=LCase(ReplaceString(string$,"/","\"))
		size=FileSize(string$)
		If size>0
			source=AllocateMemory(size)
			If source
				dest=AllocateMemory(size+8)
				If dest
					file=ReadFile(#PB_Any,string$)
					If file
						If ReadData(file,source,size)=size
							If comp>=0
								compressed=PackMemory(source,dest,size,comp)
							Else
								compressed=PackMemory(source,dest,size)
							EndIf
							file2=OpenFile(#PB_Any,dest$)
							If file2
								FileSeek(file2,endoffile)
								If compressed
									WriteData(file2,dest,compressed)
								Else
									WriteData(file2,source,size)
								EndIf
								iDBin_Header(file2,string$,size,compressed,CRC32Fingerprint(source,size))
								CloseFile(file2)
								result=#True
							EndIf					
						EndIf
						CloseFile(file)
					EndIf
					FreeMemory(dest)
				EndIf
				FreeMemory(source)
			EndIf
		EndIf
	EndIf
	ProcedureReturn result
EndProcedure

Procedure DBin_TotalFiles(string$)
	result=0
	endoffile=FileSize(string$)
	If endoffile>16
		file=ReadFile(#PB_Any,string$)
		If file
			Repeat
				endoffile=iDBin_CheckHeader(file,endoffile)
				If endoffile
					result+1
				EndIf
			Until Not endoffile
			CloseFile(file)
		EndIf
	EndIf
	ProcedureReturn result
EndProcedure

Procedure.s DBin_Dir(string$,pos)
	atfile=0
	result$=""
	endoffile=FileSize(string$)
	If endoffile>16
		file=ReadFile(#PB_Any,string$)
		If file
			Repeat
				endoffile2=endoffile
				endoffile=iDBin_CheckHeader(file,endoffile)
				If endoffile
					atfile+1
					If atfile>=pos
						len=ReadByte(file)&$ff
						If len
							result$=Space(len)
							FileSeek(file,endoffile2-17-len)
							ReadData(file,@result$,len)
							ReadByte(file) ; skip string len
							vDBin_Size=ReadLong(file)
							vDBin_Compressed=ReadLong(file)
							vDBin_CRC=ReadLong(file)
						EndIf
						Break
					EndIf
				EndIf
			Until Not endoffile
			CloseFile(file)
		EndIf
	EndIf
	ProcedureReturn result$
EndProcedure

Procedure DBin_FindFile(string$,file$)
	file$=LCase(ReplaceString(file$,"/","\"))
	result=#False
	endoffile=FileSize(string$)
	If endoffile>16
		file=ReadFile(#PB_Any,string$)
		If file
			Repeat
				endoffile2=endoffile
				endoffile=iDBin_CheckHeader(file,endoffile)
				If endoffile
					len=ReadByte(file)&$ff
					If len
						compare$=Space(len)
						FileSeek(file,endoffile2-17-len)
						ReadData(file,@compare$,len)
						If file$=compare$
							ReadByte(file) ; skip string len
							vDBin_Size=ReadLong(file)
							vDBin_Compressed=ReadLong(file)
							vDBin_CRC=ReadLong(file)
							result=endoffile
							Break
						EndIf
					EndIf
				EndIf
			Until Not endoffile
			CloseFile(file)
		EndIf
	EndIf
	ProcedureReturn result
EndProcedure

Procedure DBin_OriginalSize(string$,file$)
	If DBin_FindFile(string$,file$)
		ProcedureReturn vDBin_Size
	Else
		ProcedureReturn 0
	EndIf
EndProcedure

Procedure DBin_CompressedSize(string$,file$)
	If DBin_FindFile(string$,file$)
		ProcedureReturn vDBin_Compressed
	Else
		ProcedureReturn 0
	EndIf
EndProcedure

Procedure DBin_SaveFile(string$,file$,save$)
	result=#False
	pos=DBin_FindFile(string$,file$)
	If pos
		dest=AllocateMemory(vDBin_Size)
		If dest
			file=ReadFile(#PB_Any,string$)
			If file
				FileSeek(file,pos)
				If vDBin_Compressed
					source=AllocateMemory(vDBin_Compressed)
					If source
						If ReadData(file,source,vDBin_Compressed)=vDBin_Compressed
							UnpackMemory(source,dest)
							FreeMemory(source)
							result=#True
						EndIf
					EndIf
				Else
					If ReadData(file,dest,vDBin_Size)=vDBin_Size
						result=#True
					EndIf
				EndIf
				CloseFile(file)
				If result
					result=#False
					file=CreateFile(#PB_Any,save$)
					If file
						WriteData(file,dest,vDBin_Size)
						CloseFile(file)
						result=#True
					EndIf
				EndIf
			EndIf
			FreeMemory(dest)
		EndIf
	EndIf
	ProcedureReturn result
EndProcedure

Procedure DBin_(string$,file$)
	result=#False
	pos=DBin_FindFile(string$,file$)
	If pos
		dest=AllocateMemory(vDBin_Size)
		If dest
			file=ReadFile(#PB_Any,string$)
			If file
				FileSeek(file,pos)
				If vDBin_Compressed
					source=AllocateMemory(vDBin_Compressed)
					If source
						If ReadData(file,source,vDBin_Compressed)=vDBin_Compressed
							UnpackMemory(source,dest)
							FreeMemory(source)
							result=dest
						EndIf
					EndIf
				Else
					If ReadData(file,dest,vDBin_Size)=vDBin_Size
						result=dest
					EndIf
				EndIf
				CloseFile(file)
			EndIf
			If result=#False
				FreeMemory(dest)
			EndIf
		EndIf
	EndIf
	ProcedureReturn result
EndProcedure

Procedure DBin_Free(mem)
	ProcedureReturn FreeMemory(mem)
EndProcedure
Its quickly put together and is a bit of a hack. It was mainly written because there is no VBin_ for V4 and to allow something I wished VBin_ could do: Allow you to append your data file to an exe and load the files directly (rather than have to copy it off the executable first).

The commands are the same as VBin_'s, just change the V for a D. The AddFile has an optional compression setting. Encryption is missing, I didn't use it - but it would be good if someone else adds it.

The routines beginning with iDBin_ are the internal routines, making it into a library should be easy using TailBite, probabily just make the non-iDBin routines into ProcedureDLLs.

Its opensource, but it would be a good idea if it gets added to either Droopy's forthcoming v4 lib or PBOSL - I don't mind which. :)

Hope you all like it.

-Anthony

Posted: Mon May 29, 2006 2:13 am
by Dare
Thanks DoubleDutch, looks interesting.

Edit: I don't use vbin, are there some usage notes for vbin somewhere? Most things look obvious but just to be sure. :)

Re: DBin_

Posted: Mon May 29, 2006 2:21 am
by ts-soft
DoubleDutch wrote: Its opensource, but it would be a good idea if it gets added to either Droopy's forthcoming v4 lib or PBOSL - I don't mind which. :)

Hope you all like it.

-Anthony
thx, i will test it!

Posted: Mon May 29, 2006 2:21 am
by DoubleDutch
You can find VBin_ here: http://reelmedia.org/pureproject/ in the ASM library 3.9x section. There is a help file for VBin there.
Just replace the V with a D and ignore anything to do with encryption when refering to DBin_ versions of the commands. :)

Posted: Mon May 29, 2006 2:25 am
by Dare
Thanks!

Posted: Mon May 29, 2006 8:49 am
by thefool
thanks :)

Posted: Mon May 29, 2006 11:55 pm
by ts-soft
I have integrated the encryption (RC4)
Please test this lib for PBOSL
In the download you find the lib and modified source

PBOSL_DBin

regards
thomas

// added example to link the DBin Container to exe

Posted: Tue May 30, 2006 7:43 am
by Dare
Hi DoubleDutch and ts-soft.

The DBin_CompressedSize function returns 0 if no compression level set - I think this or something similar needs to be done:

Code: Select all

;Around Line 124/125 in DBin_AddFile3
; (if I haven't screwed up the line numbers)

If compressed
  WriteData(file2,dest,compressed)
Else
  WriteData(file2,source,Size)
  compressed=Size                    ; <-- sets the compressed size (else is 0?)
EndIf
Haven't tried the encryption yet. Going to try unicode next, wanna bet this will stuff it up? :)

I am pretty sure some " * SizeOf(character)" statements are needed, at least. If I can unicode it I will.

But maybe you gurus will want to do it properly. :)

Posted: Tue May 30, 2006 9:07 am
by Dare
It looks like unicode will be pretty easy to implement.

The following is incomplete, you can tell what I have played with from the debug lines at the end.

Changes are CAPITALISED, not because I am shouting but to show were I messed around.

Ran this in both ASCII and UNICODE mode and it worked. It forces Unicode string writing as I think this may be better than the other way round (#PB_Ascii)

There is a klurge, not sure how to get the unicode SizeOf(character) in ascii mode, so just used "2"

Anyhow, thanks to Fred and Freak's answers to my earlier Q's in coding questions, and to the fact PureBasic removes most of the mystery, it was pretty painless to do this.

Code: Select all

; Autor: DoubleDutch
; some extensions by ts-soft

Global vDBin_Size,vDBin_Compressed,vDBin_CRC
Global vDBin_CharSize = 2                                      ; ADDED - and This is a klurge!
                                                               ; I don't know how to get
                                                               ;   SizeOf(character) to return
                                                               ;   unicode size in ascii mode

Procedure iDBin_RC4Mem(Mem.l, memLen.l, key.s)
  ; based on source from Pille (German-Forum)
  Protected I.l, t.l, x.l, j.l, temp.l, y.l, l.l, *Sp.LONG, *KeyP.BYTE, *Memm.BYTE
  If key
    Dim S.l(255)
    Dim K.l(255)
    I=0: j=0: t=0: x=0
    temp=0: y=0
    j = 1
    l.l          =Len(key)
    *Sp      = @S()
    *KeyP    = @key
    For I = 0 To 255
      *Sp\l = I
      *Sp + 4
      If *KeyP\b = 0
        *KeyP = @key
      EndIf
      K(I) = *KeyP\b
      *KeyP+1
    Next I
    j = 0
    For I = 0 To 255
      j = (j + S(I) + K(I)) & 255
      temp = S(I)
      S(I) = S(j)
      S(j) = temp
    Next I
    I = 0
    j = 0
    *Memm = Mem
    For x = 0 To memLen-1
      I = (I+1) & 255
      j = (j + S(I)) & 255
      temp = S(I)
      S(I) = S(j)
      S(j) = temp
      t = (S(I) + (S(j) & 255)) & 255
      y = S(t)
      *Memm\b ! y
      *Memm + 1
    Next
  EndIf
  ProcedureReturn Mem
EndProcedure

Procedure iDBin_Header(file,string$,Size,compressed,crc)
  Protected len=Len(string$)
  If len
    WriteString(file,string$,#PB_Unicode)                      ; ADDED UNICODE FLAG
  EndIf
  WriteByte(file,len*vDBin_CharSize)   ; filename len          ; ADDED vDBin_CharSize
  WriteLong(file,Size)   ; no size                             ; Note: path now cannot be >127!
  WriteLong(file,compressed)   ; no pack
  WriteLong(file,crc)   ; crc of data
  WriteLong(file,$DBDBDBDB) ; id string
EndProcedure

Procedure iDBin_CheckHeader(file,pos)
  Protected result=0
  Protected len.l, Size.l, compressed.l, stringpos.l
  If pos>17
    FileSeek(file,pos-4)
    If ReadLong(file)=$DBDBDBDB
      FileSeek(file,pos-17)
      len=ReadByte(file)&$FF
      Size=ReadLong(file)
      compressed=ReadLong(file)
      stringpos=pos-17-len
      If compressed
        result=stringpos-compressed
      Else
        result=stringpos-Size
      EndIf
      FileSeek(file,pos-17)
    EndIf
  EndIf
  ProcedureReturn result
EndProcedure

ProcedureDLL DBin_Create(string$); Creates an empty DBin
  Protected file=CreateFile(#PB_Any,string$)
  If file
    iDBin_Header(file,"",0,0,0)
    CloseFile(file)
  EndIf
  ProcedureReturn file
EndProcedure

ProcedureDLL DBin_AddFile3(dest$,string$,comp,key$)
  Protected result=#False
  Protected endoffile=FileSize(dest$)
  Protected Size.l, source.l, dest.l, file.l, compressed.l, file2.l
  If endoffile>0
    string$=LCase(ReplaceString(string$,"/","\"))
    Size=FileSize(string$)
    If Size>0
      source=AllocateMemory(Size)
      If source
        dest=AllocateMemory(Size+8)
        If dest
          file=ReadFile(#PB_Any,string$)
          If file
            If ReadData(file,source,Size)=Size
              If key$
                iDBin_RC4Mem(source, MemorySize(source), key$)
              EndIf
              If comp>=0
                compressed=PackMemory(source,dest,Size,comp)
              Else
                compressed=PackMemory(source,dest,Size)
              EndIf
              file2=OpenFile(#PB_Any,dest$)
              If file2
                FileSeek(file2,endoffile)
                If compressed
                  WriteData(file2,dest,compressed)
                Else
                  WriteData(file2,source,Size)
                  compressed=Size
                EndIf
                iDBin_Header(file2,string$,Size,compressed,CRC32Fingerprint(source,Size))
                CloseFile(file2)
                result=#True
              EndIf
            EndIf
            CloseFile(file)
          EndIf
          FreeMemory(dest)
        EndIf
        FreeMemory(source)
      EndIf
    EndIf
  EndIf
  ProcedureReturn result
EndProcedure

ProcedureDLL DBin_AddFile2(dest$,string$,comp)
  ProcedureReturn DBin_AddFile3(dest$,string$,comp,"")
EndProcedure

ProcedureDLL DBin_AddFile(dest$,string$); Add file to DBin
  ProcedureReturn DBin_AddFile3(dest$,string$,-1,"")
EndProcedure

ProcedureDLL DBin_TotalFiles(string$); Returns total number of files in DBin
  Protected result=0
  Protected endoffile=FileSize(string$)
  Protected file.l
  If endoffile>16
    file=ReadFile(#PB_Any,string$)
    If file
      Repeat
        endoffile=iDBin_CheckHeader(file,endoffile)
        If endoffile
          result+1
        EndIf
      Until Not endoffile
      CloseFile(file)
    EndIf
  EndIf
  ProcedureReturn result
EndProcedure

ProcedureDLL.s DBin_Dir(string$,pos); Returns name of file at specified index
  Protected atfile=0
  Protected result$=""
  Protected endoffile=FileSize(string$)
  Protected file.l, len.l, endoffile2.l
  If endoffile>16
    file=ReadFile(#PB_Any,string$)
    If file
      Repeat
        endoffile2=endoffile
        endoffile=iDBin_CheckHeader(file,endoffile)
        If endoffile
          atfile+1
          If atfile>=pos
            len=ReadByte(file)&$FF
            If len
              result$=Space(len)
              FileSeek(file,endoffile2-17-len)
              ReadData(file,@result$,len)
              ReadByte(file) ; skip string len
              vDBin_Size=ReadLong(file)
              vDBin_Compressed=ReadLong(file)
              vDBin_CRC=ReadLong(file)
            EndIf
            Break
          EndIf
        EndIf
      Until Not endoffile
      CloseFile(file)
    EndIf
  EndIf
  ProcedureReturn result$
EndProcedure

ProcedureDLL DBin_FindFile(string$,file$)
  Protected result.l=#False
  Protected endoffile=FileSize(string$)
  Protected file.l, len.l, compare$, endoffile2.l
  file$=LCase(ReplaceString(file$,"/","\"))
  If endoffile>16
    file=ReadFile(#PB_Any,string$)
    If file
      Repeat
        endoffile2=endoffile
        endoffile=iDBin_CheckHeader(file,endoffile)
        If endoffile
          len=ReadByte(file)&$FF
          If len
            compare$=Space(len)
            FileSeek(file,endoffile2-17-len)
            ReadData(file,@compare$,len)
            compare$ = PeekS(@compare$,len,#PB_Unicode)         ; ADDED THIS LINE
            If Trim(file$)=Trim(compare$)                       ; ADDED TRIMS (dunno why needed) 
              ReadByte(file) ; skip string len
              vDBin_Size=ReadLong(file)
              vDBin_Compressed=ReadLong(file)
              vDBin_CRC=ReadLong(file)
              result=endoffile
              Break
            EndIf
          EndIf
        EndIf
      Until Not endoffile
      CloseFile(file)
    EndIf
  EndIf
  ProcedureReturn result
EndProcedure

ProcedureDLL DBin_OriginalSize(string$,file$); Returns Original size of file in DBin
  If DBin_FindFile(string$,file$)
    ProcedureReturn vDBin_Size
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

ProcedureDLL DBin_CompressedSize(string$,file$); Returns Compressed size of file in DBin
  If DBin_FindFile(string$,file$)
    ProcedureReturn vDBin_Compressed
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

ProcedureDLL DBin_SaveFile2(string$,file$,save$,key$)
  Protected result=#False
  Protected pos=DBin_FindFile(string$,file$)
  Protected dest.l, file.l, source.l
  If pos
    dest=AllocateMemory(vDBin_Size)
    If dest
      file=ReadFile(#PB_Any,string$)
      If file
        FileSeek(file,pos)
        If vDBin_Compressed <> vDBin_Size                          ; CHANGED as no longer 0 return
          source=AllocateMemory(vDBin_Compressed)
          If source
            If ReadData(file,source,vDBin_Compressed)=vDBin_Compressed
              UnpackMemory(source,dest)
              FreeMemory(source)
              result=#True
            EndIf
          EndIf
        Else
          If ReadData(file,dest,vDBin_Size)=vDBin_Size
            result=#True
          EndIf
        EndIf
        CloseFile(file)
        If result
          result=#False
          file=CreateFile(#PB_Any,save$)
          If file
            If key$
              iDBin_RC4Mem(dest, vDBin_Size,key$)
            EndIf
            WriteData(file,dest,vDBin_Size)
            CloseFile(file)
            result=#True
          EndIf
        EndIf
      EndIf
      FreeMemory(dest)
    EndIf
  EndIf
  ProcedureReturn result
EndProcedure

ProcedureDLL DBin_SaveFile(string$,file$,save$); Unpack and decrypted file in DBin to Disk
  ProcedureReturn DBin_SaveFile2(string$,file$,save$,"")
EndProcedure

; -------------------------------------------------- NOT TRIED ANY OF THIS
ProcedureDLL DBin_2(string$,file$,key$)
  Protected result.l=#False
  Protected pos.l=DBin_FindFile(string$,file$)
  Protected dest.l, file.l, source.l
  If pos
    dest=AllocateMemory(vDBin_Size)
    If dest
      file=ReadFile(#PB_Any,string$)
      If file
        FileSeek(file,pos)
        If vDBin_Compressed <> vDBin_Size                            ; CHANGED as 0 not returned
          source=AllocateMemory(vDBin_Compressed)
          If source
            If ReadData(file,source,vDBin_Compressed)=vDBin_Compressed
              UnpackMemory(source,dest)

              FreeMemory(source)
              result=dest
            EndIf
          EndIf
        Else
          If ReadData(file,dest,vDBin_Size)=vDBin_Size
            result=dest
          EndIf
        EndIf
        CloseFile(file)
      EndIf
      If result=#False
        FreeMemory(dest)
      EndIf
    EndIf
  EndIf
  If key$
    iDBin_RC4Mem(result,MemorySize(result),key$)
  EndIf
  ProcedureReturn result
EndProcedure

ProcedureDLL DBin_(string$,file$); Unpacks and decrypted file in DBin and returns Memory Address
  ProcedureReturn DBin_2(string$,file$,"")
EndProcedure

ProcedureDLL DBin_Free(Mem); free allocated memory
  ProcedureReturn FreeMemory(mem)
EndProcedure

ProcedureDLL DBin_CRC32(string$,file$)
  If DBin_FindFile(string$,file$)
    ProcedureReturn vDBin_CRC
  Else
    ProcedureReturn 0
  EndIf
EndProcedure



myBin.s = "SomeBinFile"
myPNG.s = "SomePngFile"
myBMP.s = "SomeBmpFile"

Debug "Create = "+Str(DBin_Create(myBin))
Debug "----"
Debug "AddPng = "+Str(DBin_AddFile(myBin,myPNG))
Debug "AddBmp = "+Str(DBin_AddFile(myBin,myBMP))
Debug "TotalF = "+Str(DBin_TotalFiles(myBin))
Debug "---- PNG"
Debug "FindFi = "+Str(DBin_FindFile(myBin,myPNG))
Debug "OrigSz = "+Str(DBin_OriginalSize(myBin,myPNG))
Debug "CompSz = "+Str(DBin_CompressedSize(myBin,myPNG))
Debug "---- BMP"
Debug "FindFi = "+Str(DBin_FindFile(myBin,myBMP))
Debug "OrigSz = "+Str(DBin_OriginalSize(myBin,myBMP))
Debug "CompSz = "+Str(DBin_CompressedSize(myBin,myBMP))
Debug "----"
Debug "SavBMP = "+Str(DBin_Savefile(myBin,myBMP, ReplaceString(myBMP,".bmp","x1.bmp")))
Debug "SavPNG = "+Str(DBin_Savefile(myBin,myPNG, ReplaceString(myPNG,".png","x1.png")))
Hope it is useful. BTW, it is not intended to replace anything you guys have done (and not everything was tested!), it is just some ideas on making it, um, cross-unicode-ascii compatible. And maybe I have screwed up big time.

Posted: Tue May 30, 2006 9:34 am
by ts-soft
@Dare
thx, for your good work, i will test it again :wink:

Posted: Tue May 30, 2006 10:11 am
by DoubleDutch
Dare: Thanks for the Unicode work :)

The compressed value SHOULD be zero if the file is not compressable, this is not a mistake. Its used as a flag to decide if to uncompress later when loading (if not zero, then uncompress).

Update: Sorry, just noticed that you did spot that and made a fix for it. :oops:

Now there is only the checksum verification that Vbin has that this doesn't. I generate the checksum - but it doesn't get checked at present. :)

Posted: Tue May 30, 2006 10:31 am
by DoubleDutch
Here is a new version of DBin_Create that should allow you to start a DBin file on the end of an exe (or any other file) by setting the optional parameter to true.

Code: Select all

Procedure DBin_Create(string$,append=#False)
	If append
		size=FileSize(string$)
		If size>0
			file=OpenFile(#PB_Any,string$)
			If file
				FileSeek(file,size)
				iDBin_Header(file,"",0,0,0)
				CloseFile(file)				
			EndIf
			ProcedureReturn file
		Else
			ProcedureReturn 0
		EndIf
	Else
		file=CreateFile(#PB_Any,string$)
		If file
			iDBin_Header(file,"",0,0,0)
			CloseFile(file)
		EndIf
		ProcedureReturn file
	EndIf
EndProcedure
It should work, but I can't test it as I'm not on the PC that has PB on it.

Posted: Tue May 30, 2006 10:35 am
by DoubleDutch
This is an alternative version, it should work instead and is less code.

Code: Select all

Procedure DBin_Create(string$,append=#False)
	If append
		size=FileSize(string$)
		If size>0
			file=OpenFile(#PB_Any,string$)
			If file
				FileSeek(file,size)
			EndIf
		EndIf
	Else
		file=CreateFile(#PB_Any,string$)
	EndIf
	If file
		iDBin_Header(file,"",0,0,0)
		CloseFile(file)
	EndIf
	ProcedureReturn file
EndProcedure

Posted: Tue May 30, 2006 10:45 am
by DoubleDutch
In the encryption routine, can this bit of code:

Code: Select all

   temp = S(I) 
   S(I) = S(j) 
   S(j) = temp 
be changed to:

Code: Select all

   Swap S(I),S(j)
:?:

If it can, then it should be very slightly faster?

Update:
I forgot to thank ts-soft for adding the encryption routine and adding it to PBOSL. :D

Anyone want to submit a help file?

Posted: Tue May 30, 2006 10:50 am
by Dare
Top stuff, thanks.

BTW, note to anyone else cutting and pasting here, don't take the code I posted above, it is incomplete, a sort of proof of possibility. Stick with what the gurus post. :)