Page 1 of 2
Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 5:13 am
by Googie85
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.
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 8:05 am
by richmond62
Use caseSensitive.
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 9:57 am
by Klaus
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!
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 10:17 am
by richmond62
That also applies to variables.
Add a number to your variables to avoid these doublettes!
Aye, well: and what happens if the OP CANNOT differentiate the variables in the way you suggest?
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 10:31 am
by richmond62
Just stick your variables into 2 fields:
-
-
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
And, for once,
Klaus, you'll see that fields DO have their uses.

Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 11:05 am
by Klaus
Code: Select all
And, for once, Klaus, you'll see that fields DO have their uses. 8)
Yes, but this completely OFF-topic here and does not solve the problem!
Aye, well: and what happens if the OP CANNOT differentiate the variables in the way you suggest?
How is that in english? First come, first serve?
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.
Posted: Fri Jan 31, 2025 11:06 am
by Klaus
This:
Code: Select all
on mouseUp
set the casesensitive to TRUE
put 1 into taaa
put 2 into tAAA
put taaa && tAAA
end mouseUp
will give you:
2 2 in the messagebox as exspected.
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 11:09 am
by richmond62
does not solve the problem!
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.
By putting the 2 variables into 2 fields they CAN be compared in that way.
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 11:32 am
by Klaus
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.
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 2:20 pm
by richmond62
OK: go for this:
-
-
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
No fields were hurt during the making of this stack.

Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 2:25 pm
by Klaus
No fields were hurt during the making of this stack.
However they were USED!
Otherwise LC cannot differ between these two poorly chosen variable names!
So it seems there is no script-only way to do so.
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 2:40 pm
by richmond62
two poorly chosen variable names!
Aesthetics were not my first thought; functionality was.
And, I thought 'EFF1' and 'EFF2' were better than 'EFFon' and 'EFFoff'.
Err: that's what I just did:
Code: Select all
if EFF1z = EFF2z then
--- EFF1 and EFF2 match
end if
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 2:59 pm
by dunbarx
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:
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
Craig
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 3:03 pm
by Klaus
richmond62 wrote: ↑Fri Jan 31, 2025 2:40 pm
two poorly chosen variable names!
Aesthetics were not my first thought; functionality was.
...
I meant Googies variable names: AlPhA123 and Alpha123
Re: Match varialbes with case sensitivity.
Posted: Fri Jan 31, 2025 3:07 pm
by dunbarx
Google85
How do you want to use this ability? My demo script can tell the difference between "dog" and "DoG", but then what?
Craig