Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Jussi Lahtinen
Btw. that is not exactly heuristic approach (more like plain algorithmic), because I don't know statistical properties of you array. IE what we can assume. Now the index is always divided by two, but if you know how the distribution of the data, you may make much more effective guesses depending on

Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Jussi Lahtinen
This works only for sorted array. Example you could take the maximum index of your array, divide it by two and look which side of the array the searched string could be. Let's say you have array of 1000 elements and you are looking for "Chr". If sMyArray[500] begins with "M", then you should look

Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Matti
Jussi, could you please explain? Yes, I have to match the beginning of the string - but what means a "heuristic guess for the index"? Am 10.05.2017 um 21:25 schrieb Jussi Lahtinen: > If you need to match only the beginning of the string, you could sort the > array and then make heuristic guess fo

Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Tobias Boege
On Wed, 10 May 2017, Matti wrote: > Yes. But as I don't know [iIndex], I have to iterate through the (huge) array > with 'For...Next'. > I hoped to make it faster with 'Find'. You can make the code smaller by using the optional Mode parameter to String[].Find() (cf. the docs [1]). The following w

Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Jussi Lahtinen
If you need to match only the beginning of the string, you could sort the array and then make heuristic guess for the index. Jussi On Wed, May 10, 2017 at 10:18 PM, Matti wrote: > Yes. But as I don't know [iIndex], I have to iterate through the (huge) > array with 'For...Next'. > I hoped to ma

Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Matti
Yes. But as I don't know [iIndex], I have to iterate through the (huge) array with 'For...Next'. I hoped to make it faster with 'Find'. Am 10.05.2017 um 20:59 schrieb Jussi Lahtinen: > For that use; String.InStr(sYourArray[iIndex], "Chr") > > > Jussi > > > On Wed, May 10, 2017 at 9:24 PM, Matti

Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Jussi Lahtinen
For that use; String.InStr(sYourArray[iIndex], "Chr") Jussi On Wed, May 10, 2017 at 9:24 PM, Matti wrote: > Oh yes, oh yes! > Thank you, Jorge. > I always thought, Value could also be part of a string. > > Am 10.05.2017 um 19:08 schrieb Jorge Carrión: > > Wiki says: "Returns the position of t

Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Matti
Oh yes, oh yes! Thank you, Jorge. I always thought, Value could also be part of a string. Am 10.05.2017 um 19:08 schrieb Jorge Carrión: > Wiki says: "Returns the position of the first occurrence of Value in the > array." > You must search for a Value of the array. > > In your array there isn't a V

Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Jorge Carrión
Wiki says: "Returns the position of the first occurrence of Value in the array." You must search for a Value of the array. In your array there isn't a Value "Chr", that is what you search, so always returns -1 Best Regars 2017-05-10 18:57 GMT+02:00 Matti : > I tried to search an array with the

[Gambas-user] String[].Find finds nothing

2017-05-10 Thread Matti
I tried to search an array with the 'Find' function instead of 'For...Next' and 'InStr'. The wiki says: "String[].Find (gb) Function Find ( Value As String [ , Mode As Integer, Start As Integer ] ) As Integer Returns the position of the first occurrence of Value in the array. If Value cannot be

Re: [Gambas-user] Serial I/O with byte data

2017-05-10 Thread T Lee Davidson
On 05/08/2017 12:13 PM, alexchernoff wrote: > Dear all, > > I am receiving data over a serial port which is sent by a byte[].write > function (an array of bytes) > > I get the SerialPort1_read() event raised where I try to read data, RxBuffer > is a string var > > *Try Read #SerialPort1, RxBuffe

Re: [Gambas-user] Editing still blocked

2017-05-10 Thread Fernando Cabral
After some more testing, I found the problem seems to be related to the keyboard. After all, I've found that I can edit the source code, as long I only use the mouse for editing (cutting, copying, pasting). I can click and save the program, I can compile it. As to the keyboard, no regular key wor