Author Topic: Forward slashes within "Getkword"  (Read 1065 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
Forward slashes within "Getkword"
« on: January 13, 2017, 12:46:23 PM »
Code: [Select]
(defun c:test()
  (initget "B/CF F/CF")
  (setq ans (getkword "\nWhich offset [B/CF / F/CF]:")
      )
)

How do i ignore the slashes in
Code: [Select]
(getkword "\nWhich offset [B/CF / F/CF]:")This becomes 4 choices but I actually want two choices
"B/CF" Choice 1
"F/CF" Choice 2
How do I ignore the slashes?

ChrisCarlson

  • Guest
Re: Forward slashes within "Getkword"
« Reply #1 on: January 13, 2017, 01:27:12 PM »
You can either escape the character or use the ASCII codes. Escape shown below

Code - Auto/Visual Lisp: [Select]
  1. (setq ans (getkword "\nWhich offset [B\\CF / F\\CF]:")

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Forward slashes within "Getkword"
« Reply #2 on: January 13, 2017, 01:38:01 PM »
Per the documentation:

Quote
Keyword Specifications

The string argument is interpreted according to the following rules:
  • Each keyword is separated from the following keyword by one or more spaces. For example, "Width Height Depth" defines three keywords.
    • Each keyword can contain only letters, numbers, and hyphens (-).
    There are two methods for abbreviating keywords:
    • The required portion of the keyword is specified in uppercase characters, and the remainder of the keyword is specified in lowercase characters. The uppercase abbreviation can be anywhere in the keyword (for example, "LType", "eXit", or "toP").
    • The entire keyword is specified in uppercase characters, and it is followed immediately by a comma, which is followed by the required characters (for example, "LTYPE,LT"). The keyword characters in this case must include the first letter of the keyword, which means that "EXIT,X" is not valid.

    dubb

    • Swamp Rat
    • Posts: 1105
    Re: Forward slashes within "Getkword"
    « Reply #3 on: January 13, 2017, 02:07:26 PM »
    Ahh,....Thanks.

    Grrr1337

    • Swamp Rat
    • Posts: 812
    Re: Forward slashes within "Getkword"
    « Reply #4 on: January 13, 2017, 02:27:57 PM »
    One alternative is to use DCL, but the effort to achieve this might be bigger than the overall routine.
    (apply ''((a b c)(a b c))
      '(
        (( f L ) (apply 'strcat (f L)))
        (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
        (72 101 108 108 111 32 87 111 114 108 100)
      )
    )
    vevo.bg