why this could not be? error in runtime?

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

why this could not be? error in runtime?

PICCORO McKAY Lenz
in the following code:

    strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)

IDE said error invalid argument, but if i do:

    psotionlen = InStr(strinchar, ")", -1) - 1
     strinchar = Mid(strinchar, 1, psotionlen)

works, why?

i wnat to remove the last occurence of a char but bybass some possible
spaces/chars at the end of string

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com
------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Fernando Cabral
2017-07-28 17:55 GMT-03:00 PICCORO McKAY Lenz <[hidden email]>:

> in the following code:
>
>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>
> What does inStr() returns if nothing is found? You may be passing an
invalid argument to Mid().
Please, check it up.

- fernando

> IDE said error invalid argument, but if i do:
>
>     psotionlen = InStr(strinchar, ")", -1) - 1
>      strinchar = Mid(strinchar, 1, psotionlen)
>
> works, why?
>
> i wnat to remove the last occurence of a char but bybass some possible
> spaces/chars at the end of string
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
> ------------------------------------------------------------
> ------------------
> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

PICCORO McKAY Lenz
2017-07-28 17:17 GMT-04:00 Fernando Cabral <[hidden email]>:

> > in the following code:
> >
> >     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
> >
> > What does inStr() returns if nothing is found? You may be passing an
> invalid argument to Mid().
> Please, check it up.
>

fernando check it up you, if i do the instr() -1 separately works... dou
you see the code before answer:

    strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1) ' does not
work

IDE said error invalid argument, but if i do:

    psotionlen = InStr(strinchar, ")", -1) - 1   ' separate the stolen and..
     strinchar = Mid(strinchar, 1, psotionlen)  ' put in here then works
?!?!?!!?

works, why?


> - fernando
>
> > IDE said error invalid argument, but if i do:
> >
> >     psotionlen = InStr(strinchar, ")", -1) - 1
> >      strinchar = Mid(strinchar, 1, psotionlen)
> >
> > works, why?
> >
> > i wnat to remove the last occurence of a char but bybass some possible
> > spaces/chars at the end of string
> >
> > Lenz McKAY Gerardo (PICCORO)
> > http://qgqlochekone.blogspot.com
> > ------------------------------------------------------------
> > ------------------
> > 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
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>
>
>
> --
> Fernando Cabral
> Blogue: http://fernandocabral.org
> Twitter: http://twitter.com/fjcabral
> e-mail <http://twitter.com/fjcabral%0Ae-mail>:
> [hidden email]
> Facebook: [hidden email]
> Telegram: +55 (37) 99988-8868
> Wickr ID: fernandocabral
> WhatsApp: +55 (37) 99988-8868
> Skype:  fernandojosecabral
> Telefone fixo: +55 (37) 3521-2183
> Telefone celular: +55 (37) 99988-8868
>
> Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
> nenhum político ou cientista poderá se gabar de nada.
> ------------------------------------------------------------
> ------------------
> 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
> [hidden email]
> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Jussi Lahtinen
In reply to this post by PICCORO McKAY Lenz
Because the line makes no sense at all. Try to remove ")".


Jussi

On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <[hidden email]
> wrote:

> in the following code:
>
>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>
> IDE said error invalid argument, but if i do:
>
>     psotionlen = InStr(strinchar, ")", -1) - 1
>      strinchar = Mid(strinchar, 1, psotionlen)
>
> works, why?
>
> i wnat to remove the last occurence of a char but bybass some possible
> spaces/chars at the end of string
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
> ------------------------------------------------------------
> ------------------
> 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
> [hidden email]
> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Jussi Lahtinen
Hmmm... sorry, no mistake... I will look closer.


Jussi

On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <[hidden email]>
wrote:

> Because the line makes no sense at all. Try to remove ")".
>
>
> Jussi
>
> On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <
> [hidden email]> wrote:
>
>> in the following code:
>>
>>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>>
>> IDE said error invalid argument, but if i do:
>>
>>     psotionlen = InStr(strinchar, ")", -1) - 1
>>      strinchar = Mid(strinchar, 1, psotionlen)
>>
>> works, why?
>>
>> i wnat to remove the last occurence of a char but bybass some possible
>> spaces/chars at the end of string
>>
>> Lenz McKAY Gerardo (PICCORO)
>> http://qgqlochekone.blogspot.com
>> ------------------------------------------------------------
>> ------------------
>> 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
>> [hidden email]
>> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Jussi Lahtinen
No... again. My initial mail was correct. It should be:
strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))

But the IDE makes highlighting bug with the brackets.


Jussi

On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <[hidden email]>
wrote:

> Hmmm... sorry, no mistake... I will look closer.
>
>
> Jussi
>
> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <[hidden email]>
> wrote:
>
>> Because the line makes no sense at all. Try to remove ")".
>>
>>
>> Jussi
>>
>> On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <
>> [hidden email]> wrote:
>>
>>> in the following code:
>>>
>>>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>>>
>>> IDE said error invalid argument, but if i do:
>>>
>>>     psotionlen = InStr(strinchar, ")", -1) - 1
>>>      strinchar = Mid(strinchar, 1, psotionlen)
>>>
>>> works, why?
>>>
>>> i wnat to remove the last occurence of a char but bybass some possible
>>> spaces/chars at the end of string
>>>
>>> Lenz McKAY Gerardo (PICCORO)
>>> http://qgqlochekone.blogspot.com
>>> ------------------------------------------------------------
>>> ------------------
>>> 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
>>> [hidden email]
>>> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Adrien Prokopowicz-2

