Jump to content

Recommended Posts

Posted

Hi,

i have a drawing with too many text, these are of three types whole number, number with decimals, only alphabets and the next is alpha numerals.

 

I am looking for a lisp that select different types of text and sort them on different layers and to create the layers if layers don't exist.

 

ex..

100 (whole number) as number

55.444 (number with decimal) as decimal number

MY NAME (ALPHABETS) as name

room 201 (ALPHANUMERIC) as name-2

 

Thanks in advance

Posted

Start with looking at 1st character using substr 1 1 if its 0-9 then its a number

 

Take the number and do a FIX num this is the integer values then check the remainder num - fix if its 0 then its a whole number 55.444 = .444 decimal number.

 

Check if any numbers in the string, use something like lee-mac parse text this will pull the numbers out of text like "Room 201" = 201, so if true then layer name-2

Posted (edited)

Heres some helpful function:

; (StrType "123") -> INT
; (StrType "12.3") -> REAL
; (StrType "My age is") -> STR
; (StrType "I'm 12 years old") -> "ALPHANUMERIC"
; (StrType "192.168.l.0") -> "ALPHANUMERIC"
(defun StrType (str / strlst rtn)
 (if (and (eq 'STR (type str))
   (setq strlst (mapcar 'chr (vl-string->list str)))
     )
   (if
     (and
(wcmatch str "*[0-9]*")
(vl-every
  (function
    (lambda (x)
      (member x (mapcar 'chr (vl-string->list "1234567890.")))
    )
  )
  strlst
)
     )
      (progn
 (setq rtn 'INT)
 (if (vl-some (function (lambda (x) (= x "."))) strlst)
   (if (= 1
	  (length (vl-remove-if-not
		    (function (lambda (x) (= x ".")))
		    strlst
		  )
	  )
       )
     (setq rtn 'REAL)
     (setq rtn "ALPHANUMERIC")
   )
 )
      )
      (if (wcmatch str "*[0-9]*")
 (setq rtn "ALPHANUMERIC")
 (setq rtn 'STR)
      )
   )
 )
 rtn
); defun StrType

Maybe someone could figure out faster.

Edited by Grrr
Posted

Four functions to preselect these categories. You can then do anything you want (delete, change properties etc.).

Note: ".123" is not recognised as a number.

(defun c:SelTextInt ()
 (sssetfirst
   nil
   (ssget
     "_X"
     '(
       (0 . "MTEXT,TEXT")
       (1 . "*#*")
       (1 . "~*[~-0-9]*")
       (1 . "~?*-*")
     )
   )
 )
 (princ)
)

(defun c:SelTextReal ()
 (sssetfirst
   nil
   (ssget
     "_X"
     '(
       (0 . "MTEXT,TEXT")
       (1 . "*#`.*")
       (1 . "~*[~-.0-9]*")
       (1 . "~*`.*`.*")
       (1 . "~?*-*")
     )
   )
 )
 (princ)
)

(defun c:SelTextAlpha ()
 (sssetfirst
   nil
   (ssget
     "_X"
     '(
       (0 . "MTEXT,TEXT")
       (1 . "~*#*")
     )
   )
 )
 (princ)
)

(defun c:SelTextAlphaNum ()
 (sssetfirst
   nil
   (ssget
     "_X"
     '(
       (0 . "MTEXT,TEXT")
       (1 . "*#*")
       (-4 . "<OR")
         (1 . "*[~-.0-9]*")
         (1 . "`.*")
         (1 . "*`.*`.*")
         (1 . "?*-*")
       (-4 . "OR>")
     )
   )
 )
 (princ)
)

Posted

Nice guys, Grr one question can you change the code formatting spacing from say tabs = 8 spaces to say 2 spaces some code disappears of the screen to the right, compare with Roys.

 

Ps if tabs is only option throw it into Word replace ^t with 2 spaces or 3 4 etc

Posted
Nice guys, Grr one question can you change the code formatting spacing from say tabs = 8 spaces to say 2 spaces some code disappears of the screen to the right, compare with Roys.

 

Ps if tabs is only option throw it into Word replace ^t with 2 spaces or 3 4 etc

Thanks, modified the code.

P.S. I actually write it in NP++ and use 2 spaces, but when I open it with other editor I see like 8 spaces.

So in this case I pasted it into VLIDE, re-formated it there and re-saved it (seems an easy fix for that).

Posted

@Grrr:

I use NP++ as well and I think you are using tabs instead of spaces to indent your code. In your case NP++ just displays a tab as 2 spaces. Note that you can replace "\t" in NP++ itself.

I use:

Settings > Preferences > Tab settings > Tab size = 2 + [v] Replace by space

Posted
@Grrr:

I use NP++ as well and I think you are using tabs instead of spaces to indent your code. In your case NP++ just displays a tab as 2 spaces. Note that you can replace "\t" in NP++ itself.

I use:

Settings > Preferences > Tab settings > Tab size = 2 + [v] Replace by space

Thanks alot Roy, "Replace by space" was the problem!

I'll just post here to test if it works:

(defun ThisIsSyntaxTest nil
 (
   (
     (
       (
         (
         )
       )
     )
   )
   (
     (
     )
   )
 )
); defun

Now you guys won't be annoyed (including myself) from codes with huge spacing, posted by me. :D

Posted

You could expand this to unlimited testing :

 

[b][color=BLACK]([/color][/b]defun strt [b][color=FUCHSIA]([/color][/b]s / f i r n e l c z[b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]setq c 1[b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]= s [color=#2f4f4f]""[/color][b][color=NAVY])[/color][/b]
   [b][color=NAVY]([/color][/b]setq z T[b][color=NAVY])[/color][/b]
   [b][color=NAVY]([/color][/b]repeat [b][color=MAROON]([/color][/b]strlen s[b][color=MAROON])[/color][/b]
           [b][color=MAROON]([/color][/b]setq l [b][color=GREEN]([/color][/b]ascii [b][color=BLUE]([/color][/b]substr s c 1[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
           [b][color=MAROON]([/color][/b]cond [b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]and [b][color=RED]([/color][/b]not e[b][color=RED])[/color][/b]
                       [b][color=RED]([/color][/b]<= 48 l 57[b][color=RED])[/color][/b]
                       [b][color=RED]([/color][/b]not [b][color=PURPLE]([/color][/b]member l '[b][color=TEAL]([/color][/b]43 45 46[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                  [b][color=BLUE]([/color][/b]setq i T[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                 [b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]and i [b][color=RED]([/color][/b]not e[b][color=RED])[/color][/b]
                         [b][color=RED]([/color][/b]member l '[b][color=PURPLE]([/color][/b]46[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                  [b][color=BLUE]([/color][/b]setq r T[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                 [b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]and [b][color=RED]([/color][/b]not e[b][color=RED])[/color][/b]
                       [b][color=RED]([/color][/b]member l '[b][color=PURPLE]([/color][/b]43 45[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                  [b][color=BLUE]([/color][/b]setq n T[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                 [b][color=GREEN]([/color][/b]T
                  [b][color=BLUE]([/color][/b]setq i nil r nil n nil e T[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
           [b][color=MAROON]([/color][/b]setq c [b][color=GREEN]([/color][/b]1+ c[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[b][color=FUCHSIA]([/color][/b]setq f [b][color=NAVY]([/color][/b]cond [b][color=MAROON]([/color][/b]e            [color=#2f4f4f]"Mixed String"[/color][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and z[b][color=GREEN])[/color][/b]      [color=#2f4f4f]"Empty String"[/color][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and i r n[b][color=GREEN])[/color][/b]  [color=#2f4f4f]"Signed Real Number"[/color][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and i n[b][color=GREEN])[/color][/b]    [color=#2f4f4f]"Signed Integer"[/color][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and i r[b][color=GREEN])[/color][/b]    [color=#2f4f4f]"Real Number"[/color][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and i[b][color=GREEN])[/color][/b]      [color=#2f4f4f]"Integer"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]


[b][color=BLACK]([/color][/b]defun c:str-type [b][color=FUCHSIA]([/color][/b]/ tl[b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]setq tl '[b][color=NAVY]([/color][/b][color=#2f4f4f]""[/color] [color=#2f4f4f]","[/color] [color=#2f4f4f]"453"[/color] [color=#2f4f4f]"."[/color] [color=#2f4f4f]" "[/color] [color=#2f4f4f]"-12.125"[/color] [color=#2f4f4f]"+120"[/color] [color=#2f4f4f]"453.21"[/color] [color=#2f4f4f]"My Name"[/color] [color=#2f4f4f]"Room 201"[/color] [b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]foreach s tl
    [b][color=NAVY]([/color][/b]alert [b][color=MAROON]([/color][/b]strcat s [color=#2f4f4f]" = "[/color] [b][color=GREEN]([/color][/b]strt s[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

 

-David

Posted
; (StringType "123")   => "##"
; (StringType "-123")  => "##"
; (StringType "12.3")  => "#."
; (StringType "-12.3") => "#."
; (StringType "1AB")   => "@#"
; (StringType "ABC")   => "@@"

; (StringType "1-23")  => "@#"
; (StringType ".123")  => "@#"
; (StringType "1.2.3") => "@#"
; (StringType "-")     => "@@"
; (StringType ".")     => "@@"
(defun StringType (str)
 (if (not (wcmatch str "*[~-.0-9]*,`.*,*`.*`.*,-,?*-*"))
   (if (wcmatch str "*`.*")
     "#." ; Real.
     "##" ; Integer.
   )
   (if (wcmatch str "*#*")
     "@#" ; Alpha-numerical.
     "@@" ; Non-numerical.
   )
 )
)

Posted

Good job David and Roy,

I wrote another version with (vl-some):


[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"123"[/color][b][color=BLACK])[/color][/b]  -> [color=#2f4f4f]"INT"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"12.3"[/color][b][color=BLACK])[/color][/b] -> [color=#2f4f4f]"REAL"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"My age is"[/color][b][color=BLACK])[/color][/b] -> [color=#2f4f4f]"AlphaSTR"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"I'm 12 years old"[/color][b][color=BLACK])[/color][/b] -> [color=#2f4f4f]"AlphaINT"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"192.168.1.0"[/color][b][color=BLACK])[/color][/b]  -> [color=#2f4f4f]"NumericalSTR"[/color][/color]

[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"-123"[/color][b][color=BLACK])[/color][/b] -> [color=#2f4f4f]"AlphaINT"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"-12.3"[/color][b][color=BLACK])[/color][/b] -> [color=#2f4f4f]"AlphaREAL"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"1AB"[/color][b][color=BLACK])[/color][/b]  -> [color=#2f4f4f]"AlphaINT"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"ABC"[/color][b][color=BLACK])[/color][/b] -> [color=#2f4f4f]"AlphaSTR"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"1-23"[/color][b][color=BLACK])[/color][/b] -> [color=#2f4f4f]"AlphaINT"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]".123"[/color][b][color=BLACK])[/color][/b] -> [color=#2f4f4f]"REAL"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"1.2.3"[/color][b][color=BLACK])[/color][/b] -> [color=#2f4f4f]"NumericalSTR"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"-"[/color][b][color=BLACK])[/color][/b]    -> [color=#2f4f4f]"AlphaSTR"[/color][/color]
[color=#8b4513]; [b][color=BLACK]([/color][/b]StrType [color=#2f4f4f]"."[/color][b][color=BLACK])[/color][/b]  -> [color=#2f4f4f]"AlphaSTR"[/color][/color]
[b][color=BLACK]([/color][/b]defun StrType [b][color=FUCHSIA]([/color][/b] str / rtn [b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]
   [b][color=NAVY]([/color][/b]lambda [b][color=MAROON]([/color][/b] lst / dots Strchr Numchr [b][color=MAROON])[/color][/b]
     [b][color=MAROON]([/color][/b]setq 
       dots [b][color=GREEN]([/color][/b]apply '- [b][color=BLUE]([/color][/b]mapcar 'length [b][color=RED]([/color][/b]list lst [b][color=PURPLE]([/color][/b]setq lst [b][color=TEAL]([/color][/b]vl-remove [color=#2f4f4f]"."[/color] lst[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [color=#8b4513]; get the [color=#2f4f4f]"."[/color] count[/color]
       Strchr [b][color=GREEN]([/color][/b]vl-some [b][color=BLUE]([/color][/b]function [b][color=RED]([/color][/b]lambda [b][color=PURPLE]([/color][/b]x[b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]wcmatch x [color=#2f4f4f]"[~0-9]"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] lst[b][color=GREEN])[/color][/b] [color=#8b4513]; theres non-numerical character[/color]
       Numchr [b][color=GREEN]([/color][/b]vl-some [b][color=BLUE]([/color][/b]function [b][color=RED]([/color][/b]lambda [b][color=PURPLE]([/color][/b]x[b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]wcmatch x [color=#2f4f4f]"[0-9]"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] lst[b][color=GREEN])[/color][/b] [color=#8b4513]; theres numerical character[/color]
     [b][color=MAROON])[/color][/b][color=#8b4513]; setq[/color]
     [b][color=MAROON]([/color][/b]cond
       [b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]and Strchr Numchr[b][color=BLUE])[/color][/b]
         [b][color=BLUE]([/color][/b]vl-some 
           [b][color=RED]([/color][/b]function [b][color=PURPLE]([/color][/b]lambda [b][color=TEAL]([/color][/b]a b[b][color=TEAL])[/color][/b] [b][color=TEAL]([/color][/b]and [b][color=OLIVE]([/color][/b]a 1 dots[b][color=OLIVE])[/color][/b] [b][color=OLIVE]([/color][/b]setq rtn b[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] 
           [b][color=RED]([/color][/b]list = < >[b][color=RED])[/color][/b] '[b][color=RED]([/color][/b][color=#2f4f4f]"AlphaREAL"[/color] [color=#2f4f4f]"AlphaSTR"[/color] [color=#2f4f4f]"AlphaINT"[/color][b][color=RED])[/color][/b] 
         [b][color=BLUE])[/color][/b]
       [b][color=GREEN])[/color][/b]
       [b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]and [b][color=RED]([/color][/b]not Strchr[b][color=RED])[/color][/b] Numchr[b][color=BLUE])[/color][/b]
         [b][color=BLUE]([/color][/b]vl-some 
           [b][color=RED]([/color][/b]function [b][color=PURPLE]([/color][/b]lambda [b][color=TEAL]([/color][/b]a b[b][color=TEAL])[/color][/b] [b][color=TEAL]([/color][/b]and [b][color=OLIVE]([/color][/b]a 1 dots[b][color=OLIVE])[/color][/b] [b][color=OLIVE]([/color][/b]setq rtn b[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] 
           [b][color=RED]([/color][/b]list = < >[b][color=RED])[/color][/b] '[b][color=RED]([/color][/b][color=#2f4f4f]"REAL"[/color] [color=#2f4f4f]"NumericalSTR"[/color] [color=#2f4f4f]"INT"[/color][b][color=RED])[/color][/b] 
         [b][color=BLUE])[/color][/b]
       [b][color=GREEN])[/color][/b]
       [b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]or [b][color=RED]([/color][/b]and Strchr [b][color=PURPLE]([/color][/b]not Numchr[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]and [b][color=PURPLE]([/color][/b]not [b][color=TEAL]([/color][/b]and Strchr Numchr[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]= 1 dots[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
         [b][color=BLUE]([/color][/b]setq rtn [color=#2f4f4f]"AlphaSTR"[/color][b][color=BLUE])[/color][/b]
       [b][color=GREEN])[/color][/b]
     [b][color=MAROON])[/color][/b][color=#8b4513]; cond[/color]
   [b][color=NAVY])[/color][/b][color=#8b4513]; lambda[/color]
   [b][color=NAVY]([/color][/b]mapcar 'chr [b][color=MAROON]([/color][/b]vl-string->list str[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
 [b][color=FUCHSIA])[/color][/b]
 rtn
[b][color=BLACK])[/color][/b][color=#8b4513]; defun StrType[/color]

 

Although it should be faster than my previous posted, I think Roy's version will be the fastest from all (because of the obviously low count of evaluations in his code).

Roy - the wcmatch king 8)

Posted

Thanks all for all your efforts,

I tried all the above codes but most of the time it like "unknown command"

 

Only david's code shows some autocad messeges. but doesn't select the texts and shifts to the required layers.

 

may be I am missing some thing to do with the code before apploading it or using it.

 

pls help me I am new to coding...

 

Thanks a lot for your postings.

Posted
Thanks all for all your efforts,

I tried all the above codes but most of the time it like "unknown command"

 

Only david's code shows some autocad messeges. but doesn't select the texts and shifts to the required layers.

 

may be I am missing some thing to do with the code before apploading it or using it.

 

pls help me I am new to coding...

 

Thanks a lot for your postings.

 

Example:

(defun C:test ( / Lst SSX i enx lyrnm )
 (and
   (setq Lst
     '(
       ("##" . "Whole Number")
       ("#." . "Decimal Number")
       ("@#" . "AlphaNumeric")
       ("@@" . "Alphabets")
     )
   )
   (setq SSX (ssget "_X" (list (cons 0 "TEXT"))))
   (repeat (setq i (sslength SSX))
     (entmakex
       (list 
         (cons 0 "LAYER")
         (cons 100 "AcDbSymbolTableRecord")
         (cons 100 "AcDbLayerTableRecord")
         (cons 2 (setq lyrnm (cdr (assoc (StringType (cdr (assoc 1 (setq enx (entget (ssname SSX (setq i (1- i)))))))) Lst))))
         (cons 70 0)
       )
     )
     (entmod (subst (cons 8 lyrnm) (assoc 8 enx) enx))
   )
 )
 (princ)
)

(defun StringType (str)
 (if (not (wcmatch str "*[~-.0-9]*,`.*,*`.*`.*,-,?*-*"))
   (if (wcmatch str "*`.*")
     "#." ; Real.
     "##" ; Integer.
   )
   (if (wcmatch str "*#*")
     "@#" ; Alpha-numerical.
     "@@" ; Non-numerical.
   )
 )
)

Posted
Example:

(defun C:test ( / Lst SSX i enx lyrnm )
 (and
   (setq Lst
     '(
       ("##" . "Whole Number")
       ("#." . "Decimal Number")
       ("@#" . "AlphaNumeric")
       ("@@" . "Alphabets")
     )
   )
   (setq SSX (ssget "_X" (list (cons 0 "TEXT"))))
   (repeat (setq i (sslength SSX))
     (entmakex
       (list 
         (cons 0 "LAYER")
         (cons 100 "AcDbSymbolTableRecord")
         (cons 100 "AcDbLayerTableRecord")
         (cons 2 (setq lyrnm (cdr (assoc (StringType (cdr (assoc 1 (setq enx (entget (ssname SSX (setq i (1- i)))))))) Lst))))
         (cons 70 0)
       )
     )
     (entmod (subst (cons 8 lyrnm) (assoc 8 enx) enx))
   )
 )
 (princ)
)

(defun StringType (str)
 (if (not (wcmatch str "*[~-.0-9]*,`.*,*`.*`.*,-,?*-*"))
   (if (wcmatch str "*`.*")
     "#." ; Real.
     "##" ; Integer.
   )
   (if (wcmatch str "*#*")
     "@#" ; Alpha-numerical.
     "@@" ; Non-numerical.
   )
 )
)

 

Thanks it works fine for my requirement.

 

All sincere thanks to everyone who spent their time for helping me...

  • 2 years later...
Posted

Hi to all,

 

How can I use this StringType function to alert if the last character of CTAB is a letter or a number?

 

Thank you.

Posted (edited)

Try this :

 

(defun ctab_last ( str / s_lst)
  (setq s_lst (reverse (vl-string->list str))
        rtn (if (< 47 (car s_lst) 58) "#" "@")
  )
)  

usage  (setq result (ctab_last (getvar 'ctab)))

 

last is a number result = "#"

otherwise result =  "@"

 

Edited by dlanorh
Posted
14 hours ago, GLORY said:

How can I use this StringType function to alert if the last character of CTAB is a letter or a number?

 

In this case, it would be much easier to simply use wcmatch, e.g.:

(wcmatch (getvar 'ctab) "*#")

The above will return T if the last character is a digit, else nil for anything else.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...