Page 1 of 1 1
Topic Options
#81339 - 2002-11-17 11:23 PM Binmode file access
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
New feature request: Binmode Reading and Writing.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81340 - 2002-11-17 11:24 PM Re: Binmode file access
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
me want too.
_________________________
!

download KiXnet

Top
#81341 - 2002-11-17 11:30 PM Re: Binmode file access
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
me want three
Top
#81342 - 2002-11-18 04:52 PM Re: Binmode file access
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
I will take binmode reading and writing for Number 4.
_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#81343 - 2002-11-18 07:59 PM Re: Binmode file access
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
I'll take BINMODE READING for 400 and got a joker [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#81344 - 2002-11-18 08:13 PM Re: Binmode file access
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I'll take Current Events for 1000, Alex.

And the answer is: BIN READING

What has Osama bin doing for the past 12 months, squirreled away in his mountain retreat.

lol

Top
#81345 - 2002-11-18 08:18 PM Re: Binmode file access
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
[Big Grin] [Big Grin] I liked that one. ROTFLMAO
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81346 - 2002-11-18 08:23 PM Re: Binmode file access
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
ROFL. Good one Shawn!
_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#81347 - 2002-11-18 08:33 PM Re: Binmode file access
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Bin Running
Bin Hiding
Bin Ducking
Bin Dodging
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81348 - 2002-11-18 08:36 PM Re: Binmode file access
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Bin Writing
Bin Sending
Bin Downgrading
Bin Daytrading
_________________________
There are two types of vessels, submarines and targets.

Top
#81349 - 2002-11-18 08:52 PM Re: Binmode file access
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
let's please try and remain professional in the Suggestions forum. We do of course, want Ruud to take us seriously.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#81350 - 2002-11-18 09:02 PM Re: Binmode file access
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
If we don't give him bbChecker, he'll have to start at the beginning of the thread while it was still serious...Maybe the point will be made by the time he makes it half way down.

[ 18. November 2002, 21:04: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81351 - 2002-11-19 10:49 AM Re: Binmode file access
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
How do you guys see the binary I/O working?

Personally I'd like to see an extension to KiXtart which includes binary data types which would be used for other things like information returned by COM objects and the like.

Another (far simpler) approach would be to provide some new file functions that use a buffer. The buffer is an array in which each element is the ASCII value of the character which has been read/will be written.

The functions would take the form:
code:
$iBytesRead=ReadArray($fdFileDescriptor,$aiDataRead,$iBytesToRead)

$iBytesRead is the number of bytes successfully read, "0" if there is no more data (end of file) and "-1" if there is an error.
$fdFileDescriptor is the file number used in the file Open().
$aiDataRead is the array which will contain the values of the data read.
$iBytesToRead is the number of bytes that you want to read - could be optional in which case it is the size of the array.

Similarly the write would be:
code:
$iBytesWritten=WriteArray($fdFileDescriptor,$aiWriteData,$iBytesToWrite

The wide awake among you will have spotted a problem with ReadArray(). The array is passed as a parameter. To be able to populate the array with the data, we would need pass-by-reference support in KiXtart, and we don't. Yet.

So, ReadArray can be simplified to:
code:
$aiDataRead=ReadArray($fdFileDescriptor,$iBytesToRead)

@ERROR can be checked for end-of-file and error conditions. The number of bytes read is the size of the array.
I prefer the first method as there is a small problem with this way of doing reads in that it is tricky to identify when some data was read before an error occurred.

The other change required is that the Open() function will probably need a flag to ensure that the file is opened in binary or "raw" mode. This is because it will probably be required by the underlying file open API.

Mixing binary and non-binary reads and writes may be possible, but the results will be hard to predict and should be avoided.

Performing binary reads and writes on a file not opened in binary mode (and vice versa) will also have unexpected results.

Some more thoughts (shouldn't think and type at the same time [Wink] )

If binary file I/O is implemented it should be able to support random file I/O, i.e.:
  • A file can be opened for both read and write.
  • Seek() function to move the file cursor to an arbitrary location in the file (1=start, -1=end)
  • Truncate() function to reduce the size of the file (when you've deleted data from the end) or to initialize a file which has data in it already that you want to discard
We would also need some way of dealing with non-string data, WriteInteger(), ReadFloat() perhaps? Or maybe a way of converting the data types to a character array for reading/writing.
Other useful support functions would allow filling an array with a character, padding a string to a length with an arbitrary character and split()/join() to work with a null delimiter.

The more I think about it the more complex it gets.

Enough of my ramblings, for now.

Top
#81352 - 2004-11-26 10:19 AM Re: Binmode file access
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Some good thoughts and ideas Richard, but sort of sounding more like a Binary Editor rather then a script processor.

Personally have had very little need to modify too many binary files with a script, but I do see where the use of supporting NULLS has come up for me and any many posts on the board. Supporting binary mode would include this, so thus I agree we need some sort of support.

Hopefully Ruud reads all these suggestion posts and can give some feedback as well some time.

Top
#81353 - 2004-11-26 10:53 AM Re: Binmode file access
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
script processor?
script processor processes scripts given to it.
doesn't matter does the script processor support binary editing or not, it still is script processor as long as it does process the scripts.
see?
_________________________
!

download KiXnet

Top
#81354 - 2004-11-26 11:00 AM Re: Binmode file access
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
This isn't English 101 don't get so caught up in names Jooel.
Top
#81355 - 2004-11-26 11:26 AM Re: Binmode file access
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I've recently posted a solution for reading and writing binary data using KiXtart elsewhere on the board - including NULLs.
Top
#81356 - 2004-11-26 11:35 AM Re: Binmode file access
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Hi Richard, do you have a link to that post?
Top
#81357 - 2004-11-26 11:39 AM Re: Binmode file access
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
doc, sure this isn't.
but you need to understand my point.
what you think script processor (or kixtart) should be like, may not fit to anybody elses ideas.
or...
anyway, I think you get my point.

_________________________
!

download KiXnet

Top
#81358 - 2004-11-26 11:45 AM Re: Binmode file access
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Hi Richard, do you have a link to that post?




Here you go.

The routines in the link convert to/from "byte array" format which you can use directly with ADODB.stream to read and write binary files.

Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.075 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org