Le Sat, 29 Jul 2017 02:40:44 +0200, Jussi Lahtinen  
<[hidden email]> a écrit:

> No... again. My initial mail was correct. It should be:
> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))
>
> But the IDE makes highlighting bug with the brackets.
>
>
> Jussi
>
> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen  
> <[hidden email]>
> wrote:
>
>> Hmmm... sorry, no mistake... I will look closer.
>>
>>
>> Jussi
>>
>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen  
>> <[hidden email]>
>> wrote:
>>
>>> Because the line makes no sense at all. Try to remove ")".
>>>
>>>
>>> Jussi
>>>
>>> On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <
>>> [hidden email]> wrote:
>>>
>>>> in the following code:
>>>>
>>>>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>>>>
>>>> IDE said error invalid argument, but if i do:
>>>>
>>>>     psotionlen = InStr(strinchar, ")", -1) - 1
>>>>      strinchar = Mid(strinchar, 1, psotionlen)
>>>>
>>>> works, why?
>>>>
>>>> i wnat to remove the last occurence of a char but bybass some possible
>>>> spaces/chars at the end of string
>>>>
>>>> Lenz McKAY Gerardo (PICCORO)
>>>> http://qgqlochekone.blogspot.com

Actually, his original code is correct. For me it runs without error in  
the IDE using
the 3.10 development version, but the editor is indeed having trouble  
matching the
parentheses.

I also tried it on the playground (which also uses 3.10) and it works
fine :  
https://gambas-playground.proko.eu/?gist=97ed16795393aa3b68913025e5d2b83c .

However the playground's editor does match the parentheses correctly. :)

Which Gambas version are you using ? There may be an old bug here.

--
Adrien Prokopowicz

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Fernando Cabral
In reply to this post by PICCORO McKAY Lenz
2017-07-28 20:46 GMT-03:00 PICCORO McKAY Lenz <[hidden email]>:

> 2017-07-28 17:17 GMT-04:00 Fernando Cabral <[hidden email]>:
>
>> > in the following code:
>> >     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>> > What does inStr() returns if nothing is found? You may be passing an
>> invalid argument to Mid().
>> Please, check it up.
>>
>
> fernando check it up you, if i do the instr() -1 separately works... dou
> you see the code before answer:
>
>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1) ' does
> not work
>
> IDE said error invalid argument, but if i do:
>
>     psotionlen = InStr(strinchar, ")", -1) - 1   ' separate the stolen
> and..
>      strinchar = Mid(strinchar, 1, psotionlen)  ' put in here then works
> ?!?!?!!?
>
> works, why?
>

I did the following test. It did not work as expected, but it did work.
I mean, I got no errors, but it did not work as expected in the sense that
the search seems always to be done from left to right, not right to left,
even if the third parameter is negative.

   Dim strinchar As String
   Dim positionlen As Integer

    strinchar = "test )after)r"
    positionlen = String.InStr(strinchar, ")", -1) - 1
    Print strinchar
    Print positionlen
    strinchar = Mid(strinchar, 1, positionlen)
    Print strinchar
    strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
    Print strinchar


This prints:

test )after)r
5
test
test

Regards

- fernando



>
>> - fernando
>>
>> > IDE said error invalid argument, but if i do:
>> >
>> >     psotionlen = InStr(strinchar, ")", -1) - 1
>> >      strinchar = Mid(strinchar, 1, psotionlen)
>> >
>> > works, why?
>> >
>> > i wnat to remove the last occurence of a char but bybass some possible
>> > spaces/chars at the end of string
>> >
>> > Lenz McKAY Gerardo (PICCORO)
>> > http://qgqlochekone.blogspot.com
>> > ------------------------------------------------------------
>> > ------------------
>> > 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
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>> >
>>
>>
>>
>> --
>> Fernando Cabral
>> Blogue: http://fernandocabral.org
>> Twitter: http://twitter.com/fjcabral
>> e-mail <http://twitter.com/fjcabral%0Ae-mail>:
>> [hidden email]
>> Facebook: [hidden email]
>> Telegram: +55 (37) 99988-8868 <%2837%29%2099988-8868>
>> Wickr ID: fernandocabral
>> WhatsApp: +55 (37) 99988-8868 <%2837%29%2099988-8868>
>> Skype:  fernandojosecabral
>> Telefone fixo: +55 (37) 3521-2183 <%2837%29%203521-2183>
>> Telefone celular: +55 (37) 99988-8868 <%2837%29%2099988-8868>
>>
>> Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
>> nenhum político ou cientista poderá se gabar de nada.
>> ------------------------------------------------------------
>> ------------------
>> 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
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
>


--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Fernando Cabral
In reply to this post by Adrien Prokopowicz-2
Piccoro, sorry for my previous information. Something was missing.
In fact, both versions work the same:












*  strinchar = "test )after)r"    positionlen = (InStr(strinchar, ")", -1)
- 1)    Print strinchar    Print positionlen    strinchar = Mid(strinchar,
1, positionlen)     Print strinchar    strinchar = "test )after)r"
strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))    Print
strinchar *
Both print  "test )after"

- fernando

2017-07-28 22:02 GMT-03:00 Adrien Prokopowicz <[hidden email]>
:

