Quantcast

poking around near the end of a string

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

poking around near the end of a string

Richmond Mathewson via use-livecode
Suppose I have a string a bit like this:

"and then the gigantic monster bit my mother on the nose $W"

and I want to check that that string ends with "$W" . . .

I tried this (pseudo code):

*if the ((last char) & (last char -1)) of MNOSE = "$W"*

and it did not work.


Richmond.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: poking around near the end of a string

Richmond Mathewson via use-livecode
Hi Richmond,

> Am 10.05.2017 um 16:18 schrieb Richmond via use-livecode <[hidden email]>:
>
> Suppose I have a string a bit like this:
>
> "and then the gigantic monster bit my mother on the nose $W"
> and I want to check that that string ends with "$W" . . .
> I tried this (pseudo code):
> *if the ((last char) & (last char -1)) of MNOSE = "$W"*
> and it did not work.

this does work:
...
if MNOSE ends with "$W" then
...
if char -2 to -1 of MNOSE = "$W" then
...

> Richmond.

Best

Klaus

--
Klaus Major
http://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: poking around near the end of a string

Richmond Mathewson via use-livecode
Thanks.

Richmond.

On 10.05.2017 17:31, Klaus major-k via use-livecode wrote:

> Hi Richmond,
>
>> Am 10.05.2017 um 16:18 schrieb Richmond via use-livecode <[hidden email]>:
>>
>> Suppose I have a string a bit like this:
>>
>> "and then the gigantic monster bit my mother on the nose $W"
>> and I want to check that that string ends with "$W" . . .
>> I tried this (pseudo code):
>> *if the ((last char) & (last char -1)) of MNOSE = "$W"*
>> and it did not work.
> this does work:
> ...
> if MNOSE ends with "$W" then
> ...
> if char -2 to -1 of MNOSE = "$W" then
> ...
>
>> Richmond.
> Best
>
> Klaus
>
> --
> Klaus Major
> http://www.major-k.de
> [hidden email]
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: poking around near the end of a string

Richmond Mathewson via use-livecode
In reply to this post by Richmond Mathewson via use-livecode
if NMOSE ends with "$W" then

OR

if char -2 to -1 of MNOSE is "$W" then



On 5/10/2017 10:18 AM, Richmond via use-livecode wrote:

> Suppose I have a string a bit like this:
>
> "and then the gigantic monster bit my mother on the nose $W"
>
> and I want to check that that string ends with "$W" . . .
>
> I tried this (pseudo code):
>
> *if the ((last char) & (last char -1)) of MNOSE = "$W"*
>
> and it did not work.
>
>
> Richmond.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: poking around near the end of a string

Richmond Mathewson via use-livecode
In reply to this post by Richmond Mathewson via use-livecode
if char -2 to -1 of MNOSE = "$W" should work.

LAST doesn't return a numeric value (as far as I can tell) so you can't
subtract from it, if you do you get strange results

In addition, the order matters.  You're putting the last char first, and
the second to last char last (if you were allowed to use last that way)  So
if it did work, you'd be checking W$ against $W

You could do it other ways too of course.  You could use (char
length(MNOSE) -1 of MNOSE & char length(MNOSE) of mNose)  to do the
comparison..  Note the -1 is first to keep the characters in order.




On Wed, May 10, 2017 at 8:18 AM, Richmond via use-livecode <
[hidden email]> wrote:

> Suppose I have a string a bit like this:
>
> "and then the gigantic monster bit my mother on the nose $W"
>
> and I want to check that that string ends with "$W" . . .
>
> I tried this (pseudo code):
>
> *if the ((last char) & (last char -1)) of MNOSE = "$W"*
>
> and it did not work.
>
>
> Richmond.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: poking around near the end of a string

Richmond Mathewson via use-livecode
Ends with.. How did I not know about that?

On Wed, May 10, 2017 at 8:46 AM, Mike Bonner <[hidden email]> wrote:

> if char -2 to -1 of MNOSE = "$W" should work.
>
> LAST doesn't return a numeric value (as far as I can tell) so you can't
> subtract from it, if you do you get strange results
>
> In addition, the order matters.  You're putting the last char first, and
> the second to last char last (if you were allowed to use last that way)  So
> if it did work, you'd be checking W$ against $W
>
> You could do it other ways too of course.  You could use (char
> length(MNOSE) -1 of MNOSE & char length(MNOSE) of mNose)  to do the
> comparison..  Note the -1 is first to keep the characters in order.
>
>
>
>
> On Wed, May 10, 2017 at 8:18 AM, Richmond via use-livecode <
> [hidden email]> wrote:
>
>> Suppose I have a string a bit like this:
>>
>> "and then the gigantic monster bit my mother on the nose $W"
>>
>> and I want to check that that string ends with "$W" . . .
>>
>> I tried this (pseudo code):
>>
>> *if the ((last char) & (last char -1)) of MNOSE = "$W"*
>>
>> and it did not work.
>>
>>
>> Richmond.
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: poking around near the end of a string

Richmond Mathewson via use-livecode
And don’t forget ‘begins with’. They were both added in v. 2.9.

Devin


On May 10, 2017, at 8:47 AM, Mike Bonner via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Ends with.. How did I not know about that?

On Wed, May 10, 2017 at 8:46 AM, Mike Bonner <[hidden email]<mailto:[hidden email]>> wrote:

if char -2 to -1 of MNOSE = "$W" should work.

LAST doesn't return a numeric value (as far as I can tell) so you can't
subtract from it, if you do you get strange results

In addition, the order matters.  You're putting the last char first, and
the second to last char last (if you were allowed to use last that way)  So
if it did work, you'd be checking W$ against $W

You could do it other ways too of course.  You could use (char
length(MNOSE) -1 of MNOSE & char length(MNOSE) of mNose)  to do the
comparison..  Note the -1 is first to keep the characters in order.




On Wed, May 10, 2017 at 8:18 AM, Richmond via use-livecode <
[hidden email]<mailto:[hidden email]>> wrote:

Suppose I have a string a bit like this:

"and then the gigantic monster bit my mother on the nose $W"

and I want to check that that string ends with "$W" . . .

I tried this (pseudo code):

*if the ((last char) & (last char -1)) of MNOSE = "$W"*

and it did not work.


Richmond.

_______________________________________________
use-livecode mailing list
[hidden email]<mailto:[hidden email]>
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



_______________________________________________
use-livecode mailing list
[hidden email]<mailto:[hidden email]>
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Devin Asay
Director
Office of Digital Humanities
Brigham Young University

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: poking around near the end of a string

Richmond Mathewson via use-livecode
That was a great version. :-)

Bob S


> On May 10, 2017, at 08:07 , Devin Asay via use-livecode <[hidden email]> wrote:
>
> And don’t forget ‘begins with’. They were both added in v. 2.9.
>
> Devin

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Loading...