Page 1 of 1 1
Topic Options
#187683 - 2008-05-15 10:51 PM KiXtart Support For Binary Files
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Isn't it time for KiXtart to support the creating, reading and writing of binary files?
I find I have to resort to Qbasic to accomplish this.

Regards,

Bill
_________________________
Bill

Top
#187686 - 2008-05-16 12:00 AM Re: KiXtart Support For Binary Files [Re: BillBarnard]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Shouldn't this be already handled by Perl or Shell scripts ?
_________________________



Top
#187697 - 2008-05-16 09:56 AM Re: KiXtart Support For Binary Files [Re: Jochen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: Jochen
Shouldn't this be already handled by Perl or Shell scripts ?

Binary I/O is handled by a lot of other programming languages too, but if you are primarily a KiXtart coder then that is not a very helpful observation.

KiXtart does already allow you to handle binary I/O via objects, specifically the ADO stream object. The file system object FSO also kind of works but is deprecated - STW if you are interested.

The bigger problem is that KiXtart does not handle raw data types like binary files at all well. At a minumum KiXtart would need to support "byte arrays", and currently it does not.

This means that you can read and write binary data pretty well, as long as you don't ever need to look at it or manipulate it.

I did some work on handling binary data in KiXtart a while back, but it's a bit Voodoo: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=8&Number=128970

Top
#187702 - 2008-05-16 02:06 PM Re: KiXtart Support For Binary Files [Re: Richard H.]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Thanks for the info, but it would be nice if KiXtart could do something simple like this Qbasic example:-
[code]
' Remove Ctrl-Z(s) from Input file.
z$ = CHR$(26)
INPUT "Input file "; infile$
INPUT "Output file "; outfile$
OPEN infile$ FOR BINARY AS #1
OPEN outfile$ FOR OUTPUT AS #2
a$ = INPUT$(1, 1)
WHILE NOT EOF(1)
IF a$ <> z$ THEN
PRINT a$;
PRINT #2, a$;
END IF
a$ = INPUT$(1, 1)
WEND
CLOSE #1
CLOSE #2
END
[/code]

Are there restrictions in the programming language KiX is written in?

Regards, Bill
_________________________
Bill

Top
#187711 - 2008-05-16 08:57 PM Re: KiXtart Support For Binary Files [Re: BillBarnard]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
No its's not a restriction in the language. It's written in MS Assembly and VC++ 6 which allows all of that. Only the programmer can say why he doesn't or hasn't supported it to this date.
Top
#187734 - 2008-05-19 07:33 PM Re: KiXtart Support For Binary Files [Re: NTDOC]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Ok thanks, I guess we have to promise to buy Ruud lots of beer, as an incentive, to implement it.
_________________________
Bill

Top
#187981 - 2008-05-30 02:10 PM Re: KiXtart Support For Binary Files [Re: BillBarnard]
Arend_ Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
I wonder, you could probably convert the chars in the binary file like I did in my UUID2netbootGUID UDF, and then write the file back. Although that takes a lot of scripting it and will be very slow it "should" get the job done.

But Richard's code would prove more usefull then my UDF

Top
#187990 - 2008-05-30 05:53 PM Re: KiXtart Support For Binary Files [Re: Arend_]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4400
Loc: New Jersey
What about binary-zero? Would that convert to nulls, which aren't supported? What about non-ascii chars? Need to be sure you're not in ASCII mode. Seems like there'd be plenty of potential pitfalls.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#188010 - 2008-06-03 11:42 AM Re: KiXtart Support For Binary Files [Re: Glenn Barnas]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: Glenn Barnas
What about binary-zero? Would that convert to nulls, which aren't supported? What about non-ascii chars? Need to be sure you're not in ASCII mode. Seems like there'd be plenty of potential pitfalls.

Glenn


Indeedy, which is my code converts to / from an array of bytes (well, integers) - in this form you can safely manage data whatever the content. A zero is just a zero.

It's a pretty ugly method and I cannot guarantee that it will continue to work in the future, but in the interim it's a workable solution for the few times that the requirement pops up.

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 707 anonymous users online.
Newest Members
min_seow, Audio, Hoschi, Comet, rrosell
17881 Registered Users

Generated in 0.084 seconds in which 0.033 seconds were spent on a total of 13 queries. Zlib compression enabled.

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