>
> Le Sat, 29 Jul 2017 02:40:44 +0200, Jussi Lahtinen <
> [hidden email]> a écrit:
>
> No... again. My initial mail was correct. It should be:
>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))
>>
>> But the IDE makes highlighting bug with the brackets.
>>
>>
>> Jussi
>>
>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <[hidden email]
>> >
>> wrote:
>>
>> Hmmm... sorry, no mistake... I will look closer.
>>>
>>>
>>> Jussi
>>>
>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>> [hidden email]>
>>> wrote:
>>>
>>> Because the line makes no sense at all. Try to remove ")".
>>>>
>>>>
>>>> Jussi
>>>>
>>>> On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <
>>>> [hidden email]> wrote:
>>>>
>>>> in the following code:
>>>>>
>>>>>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>>>>>
>>>>> IDE said error invalid argument, but if i do:
>>>>>
>>>>>     psotionlen = InStr(strinchar, ")", -1) - 1
>>>>>      strinchar = Mid(strinchar, 1, psotionlen)
>>>>>
>>>>> works, why?
>>>>>
>>>>> i wnat to remove the last occurence of a char but bybass some possible
>>>>> spaces/chars at the end of string
>>>>>
>>>>> Lenz McKAY Gerardo (PICCORO)
>>>>> http://qgqlochekone.blogspot.com
>>>>>
>>>>
> Actually, his original code is correct. For me it runs without error in
> the IDE using
> the 3.10 development version, but the editor is indeed having trouble
> matching the
> parentheses.
>
> I also tried it on the playground (which also uses 3.10) and it works
> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
> 13025e5d2b83c .
>
> However the playground's editor does match the parentheses correctly. :)
>
> Which Gambas version are you using ? There may be an old bug here.
>
> --
> Adrien Prokopowicz
>
>
> ------------------------------------------------------------
> ------------------
> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Tony Morehen
It's difficult to say for sure what's happening without Piccaro's test
strings.  However, 2 things do come to mind.

First, according to Gambas doc, InStr(strinchar, ")", -n) does a left to
right search for ")", starting at -n  characters from the end of
strinchar.  So if Instr doesn't find ")", it will return 0, which, in
conjunction with the second -1, will cause mid to drop the last
character of strinchar.  So to get the answer you want, use
RInstr(strinchar,")"). which will do a right to left search for ")",
starting at the end of strinchar.

Second, there may be a bug in gambas, or the documentation needs to make
clear what end of string means.  This is best explained by example:

Instr("(foo)",")",-1) returns 5
Instr("(foo)f",")",-1) returns 5
Instr("(foo)ff",")",-1) returns 0

This means that Instr(s1,s2,-1) begins its search one character before
the last character of the string.  So end of string actually means last
character of the string and the docs should make that explicit or there
is a bug if the intended meaning of end of string is the position after
the last character of the string.


On 2017-07-28 09:31 PM, Fernando Cabral wrote:

> Piccoro, sorry for my previous information. Something was missing.
> In fact, both versions work the same:
>
>
>
>
>
>
>
>
>
>
>
>
> *  strinchar = "test )after)r"    positionlen = (InStr(strinchar, ")", -1)
> - 1)    Print strinchar    Print positionlen    strinchar = Mid(strinchar,
> 1, positionlen)     Print strinchar    strinchar = "test )after)r"
> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))    Print
> strinchar *
> Both print  "test )after"
>
> - fernando
>
> 2017-07-28 22:02 GMT-03:00 Adrien Prokopowicz <[hidden email]>
> :
>
>> Le Sat, 29 Jul 2017 02:40:44 +0200, Jussi Lahtinen <
>> [hidden email]> a écrit:
>>
>> No... again. My initial mail was correct. It should be:
>>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))
>>>
>>> But the IDE makes highlighting bug with the brackets.
>>>
>>>
>>> Jussi
>>>
>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <[hidden email]
>>> wrote:
>>>
>>> Hmmm... sorry, no mistake... I will look closer.
>>>>
>>>> Jussi
>>>>
>>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>>> [hidden email]>
>>>> wrote:
>>>>
>>>> Because the line makes no sense at all. Try to remove ")".
>>>>>
>>>>> Jussi
>>>>>
>>>>> On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <
>>>>> [hidden email]> wrote:
>>>>>
>>>>> in the following code:
>>>>>>      strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>>>>>>
>>>>>> IDE said error invalid argument, but if i do:
>>>>>>
>>>>>>      psotionlen = InStr(strinchar, ")", -1) - 1
>>>>>>       strinchar = Mid(strinchar, 1, psotionlen)
>>>>>>
>>>>>> works, why?
>>>>>>
>>>>>> i wnat to remove the last occurence of a char but bybass some possible
>>>>>> spaces/chars at the end of string
>>>>>>
>>>>>> Lenz McKAY Gerardo (PICCORO)
>>>>>> http://qgqlochekone.blogspot.com
>>>>>>
>> Actually, his original code is correct. For me it runs without error in
>> the IDE using
>> the 3.10 development version, but the editor is indeed having trouble
>> matching the
>> parentheses.
>>
>> I also tried it on the playground (which also uses 3.10) and it works
>> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
>> 13025e5d2b83c .
>>
>> However the playground's editor does match the parentheses correctly. :)
>>
>> Which Gambas version are you using ? There may be an old bug here.
>>
>> --
>> Adrien Prokopowicz
>>
>>
>> ------------------------------------------------------------
>> ------------------
>> 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
>> [hidden email]
>> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

