Sorting out letters from numbers in a field

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: Sorting out letters from numbers in a field

Post by richmond62 » Tue Apr 08, 2025 3:28 pm

Yes, unfortunately LiveCode does not have an isAlphabetic to strain out the %$#( type chars.
Last edited by richmond62 on Wed Apr 09, 2025 2:45 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: Sorting out letters from numbers in a field

Post by dunbarx » Tue Apr 08, 2025 3:49 pm

Richmond,

True, though if one does this all day, make a function and load it into a plugin.

Code: Select all

function isAlpha var
if var is in "abcdefghijklmnopqrstuvwxyz" then return "true" else return "false"
end isAlpha
Craig
Last edited by dunbarx on Tue Apr 08, 2025 4:02 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Sorting out letters from numbers in a field

Post by FourthWorld » Tue Apr 08, 2025 4:01 pm

dunbarx wrote:
Mon Apr 07, 2025 3:56 pm
The problem with the OP's original post is that he is trying to ascribe that function to an element of field text as if it was a property of that element of text. That dog don't hunt.
If I could go back in time and change any one decision made by the original HyperCard team it would be their bizarre choice to allow property syntax ("of") when calling single-param functions.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: Sorting out letters from numbers in a field

Post by dunbarx » Tue Apr 08, 2025 4:13 pm

Richard.

I would be happy to go with you.

I assume it was during the time of making HyperTalk as friendly as possible, and the more "conversational" option of using the word "of" seemed appropriate. Bill Atkinson believed that everybody would be making personalized rolodexes with cute black and white figurines. Dan Winkler all the while was plugging away at hyperTalk. Bill was astounded when a couple hundred thousand people started demanding detailed information about writing scripts and everything they could get their hands on about HT. Bill underestimated the public's appetite for writing code, that is, the appetite to make bigger things than a rolodex.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: Sorting out letters from numbers in a field

Post by richmond62 » Tue Apr 08, 2025 5:01 pm

make a function and load it into a plugin
You'd have a hell of a job writing a plugin that listed every alphabetic symbol listed by the Unicode consortium. 8)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: Sorting out letters from numbers in a field

Post by dunbarx » Tue Apr 08, 2025 6:45 pm

Richmond.

No, I don't do that sort of thing. But you might.

And so, looking at my plug-in, would it be so onerous to create a giant switch statement, with each language in a one-line case statement:

Code: Select all

function isAlpha var,language
switch language
  case "English"
    if var is in "abcdefghijklmnopqrstuvwxyz" then return "true" else return "false"
  break
  case "Bulgarian"
    if var is in ...
  break
  ...
end isAlpha
Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: Sorting out letters from numbers in a field

Post by richmond62 » Wed Apr 09, 2025 2:51 am

I wonder how you would differentiate between languages that used the same alphabet?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: Sorting out letters from numbers in a field

Post by dunbarx » Wed Apr 09, 2025 3:12 pm

Richmond.
I wonder how you would differentiate between languages that used the same alphabet?
Why would you have to? All that function does is validate a certain character set. The French use the same set we do, so ""French" would just be another case statement:

Code: Select all

function isAlpha var,language
switch language
  case "English"
  case "French"
    if var is in "abcdefghijklmnopqrstuvwxyz" then return "true" else return "false"
  break
  case "Bulgarian"
    if var is in ...
  break
  ...
end isAlpha
The Greeks have only 24 letters in their alphabet, so they need their own character set.

Craig

Post Reply