Author Topic: Alphabet character string only  (Read 4220 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1802
  • BricsCAD 18
Re: Alphabet character string only
« Reply #15 on: April 09, 2018, 04:58:47 PM »
@John:
You probably mean:
Code - Auto/Visual Lisp: [Select]
  1. (defun alpha-p (s) (wcmatch s "~*[~A-Za-z ]*"))

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Alphabet character string only
« Reply #16 on: April 09, 2018, 05:13:28 PM »
Why stop there, you might as well pen goofy flavours of listp, minusp, numberp etc. while you’re at it.
What (I'm confused)? ...No. But I don't see how the addition of spaces was all that big of a deal--as far as requests go--or that far out of possibilities -i.e. a user wanting to quickly check the string is of only alpha and spaces with a high level language (a language which doesn't treats strings as arrays).  I'm confused (that elevated quickly).

@John:
You probably mean:
Code - Auto/Visual Lisp: [Select]
  1. (defun alpha-p (s) (wcmatch s "~*[~A-Za-z ]*"))
Sure. That'll work.

EDIT: added a few words for clarity.
« Last Edit: April 09, 2018, 05:43:01 PM by John Kaul (Se7en) »
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17662
  • Have thousands of dwgs to process? Contact me.
Re: Alphabet character string only
« Reply #17 on: April 09, 2018, 05:58:54 PM »
An isalpha predicate function that allows non alpha characters is illogical.
Engineering Technologist • CAD Specialist • Programmer Analyst
Design • Drafting • Document Control • Automation.
cadanalyst@fastmail.com • https://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Alphabet character string only
« Reply #18 on: April 09, 2018, 06:05:33 PM »
Wait, what!? Ha! If that's all, then much of the autolisp (and all programming lanuage) community is in trouble. I've seen whole solutions developed with functions named after vowels. I've seen countless functions names "foo" and "bar". ...change the name.
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

VovKa

  • Swamp Rat
  • Posts: 1243
  • Ukraine
Re: Alphabet character string only
« Reply #19 on: April 09, 2018, 07:14:42 PM »
An isalpha predicate function that allows non alpha characters is illogical.
yep, and it returns nil for the Alpha itself :)
(alpha-p "α")

MP

  • Seagull
  • Posts: 17662
  • Have thousands of dwgs to process? Contact me.
Re: Alphabet character string only
« Reply #20 on: April 09, 2018, 09:16:46 PM »
returns nil for the Alpha itself :)
(alpha-p "α")

 :uglystupid2: appropriate
Engineering Technologist • CAD Specialist • Programmer Analyst
Design • Drafting • Document Control • Automation.
cadanalyst@fastmail.com • https://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

XXL66

  • Newt
  • Posts: 99
Re: Alphabet character string only
« Reply #21 on: April 10, 2018, 05:40:04 AM »
@John:
You probably mean:
Code - Auto/Visual Lisp: [Select]
  1. (defun alpha-p (s) (wcmatch s "~*[~A-Za-z ]*"))

Was that yours Roy? Very neat work!

roy_043

  • Water Moccasin
  • Posts: 1802
  • BricsCAD 18
Re: Alphabet character string only
« Reply #22 on: April 10, 2018, 06:50:19 AM »
@John:
You probably mean:
Code - Auto/Visual Lisp: [Select]
  1. (defun alpha-p (s) (wcmatch s "~*[~A-Za-z ]*"))

Was that yours Roy? Very neat work!
I just added a space to Lee's suggestion in response to John's attempt (which does not work properly).

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1076
  • Marco
Re: Alphabet character string only
« Reply #23 on: April 10, 2018, 07:44:47 AM »
An isalpha predicate function that allows non alpha characters is illogical.
yep, and it returns nil for the Alpha itself :)
(alpha-p "α")
Excuse my ignorance, why?
Comando: (ascii "α") 92
Comando: (chr 92)   "\\"
Comando: (ascii "\\") 92

scottcd

  • Newt
  • Posts: 52
Re: Alphabet character string only
« Reply #24 on: April 10, 2018, 08:24:42 AM »
(ascii "a") returns 97 in both Autocad 2018 and BricsCAD 18.2
AutoCAD Dos R9 - 2018 and BricCAD 18.2

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Alphabet character string only
« Reply #25 on: April 10, 2018, 08:25:21 AM »
@John:
You probably mean:
Code - Auto/Visual Lisp: [Select]
  1. (defun alpha-p (s) (wcmatch s "~*[~A-Za-z ]*"))

Was that yours Roy? Very neat work!
I just added a space to Lee's suggestion in response to John's attempt (which does not work properly).

Hey!? what do you mean my addition doesn't work properly. Does so. Does so! Well, at least it should (but I guess it depends on the regex guts autodesk used but it should). I only had AutoCAD 2016 installed (and before the other day, I didn't even know I had AutoCAD installed on this machine).
Code: [Select]
Command: (defun a (s) (wcmatch s "~*[~A-Za-z ]*"))
A

Command: (a "test")
T

Command: (a "a")
T

Command: (a ".")
nil

Command: (defun b (s) (wcmatch s "~*[~A-Za-z],[ ]*"))
B

Command: (b "test")
T

Command: (b "a")
T

Command: (b ".")
nil



Excuse my ignorance, why?
Comando: (ascii "α") 92
Comando: (chr 92)   "\\"
Comando: (ascii "\\") 92

That's odd. If I'm not mistaken, Portuguese is your natural language and Portuguese uses cp850 or cp860 but only the extended char set in those differs from the std char set.
https://www.ascii-codes.com/cp860.html
Weird! If you figure that one out, let me know (you have peeked my interest).
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: Alphabet character string only
« Reply #26 on: April 10, 2018, 08:28:06 AM »
Code - Auto/Visual Lisp: [Select]
  1. _$ (a "1a")
  2. nil
  3. _$ (b "1a")
  4. T

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Alphabet character string only
« Reply #27 on: April 10, 2018, 08:38:14 AM »
Code - Auto/Visual Lisp: [Select]
  1. _$ (a "1a")
  2. nil
  3. _$ (b "1a")
  4. T

Ah! Got it. Thanks, Lee Mack. I apologize, roy_043. I removed your name from my list.
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1076
  • Marco
Re: Alphabet character string only
« Reply #28 on: April 10, 2018, 08:56:54 AM »
Excuse my ignorance, why?
Comando: (ascii "α") 92
Comando: (chr 92)   "\\"
Comando: (ascii "\\") 92

That's odd. If I'm not mistaken, Portuguese is your natural language and Portuguese uses cp850 or cp860 but only the extended char set in those differs from the std char set.
https://www.ascii-codes.com/cp860.html
Weird! If you figure that one out, let me know (you have peeked my interest).
I have: Code page 850 (Latin-1 - Western European languages)
Comando: SYSCODEPAGE    = "ANSI_1252" (solo lettura)
Comando: DWGCODEPAGE  = "ANSI_1252" (solo lettura)