cAPITAL lETTER pROBLEM

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

cAPITAL lETTER pROBLEM

Post by richmond62 » Wed Jul 18, 2018 10:24 am

So; there I am, feeling all over-confident tarting up the latest swanky version of my Devawriter Pro
when I came across a mAJOR pROBLEM tHAT i hAD cOMPLETELY mISSED bEFORE.

That really devolves on LiveCode. :evil:

If I have two images-as-buttons called "a" and "A' respectively and from somewhere else I
send mouseUp to image "a"
and
send mouseUp to image "A"
the SEND in both of those code snippets will "hit" only 1 of the 2 images.

This is because LiveCode is, seemingly, incapable of differentiating between lower and upper case Latin characters.
-
cRapitals.png
-
Capital crime.livecode.zip
Here's the stack.
(3.35 KiB) Downloaded 150 times

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: cAPITAL lETTER pROBLEM

Post by Klaus » Wed Jul 18, 2018 10:46 am

Image

Congrats, mate! :D

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 818
Joined: Fri Feb 06, 2015 4:03 pm

Re: cAPITAL lETTER pROBLEM

Post by LiveCode_Panos » Wed Jul 18, 2018 11:49 am

Hi all,

You could probably use the image ID instead of the image name in the send command.

In general, LC does differentiate between lowercase and uppercase letters but only when it comes to comparisons ("contains", "is among", "replace", "filter" etc)

See "caseSensitive" property in the dictionary.

However, messages, object names, and LiveCode terms are never treated as case-sensitive, even if the caseSensitive is set to true.

Hope this helps.
Panos
--

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: cAPITAL lETTER pROBLEM

Post by richmond62 » Wed Jul 18, 2018 2:28 pm

Hope this helps.
Like most things: in some ways it does, and in others it doesn't. :D

As a naive realist (fancy, philosophical way of saying I believe what I see),
I find it convenient to give names to objects that make some sort of sense (to me at least),
and as I spend most of my programming life surrounded by objects with names such as "a", "A",
"z" and "Z" that 'problem' is a bit of a pain in the bum: renaming things like this: "xa", "A",
"xz" and "Z" is both tedious and a bit counter-intuitive.

On the teaching front, especially as I teach kids who, on a day to day basis, use
a non-Latin alphabet, explaining to them that LiveCode
is unable to differentiate between images called "abc" and "ABC",
but CAN differentiate between images called "щюя" and "ЩЮЯ" is a bit of a headache.

Oh, and, Klaus:
saddlesore-sized.jpg

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: cAPITAL lETTER pROBLEM

Post by bogs » Wed Jul 18, 2018 2:52 pm

Just curious as I don't use simple naming, my controls and variables I usually name like I did in Delphi, cmdName(button), txtName(fields), grpName(groups), etc. (it helps fix an issue Jacque made me aware of with variables winding up tExt, as well as nigh guaranteeing I never use a reserved word :wink: )

Couldn't you in this kind of situation just use a simple if or case statement in the handler such as (psuedo code)

Code: Select all

put word 2 of the name of the target into tmpUpLow
if tmpUpLow is "a" then
	send mouseUp to image "a"
else 
	send mouseUp to image "A"
  // Of course, if you have more than 2 possibilities, go with select/case accordingly... 
end if
The ID as panos suggests would be the most accurate way, but if you already had your code setup it seems like to me you should just be able to wrap it in a case/select or if/then relatively quickly.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: cAPITAL lETTER pROBLEM

Post by richmond62 » Wed Jul 18, 2018 3:32 pm

In theory, bogs, yes . . .

BUT, while in my example stack SEND favours the image called "a"
in my Devawriter Pro SEND favours the image called "A" . . .

so hard to predict which one should be the default.

I suspect (?) that when the system has a choice between "a" and "A" it will
choose the object with the lower ID first.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: cAPITAL lETTER pROBLEM

Post by bogs » Wed Jul 18, 2018 4:18 pm

