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

2017-05-16 Thread Matti
Thank you all for your help.
Now, my search is really fast.

For anyone having similar problems:
1. My source was a huge unsorted JSON file. I converted it to a much smaller 
sorted text file. So, reading it into a String array, the array is already 
sorted.
2. String[].Find() indeed works with Mode=gb.Like=4. It's faster than doing the 
For...Next work yourself.
3. But gb.Like doesn't mean it finds anything matching your first characters, 
case insensitive. You have to use 'i = MyStringArray.Find(SearchString & "*", 
gb.Like, 0).

Regards, Matti

Am 10.05.2017 um 18:57 schrieb 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 found, -1 is returned."
>
> But I can do what I want, I always get '-1'. No positive result ever.
>
> Attached is a tiny project that should show this behaviour.
> Where is my mistake?
> Thanks in advance
> Matti
>
> Gambas 3.9.2
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


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

2017-05-11 Thread T Lee Davidson
On 05/10/2017 02:24 PM, Matti wrote:
> Oh yes, oh yes!
> Thank you, Jorge.
> I always thought, Value could also be part of a string.

It can be. Use the gb.Like comparison mode, ie:

String[].Find("Chr*", gb.Like)

See the Predefined Constants link at 
http://gambaswiki.org/wiki/comp/gb/string[]/find


---
Lee


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


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 what you will find with the current index.


Jussi

On Thu, May 11, 2017 at 12:09 AM, Jussi Lahtinen 
wrote:

> 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 only first half of
> the array. Or you could narrow the possibilities even more by dividing the
> 500 by two. Now if sMyArray[250] begins with "B", you know you just have to
> search between indexes 250 - 500, or narrow it even further.
>
> I hope you got the idea.
>
>
> Jussi
>
>
>
> On Wed, May 10, 2017 at 11:04 PM, Matti  wrote:
>
>> 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 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 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 
>> 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 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 '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 found, -1 is returned."
>> >>
>> >> But I can do what I want, I always get '-1'. No positive result
>> ever.
>> >>
>> >> Attached is a tiny project that should show this behaviour.
>> >> Where is my mistake?
>> >> Thanks in advance
>> >> Matti
>> >>
>> >> Gambas 3.9.2
>> >>
>> >> 
>> >> --
>> >> Check out the vibrant tech community on one of the world's most
>> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> >> ___
>> >> Gambas-user mailing list
>> >> Gambas-user@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/gambas-user
>> >>
>> >>
>> > 
>>  --
>> > Check out the vibrant tech community on one of the world's most
>> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> > ___
>> > Gambas-user mailing list
>> > Gambas-user@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>> >
>>  
>>  --
>>  Check out the vibrant tech community on one of the world's most
>>  engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>  ___
>>  Gambas-user mailing list
>>  Gambas-user@lists.sourceforge.net
>>  https://lists.sourceforge.net/lists/listinfo/gambas-user
>> 
>> >>> 
>> >> --
>> >>> Check out the vibrant tech community on one of the world's most
>> >>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> >>> ___
>> >>> Gambas-user mailing list
>> >>> Gambas-user@lists.sourceforge.net
>> >>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>> >> 
>> >> --
>>

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 only first half of the
array. Or you could narrow the possibilities even more by dividing the 500
by two. Now if sMyArray[250] begins with "B", you know you just have to
search between indexes 250 - 500, or narrow it even further.

I hope you got the idea.


Jussi



On Wed, May 10, 2017 at 11:04 PM, Matti  wrote:

> 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 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 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  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 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 '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 found, -1 is returned."
> >>
> >> But I can do what I want, I always get '-1'. No positive result
> ever.
> >>
> >> Attached is a tiny project that should show this behaviour.
> >> Where is my mistake?
> >> Thanks in advance
> >> Matti
> >>
> >> Gambas 3.9.2
> >>
> >> 
> >> --
> >> Check out the vibrant tech community on one of the world's most
> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >> ___
> >> Gambas-user mailing list
> >> Gambas-user@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>
> >>
> > 
>  --
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > ___
> > Gambas-user mailing list
> > Gambas-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>  
>  --
>  Check out the vibrant tech community on one of the world's most
>  engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>  ___
>  Gambas-user mailing list
>  Gambas-user@lists.sourceforge.net
>  https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> >>> 
> >> --
> >>> Check out the vibrant tech community on one of the world's most
> >>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >>> ___
> >>> Gambas-user mailing list
> >>> Gambas-user@lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >> 
> >> --
> >> Check out the vibrant tech community on one of the world's most
> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >> ___
> >> Gambas-user mailing list
> >> Gambas-user@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>
> > 
> --
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _

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 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 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  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 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 '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 found, -1 is returned."
>>
>> But I can do what I want, I always get '-1'. No positive result ever.
>>
>> Attached is a tiny project that should show this behaviour.
>> Where is my mistake?
>> Thanks in advance
>> Matti
>>
>> Gambas 3.9.2
>>
>> 
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Gambas-user mailing list
>> Gambas-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>>
> 
 --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
 
 --
 Check out the vibrant tech community on one of the world's most
 engaging tech sites, Slashdot.org! http://sdm.link/slashdot
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