PICCORO McKAY Lenz
HEY TONY; ITS PICCORO; NOT PICARO! GRRRRR

in the playground wprks perfectly, i not have 3.10, but in the job i have
3.1 and at my home 3.5
its a bug in 3.9 and 3.8, *with 3.1 works perfectly in debian squeeze (very
older but better)*

2017-07-28 21:02 GMT-04:00 Adrien Prokopowicz <[hidden email]>
:

> Actually, his original code is correct. For me it runs without error in
> the IDE using
> the 3.10 development version, but the editor is indeed having trouble
> matching the
> parentheses.
>
me too, the edtor has some problems, when the ide made a word wrap, and i
have thesame behaviour, parentheses does not matching correctly..


> I also tried it on the playground (which also uses 3.10) and it works
> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
> 13025e5d2b83c .
>
tested, me too..


> However the playground's editor does match the parentheses correctly. :)
>
jajaja excelent work!


>
> Which Gambas version are you using ? There may be an old bug here.
>
3.9.1 with some git patches..

in the job i have 3.1 and at my home 3.5

its a bug in 3.9 and 3.8, with 3.1 works perfectly in debian squeeze (very
older but better)



Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2017-07-28 23:46 GMT-04:00 Tony Morehen <[hidden email]>:

> It's difficult to say for sure what's happening without Piccaro's test
> strings.  However, 2 things do come to mind.
>
> First, according to Gambas doc, InStr(strinchar, ")", -n) does a left to
> right search for ")", starting at -n  characters from the end of
> strinchar.  So if Instr doesn't find ")", it will return 0, which, in
> conjunction with the second -1, will cause mid to drop the last character
> of strinchar.  So to get the answer you want, use RInstr(strinchar,")").
> which will do a right to left search for ")", starting at the end of
> strinchar.
>
> Second, there may be a bug in gambas, or the documentation needs to make
> clear what end of string means.  This is best explained by example:
>
> Instr("(foo)",")",-1) returns 5
> Instr("(foo)f",")",-1) returns 5
> Instr("(foo)ff",")",-1) returns 0
>
> This means that Instr(s1,s2,-1) begins its search one character before the
> last character of the string.  So end of string actually means last
> character of the string and the docs should make that explicit or there is
> a bug if the intended meaning of end of string is the position after the
> last character of the string.
>
>
>
> On 2017-07-28 09:31 PM, Fernando Cabral wrote:
>
>> Piccoro, sorry for my previous information. Something was missing.
>> In fact, both versions work the same:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *  strinchar = "test )after)r"    positionlen = (InStr(strinchar, ")", -1)
>> - 1)    Print strinchar    Print positionlen    strinchar = Mid(strinchar,
>> 1, positionlen)     Print strinchar    strinchar = "test )after)r"
>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))    Print
>> strinchar *
>> Both print  "test )after"
>>
>> - fernando
>>
>> 2017-07-28 22:02 GMT-03:00 Adrien Prokopowicz <
>> [hidden email]>
>> :
>>
>> Le Sat, 29 Jul 2017 02:40:44 +0200, Jussi Lahtinen <
>>> [hidden email]> a écrit:
>>>
>>> No... again. My initial mail was correct. It should be:
>>>
>>>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))
>>>>
>>>> But the IDE makes highlighting bug with the brackets.
>>>>
>>>>
>>>> Jussi
>>>>
>>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>>> [hidden email]
>>>> wrote:
>>>>
>>>> Hmmm... sorry, no mistake... I will look closer.
>>>>
>>>>>
>>>>> Jussi
>>>>>
>>>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>>>> [hidden email]>
>>>>> wrote:
>>>>>
>>>>> Because the line makes no sense at all. Try to remove ")".
>>>>>
>>>>>>
>>>>>> Jussi
>>>>>>
>>>>>> On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <
>>>>>> [hidden email]> wrote:
>>>>>>
>>>>>> in the following code:
>>>>>>
>>>>>>>      strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>>>>>>>
>>>>>>> IDE said error invalid argument, but if i do:
>>>>>>>
>>>>>>>      psotionlen = InStr(strinchar, ")", -1) - 1
>>>>>>>       strinchar = Mid(strinchar, 1, psotionlen)
>>>>>>>
>>>>>>> works, why?
>>>>>>>
>>>>>>> i wnat to remove the last occurence of a char but bybass some
>>>>>>> possible
>>>>>>> spaces/chars at the end of string
>>>>>>>
>>>>>>> Lenz McKAY Gerardo (PICCORO)
>>>>>>> http://qgqlochekone.blogspot.com
>>>>>>>
>>>>>>> Actually, his original code is correct. For me it runs without error
>>> in
>>> the IDE using
>>> the 3.10 development version, but the editor is indeed having trouble
>>> matching the
>>> parentheses.
>>>
>>> I also tried it on the playground (which also uses 3.10) and it works
>>> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
>>> 13025e5d2b83c .
>>>
>>> However the playground's editor does match the parentheses correctly. :)
>>>
>>> Which Gambas version are you using ? There may be an old bug here.
>>>
>>> --
>>> Adrien Prokopowicz
>>>
>>>
>>> ------------------------------------------------------------
>>> ------------------
>>> 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
>>> [hidden email]
>>> 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
> [hidden email]
> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Tony Morehen
Sorry about that,

