Match varialbes with case sensitivity.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Match varialbes with case sensitivity.
Hii Guys!!
I'm wondering how to match 2 variables with case sensitivity. For example, AlPhA123 will currently match Alpha123. How do I match these variables with Case Sensitivity?
Many Thanks,
Googie.
I'm wondering how to match 2 variables with case sensitivity. For example, AlPhA123 will currently match Alpha123. How do I match these variables with Case Sensitivity?
Many Thanks,
Googie.
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Match varialbes with case sensitivity.
From the docs:
Important: Messages, object names, and LiveCode terms are never treated as case-sensitive,
even if the caseSensitive is set to true.
That also applies to variables.
Add a number to your variables to avoid these doublettes!
Important: Messages, object names, and LiveCode terms are never treated as case-sensitive,
even if the caseSensitive is set to true.
That also applies to variables.
Add a number to your variables to avoid these doublettes!
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Match varialbes with case sensitivity.
Aye, well: and what happens if the OP CANNOT differentiate the variables in the way you suggest?That also applies to variables.
Add a number to your variables to avoid these doublettes!
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Match varialbes with case sensitivity.
Just stick your variables into 2 fields:
- -
Button 'SENSITIVE':
And, for once, Klaus, you'll see that fields DO have their uses. 
- -
Button 'SENSITIVE':
Code: Select all
on mouseUp
set the caseSensitive to true
if fld "f1" contains fld "f2" then
put "MATCH" into fld "f3"
else
put "NOPE" into fld "f3"
end if
end mouseUp

- Attachments
-
- Insensitivity.livecode.zip
- Stack.
- (1.12 KiB) Downloaded 393 times
Re: Match varialbes with case sensitivity.
Code: Select all
And, for once, Klaus, you'll see that fields DO have their uses. 8)

How is that in english? First come, first serve?Aye, well: and what happens if the OP CANNOT differentiate the variables in the way you suggest?
Means that LC will treat these as the SAME variable so it will get overwritten whenever the TS accesses them.
Re: Match varialbes with case sensitivity.
This:
will give you: 2 2 in the messagebox as exspected.
Code: Select all
on mouseUp
set the casesensitive to TRUE
put 1 into taaa
put 2 into tAAA
put taaa && tAAA
end mouseUp
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Match varialbes with case sensitivity.
The 'problem' as far as I can see is that the OP wants to compare 2 variables and differentiate them on the basis of whether , while being alphabetically the same, there is a CASE difference in those alphabetic characters.does not solve the problem!
By putting the 2 variables into 2 fields they CAN be compared in that way.
Re: Match varialbes with case sensitivity.
Yes, sure, but if that is the case (using two FIELDS to compare two variable names, which would make
the execution of a script a TAD longer than neccessary), then something is going completely wrong with the scripting!
And even that will make LC NOT differ between the variables in the scripts.
the execution of a script a TAD longer than neccessary), then something is going completely wrong with the scripting!

And even that will make LC NOT differ between the variables in the scripts.
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Match varialbes with case sensitivity.
OK: go for this:
- -
No fields were hurt during the making of this stack. 
- -
Code: Select all
on mouseUp
put empty into fld "f3"
put fld "f1" into EFF1
put EFF1 into EFF1x
put fld "f2" into EFF2
put EFF2 into EFF2x
repeat until EFF1x is empty
put codePointToNum(char 1 of EFF1x) after EFF1z
delete char 1 of EFF1x
end repeat
repeat until EFF2x is empty
put codePointToNum(char 1 of EFF2x) after EFF2z
delete char 1 of EFF2x
end repeat
if EFF1z = EFF2z then
put "MATCH" into fld "f3"
else
put "NOPE" into fld "f3"
end if
end mouseUp

- Attachments
-
- Two Birds.livecode.zip
- Stack.
- (1.14 KiB) Downloaded 398 times
Re: Match varialbes with case sensitivity.
However they were USED!No fields were hurt during the making of this stack.
Otherwise LC cannot differ between these two poorly chosen variable names!
So it seems there is no script-only way to do so.
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Match varialbes with case sensitivity.
Aesthetics were not my first thought; functionality was.two poorly chosen variable names!

And, I thought 'EFF1' and 'EFF2' were better than 'EFFon' and 'EFFoff'.

Code: Select all
no script-only way
Code: Select all
if EFF1z = EFF2z then
--- EFF1 and EFF2 match
end if
Re: Match varialbes with case sensitivity.
Re-form the variables into a string of their ASCII characters. Here is a long-winded demo script using a button and a field. Put this in the button script:
Craig
Code: Select all
on mouseUp
get "dog"
repeat for each char tChar in it
put charToNum(tChar) after temp
end repeat
put temp into fld 1
get "DoG"
repeat for each char tChar in it
put charToNum(tChar) after temp1
end repeat
put temp1 into line 2 of fld 1
end mouseUp
Last edited by dunbarx on Fri Jan 31, 2025 3:05 pm, edited 1 time in total.
Re: Match varialbes with case sensitivity.
I meant Googies variable names: AlPhA123 and Alpha123richmond62 wrote: ↑Fri Jan 31, 2025 2:40 pmAesthetics were not my first thought; functionality was.two poorly chosen variable names!![]()
...
Re: Match varialbes with case sensitivity.
Google85
How do you want to use this ability? My demo script can tell the difference between "dog" and "DoG", but then what?
Craig
How do you want to use this ability? My demo script can tell the difference between "dog" and "DoG", but then what?
Craig