>>> 
>> --
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> ___
>>> Gambas-user mailing list
>>> Gambas-user@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>> 
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Gambas-user mailing list
>> Gambas-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


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 will work as you wanted:

  Dim aNames As New String[]

  aNames.Add("Anna")
  aNames.Add("Berta")
  aNames.Add("Christa")
  aNames.Add("Dora")

  Print aNames.Find("Chr*", gb.Like)
  ' will print 2

but it will probably make the code slower because the gb.Like mode makes the
Find() operation significantly more complex. I would recommend you test it
out though. Also let me say that Gambas can't perform wonders. Just because
you call a single built-in function doesn't make the operation fast. If your
array is huge and unsorted, all searches will be slow. In fact, the Find()
method is implemented as a For-Next loop (in C, admittedly).

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb/string[]/find

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


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 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  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 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 '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 found, -1 is returned."
> 
>  But I can do what I want, I always get '-1'. No positive result ever.
> 
>  Attached is a tiny project that should show this behaviour.
>  Where is my mistake?
>  Thanks in advance
>  Matti
> 
>  Gambas 3.9.2
> 
>  
>  --
>  Check out the vibrant tech community on one of the world's most
>  engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>  ___
>  Gambas-user mailing list
>  Gambas-user@lists.sourceforge.net
>  https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 
> >>> 
> >> --
> >>> Check out the vibrant tech community on one of the world's most
> >>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >>> ___
> >>> Gambas-user mailing list
> >>> Gambas-user@lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>>
> >> 
> >> --
> >> Check out the vibrant tech community on one of the world's most
> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >> ___
> >> Gambas-user mailing list
> >> Gambas-user@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>
> > 
> --
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > ___
> > Gambas-user mailing list
> > Gambas-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


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  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 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 '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 found, -1 is returned."

 But I can do what I want, I always get '-1'. No positive result ever.

 Attached is a tiny project that should show this behaviour.
 Where is my mistake?
 Thanks in advance
 Matti

 Gambas 3.9.2

 
 --
 Check out the vibrant tech community on one of the world's most
 engaging tech sites, Slashdot.org! http://sdm.link/slashdot
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user


>>> 
>> --
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> ___
>>> Gambas-user mailing list
>>> Gambas-user@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>
>> 
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Gambas-user mailing list
>> Gambas-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


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 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 '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 found, -1 is returned."
> >>
> >> But I can do what I want, I always get '-1'. No positive result ever.
> >>
> >> Attached is a tiny project that should show this behaviour.
> >> Where is my mistake?
> >> Thanks in advance
> >> Matti
> >>
> >> Gambas 3.9.2
> >>
> >> 
> >> --
> >> Check out the vibrant tech community on one of the world's most
> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >> ___
> >> Gambas-user mailing list
> >> Gambas-user@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>
> >>
> > 
> --
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > ___
> > Gambas-user mailing list
> > Gambas-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


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 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 '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 found, -1 is returned."
>>
>> But I can do what I want, I always get '-1'. No positive result ever.
>>
>> Attached is a tiny project that should show this behaviour.
>> Where is my mistake?
>> Thanks in advance
>> Matti
>>
>> Gambas 3.9.2
>>
>> 
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Gambas-user mailing list
>> Gambas-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


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 '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 found, -1 is returned."
>
> But I can do what I want, I always get '-1'. No positive result ever.
>
> Attached is a tiny project that should show this behaviour.
> Where is my mistake?
> Thanks in advance
> Matti
>
> Gambas 3.9.2
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[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 found, -1 is returned."

But I can do what I want, I always get '-1'. No positive result ever.

Attached is a tiny project that should show this behaviour.
Where is my mistake?
Thanks in advance
Matti

Gambas 3.9.2


FindString-0.0.1.tar.gz
Description: application/gzip
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user