[Gambas-user] My quest for efficiency

Benoît Minisini gambas at ...1...
Sat Jul 15 21:24:12 CEST 2017


Le 15/07/2017 à 20:49, Tony Morehen a écrit :
> Did you try Benoit's suggestion:
> 
> Public Sub Main()
> 
>    Dim sIn as String
>    Dim sOut as String
> 
>    sIn = File.Load("/home/fernando/temp/deah001.dhn")
>    sOut = Add11(sIn)
>    File.Save("/home/fernando/temp/deah001.11Added.dhn", sOut)
> 
> End
> 
> Public Sub Add11(InputString as String) as String
>    Dim bArray As Byte[]
>    Dim String11 As String
>    Dim i As Integer
> 
>    bArray = Byte[].FromString(InputString)
>    For i = 0 To bArray.Max
>      bArray[i] += 11
>    Next
>   Return bArray.ToString
> End
> 
> 

Just a remark:

You don't have to use Byte[].FromString.

You can use the Bute[].Read() method instead, to load the file directly 
into the array. You save an intermediate string that way.

Regards,

-- 
Benoît Minisini




More information about the User mailing list