What strings are you using?  What output do you want?  For example:
fn("(foo)") do you want "(foo)"  or "(foo"  yours returns "(foo"
fn("(foo)x") do you want "(foo)" or "(foo" yours returns "(foo"
fn("(foo)xx") do you want "(foo)" or "(foo" or "(foo)x" yours returns
"(foo)x"
fn("(foo)xxx") do you want "(foo)" or "(foo" or "(foo)x" or "(foo)xx"
yours returns "(foo)xx"

Let's get the algorithm right.  Then worry about bugs.

On 2017-07-28 11:53 PM, PICCORO McKAY Lenz wrote:

> HEY TONY; ITS PICCORO; NOT PICARO! GRRRRR
>
> in the playground wprks perfectly, i not have 3.10, but in the job i have
> 3.1 and at my home 3.5
> its a bug in 3.9 and 3.8, *with 3.1 works perfectly in debian squeeze (very
> older but better)*
>
> 2017-07-28 21:02 GMT-04:00 Adrien Prokopowicz <[hidden email]>
> :
>
>> Actually, his original code is correct. For me it runs without error in
>> the IDE using
>> the 3.10 development version, but the editor is indeed having trouble
>> matching the
>> parentheses.
>>
> me too, the edtor has some problems, when the ide made a word wrap, and i
> have thesame behaviour, parentheses does not matching correctly..
>
>
>> I also tried it on the playground (which also uses 3.10) and it works
>> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
>> 13025e5d2b83c .
>>
> tested, me too..
>
>
>> However the playground's editor does match the parentheses correctly. :)
>>
> jajaja excelent work!
>
>
>> Which Gambas version are you using ? There may be an old bug here.
>>
> 3.9.1 with some git patches..
>
> in the job i have 3.1 and at my home 3.5
>
> its a bug in 3.9 and 3.8, with 3.1 works perfectly in debian squeeze (very
> older but better)
>
>
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
>
> 2017-07-28 23:46 GMT-04:00 Tony Morehen <[hidden email]>:
>
>> It's difficult to say for sure what's happening without Piccaro's test
>> strings.  However, 2 things do come to mind.
>>
>> First, according to Gambas doc, InStr(strinchar, ")", -n) does a left to
>> right search for ")", starting at -n  characters from the end of
>> strinchar.  So if Instr doesn't find ")", it will return 0, which, in
>> conjunction with the second -1, will cause mid to drop the last character
>> of strinchar.  So to get the answer you want, use RInstr(strinchar,")").
>> which will do a right to left search for ")", starting at the end of
>> strinchar.
>>
>> Second, there may be a bug in gambas, or the documentation needs to make
>> clear what end of string means.  This is best explained by example:
>>
>> Instr("(foo)",")",-1) returns 5
>> Instr("(foo)f",")",-1) returns 5
>> Instr("(foo)ff",")",-1) returns 0
>>
>> This means that Instr(s1,s2,-1) begins its search one character before the
>> last character of the string.  So end of string actually means last
>> character of the string and the docs should make that explicit or there is
>> a bug if the intended meaning of end of string is the position after the
>> last character of the string.
>>
>>
>>
>> On 2017-07-28 09:31 PM, Fernando Cabral wrote:
>>
>>> Piccoro, sorry for my previous information. Something was missing.
>>> In fact, both versions work the same:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *  strinchar = "test )after)r"    positionlen = (InStr(strinchar, ")", -1)
>>> - 1)    Print strinchar    Print positionlen    strinchar = Mid(strinchar,
>>> 1, positionlen)     Print strinchar    strinchar = "test )after)r"
>>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))    Print
>>> strinchar *
>>> Both print  "test )after"
>>>
>>> - fernando
>>>
>>> 2017-07-28 22:02 GMT-03:00 Adrien Prokopowicz <
>>> [hidden email]>
>>> :
>>>
>>> Le Sat, 29 Jul 2017 02:40:44 +0200, Jussi Lahtinen <
>>>> [hidden email]> a écrit:
>>>>
>>>> No... again. My initial mail was correct. It should be:
>>>>
>>>>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))
>>>>>
>>>>> But the IDE makes highlighting bug with the brackets.
>>>>>
>>>>>
>>>>> Jussi
>>>>>
>>>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>>>> [hidden email]
>>>>> wrote:
>>>>>
>>>>> Hmmm... sorry, no mistake... I will look closer.
>>>>>
>>>>>> Jussi
>>>>>>
>>>>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>>>>> [hidden email]>
>>>>>> wrote:
>>>>>>
>>>>>> Because the line makes no sense at all. Try to remove ")".
>>>>>>
>>>>>>> Jussi
>>>>>>>
>>>>>>> On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <
>>>>>>> [hidden email]> wrote:
>>>>>>>
>>>>>>> in the following code:
>>>>>>>
>>>>>>>>       strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>>>>>>>>
>>>>>>>> IDE said error invalid argument, but if i do:
>>>>>>>>
>>>>>>>>       psotionlen = InStr(strinchar, ")", -1) - 1
>>>>>>>>        strinchar = Mid(strinchar, 1, psotionlen)
>>>>>>>>
>>>>>>>> works, why?
>>>>>>>>
>>>>>>>> i wnat to remove the last occurence of a char but bybass some
>>>>>>>> possible
>>>>>>>> spaces/chars at the end of string
>>>>>>>>
>>>>>>>> Lenz McKAY Gerardo (PICCORO)
>>>>>>>> http://qgqlochekone.blogspot.com
>>>>>>>>
>>>>>>>> Actually, his original code is correct. For me it runs without error
>>>> in
>>>> the IDE using
>>>> the 3.10 development version, but the editor is indeed having trouble
>>>> matching the
>>>> parentheses.
>>>>
>>>> I also tried it on the playground (which also uses 3.10) and it works
>>>> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
>>>> 13025e5d2b83c .
>>>>
>>>> However the playground's editor does match the parentheses correctly. :)
>>>>
>>>> Which Gambas version are you using ? There may be an old bug here.
>>>>
>>>> --
>>>> Adrien Prokopowicz
>>>>
>>>>
>>>> ------------------------------------------------------------
>>>> ------------------
>>>> 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
>>>> [hidden email]
>>>> 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
>> [hidden email]
>> 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
> [hidden email]
> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

