| View previous topic :: View next topic |
| Author |
Message |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Wed Dec 31, 2003 10:23 pm Post subject: Binfile help |
|
|
Ok, i have just spent ages looking at all the binfile help on the forum and I know there are some good examples but I cant seem to grasp them.
Can someone please explain as simple as possible how to use the binfile commands and functions.
I want to open a file then write it to another, a bit like making a copy.
Please dont say why not just use copy because the reason is I am trying to learn VDS.
I am using vds 4. |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Dec 31, 2003 10:25 pm Post subject: |
|
|
I've always been confused by BINFILE, even though I've been using VDS
for years.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Wed Dec 31, 2003 10:31 pm Post subject: |
|
|
Im glad im not the only one.
Why did they make it so hard, when it seems so easy? |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Thu Jan 01, 2004 1:46 am Post subject: |
|
|
me two guys...i understand the basics of binfile but not enough to be able to use it...a step by step tutorial to cover the basics would be great:
- how to create a binfile
- how to write to a binfile
- how to read from a binfile
- how to append to a binfile
- how to delete a binfile
- how to delete parts of a binfile
- how to update parts of a binfile
and so on...
i have tried to also follow examples provided at the forum and gave up
serge _________________
|
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Jan 01, 2004 2:12 am Post subject: |
|
|
Ya might want to check out the file IO in VDSug.dll.
http://www.trinex.net/users/mac/vdsug/
Although it doesn't do "binary" data, it does some
things BINFILE can't, and is reportedly faster on
large files.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Thu Jan 01, 2004 2:13 am Post subject: |
|
|
I'd like to learn how to use BINFILE first so I understand how to use VDSUG  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Thu Jan 01, 2004 4:29 am Post subject: |
|
|
I hope this helps.
| Code: |
%%File = C:\TestBinFile.dat
REM Create a File(if it already exists it will be recreated):
BINFILE OPEN,1,%%File,CREATE
REM Set position to write to:
%%Pos = 0
BINFILE SEEK,1,%%Pos
REM Write to the file:
BINFILE WRITE,1,TEXT,"Company: VDS"
REM Seek back to the beginning to read what we wrote:
BINFILE SEEK,1,%%Pos
REM Read up to the end of the file:
REM We wrote in TEXT so we read TEXT
%%Read = @BINFILE(READ,1,TEXT,@BINFILE(SIZE,1))
INFO %%Read
REM Seek to the end of the file so we can append to it:
BINFILE SEEK,1,@BINFILE(SIZE,1)
REM Append text to it:
BINFILE WRITE,1,TEXT," - File Version: 2.5"
REM Seek back to the beginning to read the whole thing
BINFILE SEEK,1,%%Pos
REM Read everything from the file:
%%Read = @BINFILE(READ,1,TEXT,@BINFILE(SIZE,1))
INFO %%Read
REM Change File Version:
BINFILE SEEK,1,@FSUB(@BINFILE(SIZE,1),3)
BINFILE WRITE,1,TEXT,"3.0"
BINFILE SEEK,1,%%Pos
%%Read = @BINFILE(READ,1,TEXT,@BINFILE(SIZE,1))
INFO %%Read
REM The best way I know to delete part of a binfile is:
REM Get rid of the File Version number
%%Read = @SUBSTR(%%Read,1,@FSUB(@LEN(%%Read),3))
REM Recreate the file and write the new contents
BINFILE CLOSE,1
BINFILE OPEN,1,%%File,CREATE
BINFILE SEEK,1,%%Pos
BINFILE WRITE,1,TEXT,%%Read
BINFILE SEEK,1,%%Pos
%%Read = @BINFILE(READ,1,TEXT,@BINFILE(SIZE,1))
INFO %%Read
REM Close the file:
BINFILE CLOSE,1
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Thu Jan 01, 2004 10:29 am Post subject: |
|
|
Thats good, but I still cant quite get my head round it.
How do you read binary data from one file and then write it to another? |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Fri Jan 02, 2004 6:55 pm Post subject: |
|
|
Study this and see if it helps:
| Code: |
%%InFile = C:\zzztest.bmp
%%OutFile = C:\TestBinFile.dat
%%Pos = 0
REM How many bytes to read/write at a time.
%%Bytes = 2000
DIALOG CREATE,Binfile Copy Example,-1,0,199,64
DIALOG ADD,BUTTON,COPY,20,55,85,24,Binfile Copy
DIALOG SHOW
:evloop
wait event
goto @event()
:COPYBUTTON
DIALOG SET,COPY,Copying..
DIALOG DISABLE,COPY
BINFILE OPEN,1,%%InFile,READ
BINFILE OPEN,2,%%OutFile,CREATE
REPEAT
BINFILE SEEK,1,%%Pos
BINFILE SEEK,2,%%Pos
%%Read = @BINFILE(READ,1,BINARY,%%Bytes)
BINFILE WRITE,2,BINARY,%%Read
%%Pos = @FADD(%%Pos,%%Bytes)
UNTIL @BINFILE(EOF,1)
BINFILE CLOSE,1
BINFILE CLOSE,2
DIALOG SET,COPY,Binfile Copy
DIALOG ENABLE,COPY
goto evloop
:Close
exit
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Fri Jan 02, 2004 7:38 pm Post subject: |
|
|
Thank you.
Thats what I am trying to do sort of, I think I can take this apart and learn quite alot. |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Sat Jan 03, 2004 12:48 am Post subject: |
|
|
thanks snarlingsheep...will print it and study it too...looks good
serge _________________
|
|
| Back to top |
|
 |
moke Contributor

Joined: 02 Jan 2002 Posts: 162
|
Posted: Sat Jan 03, 2004 3:57 am Post subject: |
|
|
Just my opinion but I do LOTS of r/w with binary files and VDSINOUT and VDSUG both have much better handling functions (even though Mac claims UG doesn't do binary ). If you look at any sample code for the UG or INOUT dll's most of the handling theroy can also be applied to binfile.
moke |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Jan 03, 2004 4:18 am Post subject: |
|
|
LOL thanks moke,
By "binary" I meant getting the actual "binary" values
(00111100 11000001 00000111 etc.). VDSug DOES
handle "raw" data from files, but the user only sees
it as characters (or HEX if desired).
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sat Jan 03, 2004 4:21 am Post subject: |
|
|
You're both wrong...there is no VDSUG, VDSINOUT..or spoon. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Sat Jan 03, 2004 6:06 am Post subject: |
|
|
 _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|