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

Ru Vuott vuott at ...325...
Sun Apr 8 23:38:11 CEST 2012


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




More information about the User mailing list