PICCORO McKAY Lenz
i not at the depot, and in my work i have gambas 3.1 (wheeze/squeeze), the
"rare" behaviour are at the depot of my work with gambas 3.9

but as adrien said: works in playgroud and works at my home in gambas 3.1,
in few hours i go to the depot and paste the code..

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2017-07-29 0:15 GMT-04:00 Tony Morehen <[hidden email]>:

> Sorry about that,
>
> What strings are you using?  What output do you want?  For example:
> fn("(foo)") do you want "(foo)"  or "(foo"  yours returns "(foo"
> fn("(foo)x") do you want "(foo)" or "(foo" yours returns "(foo"
> fn("(foo)xx") do you want "(foo)" or "(foo" or "(foo)x" yours returns
> "(foo)x"
> fn("(foo)xxx") do you want "(foo)" or "(foo" or "(foo)x" or "(foo)xx"
> yours returns "(foo)xx"
>
> Let's get the algorithm right.  Then worry about bugs.
>
> On 2017-07-28 11:53 PM, PICCORO McKAY Lenz wrote:
>
>> HEY TONY; ITS PICCORO; NOT PICARO! GRRRRR
>>
>> in the playground wprks perfectly, i not have 3.10, but in the job i have
>> 3.1 and at my home 3.5
>> its a bug in 3.9 and 3.8, *with 3.1 works perfectly in debian squeeze
>> (very
>> older but better)*
>>
>>
>> 2017-07-28 21:02 GMT-04:00 Adrien Prokopowicz <
>> [hidden email]>
>> :
>>
>> Actually, his original code is correct. For me it runs without error in
>>> the IDE using
>>> the 3.10 development version, but the editor is indeed having trouble
>>> matching the
>>> parentheses.
>>>
>>> me too, the edtor has some problems, when the ide made a word wrap, and i
>> have thesame behaviour, parentheses does not matching correctly..
>>
>>
>> I also tried it on the playground (which also uses 3.10) and it works
>>> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
>>> 13025e5d2b83c .
>>>
>>> tested, me too..
>>
>>
>> However the playground's editor does match the parentheses correctly. :)
>>>
>>> jajaja excelent work!
>>
>>
>> Which Gambas version are you using ? There may be an old bug here.
>>>
>>> 3.9.1 with some git patches..
>>
>> in the job i have 3.1 and at my home 3.5
>>
>> its a bug in 3.9 and 3.8, with 3.1 works perfectly in debian squeeze (very
>> older but better)
>>
>>
>>
>> Lenz McKAY Gerardo (PICCORO)
>> http://qgqlochekone.blogspot.com
>>
>> 2017-07-28 23:46 GMT-04:00 Tony Morehen <[hidden email]>:
>>
>> It's difficult to say for sure what's happening without Piccaro's test
>>> strings.  However, 2 things do come to mind.
>>>
>>> First, according to Gambas doc, InStr(strinchar, ")", -n) does a left to
>>> right search for ")", starting at -n  characters from the end of
>>> strinchar.  So if Instr doesn't find ")", it will return 0, which, in
>>> conjunction with the second -1, will cause mid to drop the last character
>>> of strinchar.  So to get the answer you want, use RInstr(strinchar,")").
>>> which will do a right to left search for ")", starting at the end of
>>> strinchar.
>>>
>>> Second, there may be a bug in gambas, or the documentation needs to make
>>> clear what end of string means.  This is best explained by example:
>>>
>>> Instr("(foo)",")",-1) returns 5
>>> Instr("(foo)f",")",-1) returns 5
>>> Instr("(foo)ff",")",-1) returns 0
>>>
>>> This means that Instr(s1,s2,-1) begins its search one character before
>>> the
>>> last character of the string.  So end of string actually means last
>>> character of the string and the docs should make that explicit or there
>>> is
>>> a bug if the intended meaning of end of string is the position after the
>>> last character of the string.
>>>
>>>
>>>
>>> On 2017-07-28 09:31 PM, Fernando Cabral wrote:
>>>
>>> Piccoro, sorry for my previous information. Something was missing.
>>>> In fact, both versions work the same:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *  strinchar = "test )after)r"    positionlen = (InStr(strinchar, ")",
>>>> -1)
>>>> - 1)    Print strinchar    Print positionlen    strinchar =
>>>> Mid(strinchar,
>>>> 1, positionlen)     Print strinchar    strinchar = "test )after)r"
>>>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))    Print
>>>> strinchar *
>>>> Both print  "test )after"
>>>>
>>>> - fernando
>>>>
>>>> 2017-07-28 22:02 GMT-03:00 Adrien Prokopowicz <
>>>> [hidden email]>
>>>> :
>>>>
>>>> Le Sat, 29 Jul 2017 02:40:44 +0200, Jussi Lahtinen <
>>>>
>>>>> [hidden email]> a écrit:
>>>>>
>>>>> No... again. My initial mail was correct. It should be:
>>>>>
>>>>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))
>>>>>>
>>>>>> But the IDE makes highlighting bug with the brackets.
>>>>>>
>>>>>>
>>>>>> Jussi
>>>>>>
>>>>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>>>>> [hidden email]
>>>>>> wrote:
>>>>>>
>>>>>> Hmmm... sorry, no mistake... I will look closer.
>>>>>>
>>>>>> Jussi
>>>>>>>
>>>>>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>>>>>> [hidden email]>
>>>>>>> wrote:
>>>>>>>
>>>>>>> Because the line makes no sense at all. Try to remove ")".
>>>>>>>
>>>>>>> Jussi
>>>>>>>>
>>>>>>>> On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <
>>>>>>>> [hidden email]> wrote:
>>>>>>>>
>>>>>>>> in the following code:
>>>>>>>>
>>>>>>>>       strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>>>>>>>>>
>>>>>>>>> IDE said error invalid argument, but if i do:
>>>>>>>>>
>>>>>>>>>       psotionlen = InStr(strinchar, ")", -1) - 1
>>>>>>>>>        strinchar = Mid(strinchar, 1, psotionlen)
>>>>>>>>>
>>>>>>>>> works, why?
>>>>>>>>>
>>>>>>>>> i wnat to remove the last occurence of a char but bybass some
>>>>>>>>> possible
>>>>>>>>> spaces/chars at the end of string
>>>>>>>>>
>>>>>>>>> Lenz McKAY Gerardo (PICCORO)
>>>>>>>>> http://qgqlochekone.blogspot.com
>>>>>>>>>
>>>>>>>>> Actually, his original code is correct. For me it runs without
>>>>>>>>> error
>>>>>>>>>
>>>>>>>> in
>>>>> the IDE using
>>>>> the 3.10 development version, but the editor is indeed having trouble
>>>>> matching the
>>>>> parentheses.
>>>>>
>>>>> I also tried it on the playground (which also uses 3.10) and it works
>>>>> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
>>>>> 13025e5d2b83c .
>>>>>
>>>>> However the playground's editor does match the parentheses correctly.
>>>>> :)
>>>>>
>>>>> Which Gambas version are you using ? There may be an old bug here.
>>>>>
>>>>> --
>>>>> Adrien Prokopowicz
>>>>>
>>>>>
>>>>> ------------------------------------------------------------
>>>>> ------------------
>>>>> 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
>>>>> [hidden email]
>>>>> 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
>>> [hidden email]
>>> 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
>> [hidden email]
>> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Matti
In reply to this post by PICCORO McKAY Lenz
YOU complainig-shouting about a typo!


