Re: [Gambas-user] Setting at zero more byte in a file by "Byte[]"

2012-04-08 Thread Ru Vuott
Hello Emil,

no, it's no good, because I obtain 41 02 04 00 00 00 00 . again.

Minisini's solution is that right. --> buff.Write(stream)

But thank you.

Bye

Vuottt

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Setting at zero more byte in a file by "Byte[]"

2012-04-08 Thread Emil Lenngren
When you write
  For Each b In buff
b = 0
  Next
you get a copy of each byte in the variable 'b', not a reference.
Instead, you can do something like this:
  For i = 0 To 3
buff[i] = 0
  Next

/Emil

2012/4/8 Ru Vuott 

> 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@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Setting at zero more byte in a file by "Byte[]"

2012-04-08 Thread tobi
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@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

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] Setting at zero more byte in a file by "Byte[]"

2012-04-08 Thread Ru Vuott
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user