forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Binfile help
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Wed Dec 31, 2003 10:23 pm    Post subject: Binfile help Reply with quote

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
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Dec 31, 2003 10:25 pm    Post subject: Reply with quote

I've always been confused by BINFILE, even though I've been using VDS
for years. Confused

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Wed Dec 31, 2003 10:31 pm    Post subject: Reply with quote

Im glad im not the only one.
Why did they make it so hard, when it seems so easy?
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Thu Jan 01, 2004 1:46 am    Post subject: Reply with quote

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 Sad

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Jan 01, 2004 2:12 am    Post subject: Reply with quote

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 Smile

_________________
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
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu Jan 01, 2004 2:13 am    Post subject: Reply with quote

I'd like to learn how to use BINFILE first so I understand how to use VDSUG Wink
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Jan 01, 2004 4:29 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Thu Jan 01, 2004 10:29 am    Post subject: Reply with quote

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
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Jan 02, 2004 6:55 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Fri Jan 02, 2004 7:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sat Jan 03, 2004 12:48 am    Post subject: Reply with quote

thanks snarlingsheep...will print it and study it too...looks good Very Happy

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
moke
Contributor
Contributor


Joined: 02 Jan 2002
Posts: 162

PostPosted: Sat Jan 03, 2004 3:57 am    Post subject: Reply with quote

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 Wink ). 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
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Jan 03, 2004 4:18 am    Post subject: Reply with quote

LOL thanks moke, Wink

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). Wink

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Sat Jan 03, 2004 4:21 am    Post subject: Reply with quote

You're both wrong...there is no VDSUG, VDSINOUT..or spoon.
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Jan 03, 2004 6:06 am    Post subject: Reply with quote

Confused Question
_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group