Am 29.07.2017 um 05:53 schrieb PICCORO McKAY Lenz:

> HEY TONY; ITS PICCORO; NOT PICARO! GRRRRR
>
> in the playground wprks perfectly, i not have 3.10, but in the job i have
> 3.1 and at my home 3.5
> its a bug in 3.9 and 3.8, *with 3.1 works perfectly in debian squeeze (very
> older but better)*
>
> 2017-07-28 21:02 GMT-04:00 Adrien Prokopowicz <[hidden email]>
> :
>
>> Actually, his original code is correct. For me it runs without error in
>> the IDE using
>> the 3.10 development version, but the editor is indeed having trouble
>> matching the
>> parentheses.
>>
> me too, the edtor has some problems, when the ide made a word wrap, and i
> have thesame behaviour, parentheses does not matching correctly..
>
>
>> I also tried it on the playground (which also uses 3.10) and it works
>> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
>> 13025e5d2b83c .
>>
> tested, me too..
>
>
>> However the playground's editor does match the parentheses correctly. :)
>>
> jajaja excelent work!
>
>
>> Which Gambas version are you using ? There may be an old bug here.
>>
> 3.9.1 with some git patches..
>
> in the job i have 3.1 and at my home 3.5
>
> its a bug in 3.9 and 3.8, with 3.1 works perfectly in debian squeeze (very
> older but better)
>
>
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
>
> 2017-07-28 23:46 GMT-04:00 Tony Morehen <[hidden email]>:
>
>> It's difficult to say for sure what's happening without Piccaro's test
>> strings.  However, 2 things do come to mind.
>>
>> First, according to Gambas doc, InStr(strinchar, ")", -n) does a left to
>> right search for ")", starting at -n  characters from the end of
>> strinchar.  So if Instr doesn't find ")", it will return 0, which, in
>> conjunction with the second -1, will cause mid to drop the last character
>> of strinchar.  So to get the answer you want, use RInstr(strinchar,")").
>> which will do a right to left search for ")", starting at the end of
>> strinchar.
>>
>> Second, there may be a bug in gambas, or the documentation needs to make
>> clear what end of string means.  This is best explained by example:
>>
>> Instr("(foo)",")",-1) returns 5
>> Instr("(foo)f",")",-1) returns 5
>> Instr("(foo)ff",")",-1) returns 0
>>
>> This means that Instr(s1,s2,-1) begins its search one character before the
>> last character of the string.  So end of string actually means last
>> character of the string and the docs should make that explicit or there is
>> a bug if the intended meaning of end of string is the position after the
>> last character of the string.
>>
>>
>>
>> On 2017-07-28 09:31 PM, Fernando Cabral wrote:
>>
>>> Piccoro, sorry for my previous information. Something was missing.
>>> In fact, both versions work the same:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *  strinchar = "test )after)r"    positionlen = (InStr(strinchar, ")", -1)
>>> - 1)    Print strinchar    Print positionlen    strinchar = Mid(strinchar,
>>> 1, positionlen)     Print strinchar    strinchar = "test )after)r"
>>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))    Print
>>> strinchar *
>>> Both print  "test )after"
>>>
>>> - fernando
>>>
>>> 2017-07-28 22:02 GMT-03:00 Adrien Prokopowicz <
>>> [hidden email]>
>>> :
>>>
>>> Le Sat, 29 Jul 2017 02:40:44 +0200, Jussi Lahtinen <
>>>> [hidden email]> a écrit:
>>>>
>>>> No... again. My initial mail was correct. It should be:
>>>>
>>>>> strinchar = Mid(strinchar, 1, (InStr(strinchar, ")", -1) - 1))
>>>>>
>>>>> But the IDE makes highlighting bug with the brackets.
>>>>>
>>>>>
>>>>> Jussi
>>>>>
>>>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>>>> [hidden email]
>>>>> wrote:
>>>>>
>>>>> Hmmm... sorry, no mistake... I will look closer.
>>>>>
>>>>>> Jussi
>>>>>>
>>>>>> On Sat, Jul 29, 2017 at 3:33 AM, Jussi Lahtinen <
>>>>>> [hidden email]>
>>>>>> wrote:
>>>>>>
>>>>>> Because the line makes no sense at all. Try to remove ")".
>>>>>>
>>>>>>> Jussi
>>>>>>>
>>>>>>> On Fri, Jul 28, 2017 at 11:55 PM, PICCORO McKAY Lenz <
>>>>>>> [hidden email]> wrote:
>>>>>>>
>>>>>>> in the following code:
>>>>>>>
>>>>>>>>       strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>>>>>>>>
>>>>>>>> IDE said error invalid argument, but if i do:
>>>>>>>>
>>>>>>>>       psotionlen = InStr(strinchar, ")", -1) - 1
>>>>>>>>        strinchar = Mid(strinchar, 1, psotionlen)
>>>>>>>>
>>>>>>>> works, why?
>>>>>>>>
>>>>>>>> i wnat to remove the last occurence of a char but bybass some
>>>>>>>> possible
>>>>>>>> spaces/chars at the end of string
>>>>>>>>
>>>>>>>> Lenz McKAY Gerardo (PICCORO)
>>>>>>>> http://qgqlochekone.blogspot.com
>>>>>>>>
>>>>>>>> Actually, his original code is correct. For me it runs without error
>>>> in
>>>> the IDE using
>>>> the 3.10 development version, but the editor is indeed having trouble
>>>> matching the
>>>> parentheses.
>>>>
>>>> I also tried it on the playground (which also uses 3.10) and it works
>>>> fine : https://gambas-playground.proko.eu/?gist=97ed16795393aa3b689
>>>> 13025e5d2b83c .
>>>>
>>>> However the playground's editor does match the parentheses correctly. :)
>>>>
>>>> Which Gambas version are you using ? There may be an old bug here.
>>>>
>>>> --
>>>> Adrien Prokopowicz
>>>>
>>>>
>>>> ------------------------------------------------------------
>>>> ------------------
>>>> 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
>>>> [hidden email]
>>>> 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
>> [hidden email]
>> 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
> [hidden email]
> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: why this could not be? error in runtime?

