See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Another way to check alpha vs. numeric?

  1. #1
    I could stop if I wanted to
    Join Date
    2005-02
    Location
    Tasmania
    Posts
    278
    Login to Give a bone
    0

    Default Another way to check alpha vs. numeric?

    Hi all,

    I've been using the code below to check the last character of our drawing revision attribute so I can determine where to put the PDF file once it has been created (we want only "As-Built" drawings available for general usage).

    We use an alpha-numeric revision numbering system where 0, 1, 2, etc are As-Builts and 0A, 1A, 1B, etc. are interim revisions. I have just discovered today though that this code works for all revisions except revision 0 (the first As-Built revision).

    Code:
    (setq revlen (strlen revval))
    (setq revlast (substr revval revlen))
        (if (= 0 (atoi revlast))
            (command "script" "N:/plot/Pspace-Interim.scr")
            (command "script" "N:/plot/Pspace-As-Built.scr")
        )
    revval = the actual revision (e.g. 0, 0A, 1A, etc.)
    revlast = the last character of the revision value stripped out

    Of course you will see that this works fine for any drawing with a revision other than '0', for this revision it will determine (incorrectly) that it is an interim revision.

    Does anybody have another way of checking this value (revlast) to see if it is an numeric or an alpha character?

    TIA,...Jon.

  2. #2
    100 Club CADmium's Avatar
    Join Date
    2004-08
    Location
    Eberswalde, Germany, Europe
    Posts
    128
    Login to Give a bone
    1

    Default Re: Another way to check alpha vs. numeric?

    uses the function distof .. it will return nil, if the argument can not change to a numeric

  3. #3
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    277
    Login to Give a bone
    0

    Default Re: Another way to check alpha vs. numeric?

    Hi jguest,
    How about this
    Code:
    (setq revval '("0" "0A" "1A"))
    (foreach x revval
      (setq revlast (substr x 1 1))
      (if
        (= "0" revlast)
        (command "script" "N:/plot/Pspace-Interim.scr")
        (command "script" "N:/plot/Pspace-As-Built.scr")
        )                                                                       ; if
    )                                                                           ; foreach
    Last edited by Adesu; 2006-04-24 at 08:11 AM.

  4. #4
    I could stop if I wanted to
    Join Date
    2005-02
    Location
    Tasmania
    Posts
    278
    Login to Give a bone
    0

    Default Re: Another way to check alpha vs. numeric?

    Quote Originally Posted by thomas.krueger
    uses the function distof .. it will return nil, if the argument can not change to a numeric
    Thanks Thomas,

    That seems to work quite well. That section of code now reads as follows:

    Code:
    (setq revlen (strlen revval))
    (setq revlast (substr revval revlen))
        (if (= nil (distof revlast))
            (command "script" "N:/plot/Pspace-Interim.scr")
            (command "script" "N:/plot/Pspace-As-Built.scr")
        )

  5. #5
    I could stop if I wanted to
    Join Date
    2005-02
    Location
    Tasmania
    Posts
    278
    Login to Give a bone
    0

    Default Re: Another way to check alpha vs. numeric?

    Quote Originally Posted by Adesu
    Hi jguest,
    How about this
    Code:
    (setq revval '("0" "0A" "1A"))
    (foreach x revval
      (setq revlast (substr x 1 1))
      (if
        (= "0" revlast)
        (command "script" "N:/plot/Pspace-Interim.scr")
        (command "script" "N:/plot/Pspace-As-Built.scr")
        )                                                                       ; if
    )                                                                           ; foreach
    I'm not quite sure what you're suggesting here Adesu, as the revision values exist in a single instance per drawing - i.e. the drawing will be revision 0, or revision 0A, or revision 1A. I'm only dealing with one at a time, not all of them at once.

    Also, your code extracts the first character of the revision value, not the last character which is the one that determines whether it is an As-Built or an Interim drawing. I may not have been too clear about that point though.

    Thanks for going to the trouble of helping out anyway, it's appreciated.

  6. #6
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    1

    Default Re: Another way to check alpha vs. numeric?

    Try this:
    Code:
        (if (and (= 0 (atoi revlast))(numberp (read revlast)))
            (command "script" "N:/plot/Pspace-Interim.scr")
            (command "script" "N:/plot/Pspace-As-Built.scr")
        )

  7. #7
    I could stop if I wanted to
    Join Date
    2005-02
    Location
    Tasmania
    Posts
    278
    Login to Give a bone
    0

    Default Re: Another way to check alpha vs. numeric?

    Quote Originally Posted by CAB2k
    Try this:
    Code:
        (if (and (= 0 (atoi revlast))(numberp (read revlast)))
            (command "script" "N:/plot/Pspace-Interim.scr")
            (command "script" "N:/plot/Pspace-As-Built.scr")
        )
    Thanks CAB2k, that would work well too. In fact, it is probably an even more appropriate function to use than distof but I have that working now so I think I'll leave it as it is.

    Thanks anyway,...Jon.

  8. #8
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Another way to check alpha vs. numeric?

    You're welcome.

  9. #9
    I could stop if I wanted to
    Join Date
    2002-02
    Location
    Kansas
    Posts
    487
    Login to Give a bone
    0

    Default Re: Another way to check alpha vs. numeric?

    Here I check the ascii code.
    code 48 =0 code 57 = 9
    code 65 = A
    code 97 = a

    so if the ascii code > 57 it is alpha

    Code:
    (setq revlen (strlen revval))
    (setq revlast (substr revval revlen))
    	(if (> 57 (ascii revlast))
    		(command "script" "N:/plot/Pspace-Interim.scr")
    		(command "script" "N:/plot/Pspace-As-Built.scr")
    	)

  10. #10
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Another way to check alpha vs. numeric?

    . . . and as a function
    Code:
    (defun num? ( in / )
      (if (and (< 47 (ascii in )) (< (ascii in ) 58 )) T nil )
    )
    there (num? "A" ) returns nil and (num? "5" ) returns T

    : ) Happy Computing !

    kennet

Page 1 of 2 12 LastLast

Similar Threads

  1. The 'Check Circuits' in the 'Check Systems' ribbon no longer works in 2012.
    By Wish List System in forum Revit MEP - Wish List
    Replies: 0
    Last Post: 2011-11-01, 06:26 PM
  2. Replies: 0
    Last Post: 2010-09-21, 02:06 PM
  3. Alpha Numeric room tags
    By mrgeee92329 in forum ACA General
    Replies: 4
    Last Post: 2008-12-04, 12:20 PM
  4. QSELECT Numeric and alpha text
    By Shoey in forum AutoCAD General
    Replies: 4
    Last Post: 2008-08-15, 09:17 PM
  5. 8.1/E - Section box have numeric properties - O
    By janunson in forum Revit Architecture - Wish List
    Replies: 1
    Last Post: 2005-10-07, 07:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •