Limited character input

Limited character input

saitoib
Advocate Advocate
782 Views
4 Replies
Message 1 of 5

Limited character input

saitoib
Advocate
Advocate

Hi All!

 

I want to limit the characters I can type.
Currently, I have come up with the following code to do so.
Maybe there is a more standard code?

(defun c:test1 ( / val);ali is gloval
  (while (not (or
    (= val "L") (= val "l")	(= val "C") (= val "c")	(= val "R") (= val "r")))
    (cond
      ((setq val (getstring (strcat "\Enter attach position [right(R) center(C) left(L)]"
        (if ali (strcat "<" ali ">") "")
        ":")))
        (if (= val "") (setq val ali));if enter
      )
    )
  )
  (setq val (strcase val));to capital letter
  (setq ali val)
)
Saitoib
0 Likes
Accepted solutions (1)
783 Views
4 Replies
Replies (4)
Message 2 of 5

dbroad
Mentor
Mentor
Accepted solution

If I'm interpreting your problem correctly, look at the help files for initget, especially the bits value.

(initget 1 "Right Center Left" ) ;;use 0 to accept defaults and test for nil in getstring result
(setq val (getkword "\nEnter the attach position [Right/Center/Left] :"))
Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 3 of 5

saitoib
Advocate
Advocate

@dbroad 

There was a special function for this.
Thank you very much.

Saitoib
0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor

Or this is a library function can be used in any code 3 lines of code.

 

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= but nil)(setq but 1))
(setq ans (ah:butts but "h"  '("Left center or right" "Left" "Centre" "Right"))) ; ans holds the button picked

SeaHaven_0-1638836982675.png

 

0 Likes
Message 5 of 5

saitoib
Advocate
Advocate

@Sea-Haven 

This is cool.
Thank you very much.

Saitoib