In the code I gave as an example, what the system likes or doesn't shouldn't matter. In the example, your taking the name of the target, from your example, image "a" or image "A", getting the 2nd word of the name (which will either be a or A), and determining where to send the message based on that, which should be the correct image.

Or it is possible I just don't understand the problem correctly, I did only get halfway through my first cup of coffee so far Image
Image

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: cAPITAL lETTER pROBLEM

Post by Klaus » Wed Jul 18, 2018 4:22 pm

richmond62 wrote:
Wed Jul 18, 2018 2:28 pm
Oh, and, Klaus:
saddlesore-sized.jpg
Again, I don't get this surely funny meme!? :shock:

But don't forget our "kinky relationship": "I educate (and make fun of you sometimes)
you, and you annoy me." And we are both very good at that! :D
http://forums.livecode.com/viewtopic.ph ... 01#p167189

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: cAPITAL lETTER pROBLEM

Post by dunbarx » Wed Jul 18, 2018 5:12 pm

Bogs.

LC cannot do what you imply in your handler. You cannot even determine the case of, say, the first char of the name of a control, since the caseSensitive property does not hold in that arena.

You must find another reference to work with. Richmond needs to rename his images.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: cAPITAL lETTER pROBLEM

Post by richmond62 » Wed Jul 18, 2018 5:24 pm

Again, I don't get this surely funny meme!?
Just put it down to cultural differences. 8)
I educate (and make fun of you sometimes)
you, and you annoy me.
That sounds a bit arrogant.

Has it occurred to you that you might annoy me as well? 8)
Last edited by richmond62 on Wed Jul 18, 2018 5:27 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: cAPITAL lETTER pROBLEM

Post by richmond62 » Wed Jul 18, 2018 5:25 pm

Richmond needs to rename his images.
Indeed, and I did, and a right "bother" that was. 8)

Why do I think it would be "rather nice" if this 'bug' were fixed?

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: cAPITAL lETTER pROBLEM

Post by Klaus » Wed Jul 18, 2018 5:33 pm

richmond62 wrote:
Wed Jul 18, 2018 5:24 pm
Again, I don't get this surely funny meme!?
Just put it down to cultural differences. 8)
OK, it has to do with riding a bycycle, right?
richmond62 wrote:
Wed Jul 18, 2018 5:24 pm
I educate (and make fun of you sometimes)
you, and you annoy me.
That sounds a bit arrogant.
Your words (except the ones inside of the brackets), check the link!
richmond62 wrote:
Wed Jul 18, 2018 5:24 pm
Has it occurred to you that you might annoy me as well? 8)
You BET, and in my opinion this is just fair! :-D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: cAPITAL lETTER pROBLEM

Post by jacque » Wed Jul 18, 2018 6:28 pm

richmond62 wrote: Why do I think it would be "rather nice" if this 'bug' were fixed?
It isn't a bug. Case insensitivity has been normal for xtalk since HyperCard. In fact, LC improved on it by adding a way to distinguish it more easily during comparisons.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: cAPITAL lETTER pROBLEM

Post by dunbarx » Wed Jul 18, 2018 7:03 pm

So much thinking and struggling just does not come up because of the case insensitivity of LC.

Certainly, as Richmond discovered, it may have its downside in certain situations, but that pales in comparison, and is easily circumvented. Sensible, robust naming is LC 101.

I recall a thread years ago that asked for a global property to make, er, the case for this to be optional in all aspects of the engine. I wonder how much stuff would break if this was misused, and whether the engine could even handle such a thing at this late date.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: cAPITAL lETTER pROBLEM

Post by richmond62 » Wed Jul 18, 2018 7:18 pm

Sensible, robust naming is LC 101.
And here endeth the lesson. :D

But, he who always wants to have the last word points out:
On the teaching front, especially as I teach kids who, on a day to day basis, use
a non-Latin alphabet, explaining to them that LiveCode
is unable to differentiate between images called "abc" and "ABC",
but CAN differentiate between images called "щюя" and "ЩЮЯ" is a bit of a headache.
8)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”