Christof Thalhofer
In reply to this post by PICCORO McKAY Lenz
Am 28.07.2017 um 22:55 schrieb PICCORO McKAY Lenz:

> in the following code:
>
>     strinchar = Mid(strinchar, 1, InStr(strinchar, ")", -1) - 1)
>
> IDE said error invalid argument, but if i do:

No, the IDE says nothing:

Public Sub Test()

  Dim strinchar As String
  Dim psotionlen As Integer

  ' ------------------------------------------------- 1
  strinchar = "strat)edn1"

  strinchar = Mid(strinchar, 1, InStr(strinchar, "u", -1) - 1)

  Print strinchar

  ' ------------------------------------------------- 2
  strinchar = "strat)edn1"

  psotionlen = InStr(strinchar, ")", -1) - 1
  strinchar = Mid(strinchar, 1, psotionlen)

  Print strinchar

  ' ------------------------------------------------- 3
  ' but the only thing this does is (AFAIK)

  strinchar = "strat)edn1"

  Print Left(strinchar, Len(strinchar) - 1)

End

Result is:

strat)edn
strat)edn
strat)edn

:-)

Maybe you should write and code a little slower. ;-)


Alles Gute

Christof Thalhofer

--
Dies ist keine Signatur


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user

signature.asc (836 bytes) Download Attachment