[Gambas-user] Setting at zero more byte in a file by "Byte[]"
tobi
tobiasboege01 at ...1601...
Mon Apr 9 00:08:50 CEST 2012
On Sun, 08 Apr 2012, Ru Vuott wrote:
> Hello,
>
> I'ld like to set at zero more subsequent byte (e.g. the FIRST four) in a file, using that code:
>
> ***
> Public Sub Button1_Click()
>
> Dim aFl As File
> Dim buff As New Byte[4]
> Dim b As Byte
>
> aFl = Open "/tmp/my_file" For Write
>
> For Each b In buff
> b = 0
> Next
>
> Write #aFl, buff As Byte[]
>
> aFl.Close
>
> End
> ***
>
> But I obtain a "strange" result. In fact if I control the result of file by an exad. editor, I see the byte are:
>
> 41 02 04 00 00 00 00 ......
>
> I have three "strange" byte (41 02 04) end 'then' the four zero !
> If I want to set at zero five byte, those three exad. number will be: 41 02 05 .... It seems it memorized and wrote the array pointer instead of its contents (the four zero) !
>
> Isn't it ?
>
> Vuott
>
> ------------------------------------------------------------------------------
> For Developers, A Lot Can Happen In A Second.
> Boundary is the first to Know...and Tell You.
> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> http://p.sf.net/sfu/Boundary-d2dvs2
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
If you
Write #File, aArr As Array
then Gambas has to be able to
aArr = Read #File As Array
the data back. To do so, the type of array and its size must be available and thus are written
before the actual data. You may want to use the
Write #File, "\x00\x00\x00\x00", 4
syntax. Haven't tried but should work.
Regards,
Tobi
More information about the User
mailing list