Page 2 of 2

Posted: Tue Sep 14, 2004 4:54 am
by Paul
Actually after reading this post 2 weeks ago, I simply forgot about it since no one ever did email me (I'm quite busy on a number of other projects so a short email usually helps job my memory)

I happened to be browsing through the forum this evening and saw this thread was still alive so YES, I did fix the VBin library so the BIN extension can be changed.
The VBin Maker still saves it with the default .BIN extension but you can manually rename it. Then pass the whole filename including new extension to the vbin library functions. If you pass no extension then .BIN is used by default (this keeps backwards compatability)

Enjoy :)

Posted: Tue Sep 14, 2004 9:36 am
by J. Baker
Hey Paul, thanks for the update! :D Also, will there be a catchfile option in the future? Thanks

Posted: Tue Sep 14, 2004 10:40 am
by PolyVector
Thanks for the update Paul... Good seeing my own extentions on my vbins... nice work :D

Posted: Tue Sep 14, 2004 5:54 pm
by Paul
J. Baker wrote:Hey Paul, thanks for the update! :D Also, will there be a catchfile option in the future? Thanks
Not sure what you mean by "catchfile" option?

I think VBin provides you with everything needed to pull data from a virtual bin.
Say you have a text file called test.txt which contains:
This is a test.
and this is put into a VBin.

the VBin() function returns a memory address of where this file is located in the VBin (which is what the various PB Catch commands use)...
MemAddress =VBin("Test.bin","test.txt","")
You can then use the VBinSize command to get the size of the data for this file...
size=VBinSize("Test.bin","test.txt","")

Then retrieve the text data using
A$=PeekS(MemAddress,size)

A$ will contain:
This is a test.

Does this example help at all?

Posted: Tue Sep 14, 2004 10:27 pm
by J. Baker
OH WOW! I thought you had to use the Catch commands to get anything from the VBin. Thanks very much for your explanation Paul, that helps alot. :D

Posted: Sat Sep 18, 2004 10:42 pm
by Shannara

Code: Select all

Delete Resource from VBin.

Use:
Result =VBinDelete("MyBin.bin","Image.bmp")

Returns 1 if sucess.


Is there any way you could make it that it'll only delete password protected vbin resources if a password was passed to the command? As it stands now, anybody can delete resources from a vbin.

If there was a password required (only for those bins that are password protected), and people submit the wrong password, then the resource wont be deleted... you know, kinda helps with the protection :)

Posted: Wed Jul 27, 2005 9:56 pm
by griz
Something like this Paul? :)

Code: Select all

; return file from VBIN as a string
Procedure.s VBinTextFile(BinName$, FileName$, Pass$)
  If VBin(BinName$, FileName$, Pass$)
    ProcedureReturn PeekS(VBin(BinName$, FileName$, Pass$),VBinSize(BinName$, FileName$, Pass$))
  EndIf
EndProcedure

debug VBinTextFile("MyBin", "test.txt", "")
BTW Thanks for VBIN.

Posted: Thu Jul 28, 2005 12:50 am
by griz
Here it is for Paul's newer VBIN 2 :

Code: Select all

; return specified file from VBIN as a string
Procedure.s VBinTextFile(BinName$, FileName$, Pass$)
  If VBin_(BinName$, FileName$, Pass$)
    ProcedureReturn PeekS(VBin_(BinName$, FileName$, Pass$),VBin_OriginalSize(BinName$, FileName$))
  EndIf
EndProcedure

debug VBinTextFile("MyBin", "test.txt", "")

Posted: Thu Jul 28, 2005 1:57 am
by Paul
Nice procedure griz :)

I would suggest though, for the best speed only call VBin_() once:

Code: Select all

; return specified file from VBIN as a string
Procedure.s VBinTextFile(BinName$, FileName$, Pass$)
  mem=VBin_(BinName$, FileName$, Pass$)
  If mem
    ProcedureReturn PeekS(mem,VBin_OriginalSize(BinName$, FileName$))
  EndIf
EndProcedure

debug VBinTextFile("MyBin", "test.txt", "")
Every time you call VBin_() it must retrieve the required data from the internal file system.

Posted: Thu Jul 28, 2005 8:02 pm
by DoubleDutch
what would be good is if you could append the vbin file to the end of an exe and then vbin load from the exe...

as it stands i do this and have to copy the vbin to a temp area before accessing it.

-Anthony

Posted: Thu Jul 28, 2005 8:28 pm
by Paul
If you are going to attach the VBin to your exe then it kind of defeats the purpose of using a VBin. Might as well simply "IncludeBinary" your files. ;)

Posted: Thu Jul 28, 2005 9:46 pm
by DoubleDutch
Does windows load the whole EXE file into RAM though, or does it just load code and data segments to the correct areas of memory?

I think its the latter.

In the case of appending the data to the end of the file, it should not be actually loaded by windows.

In the case of includebinary it would be included in the load (for the data section).

This would be the difference, as the data would not take up valuable RAM until needed... :)

-Anthony

Posted: Wed Aug 03, 2005 4:30 am
by Fou-Lu
I'm almost sure it loads the whole exe.
Shannara wrote:

Code: Select all

Delete Resource from VBin.

Use:
Result =VBinDelete("MyBin.bin","Image.bmp")

Returns 1 if sucess.
Is there any way you could make it that it'll only delete password protected vbin resources if a password was passed to the command? As it stands now, anybody can delete resources from a vbin.
I agree. It might not be that hard to do that. And thanks for the good work Anthony!! Now nobody will say DarkBASIC is better because of the "Create Final EXE" thing. ( Anyway I don't think anyone would ever say db is better than pb... )

Posted: Wed Aug 03, 2005 2:36 pm
by DoubleDutch
And thanks for the good work Anthony!!
??? good work ???

-Anthony

Posted: Wed Aug 03, 2005 7:55 pm
by Fou-Lu
Hey did I say Anthony? I meant Paul!!! :oops: Oh my god that one was just horrible... Sorry Antho... *ahem* Paul.