See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: initget/getkword with space and dots

  1. #1
    Member
    Join Date
    2009-11
    Posts
    4
    Login to Give a bone
    0

    Default initget/getkword with space and dots

    Hello,
    I have a lisp but i want to a space behind the dots in the names. example J.Marchal has to be J. Marchal.
    The result now is J. It stops the string after the space.
    Can this be done?



    Code:
    ;-----------------------------------------------------
    (initget "J.Marchal A.Scholten I.vdHorst")
    (setq *ans*
      (cond
        (
          (getkword
            (strcat "\nChoose [J.Marchal/A.Scholten/I.vdHorst] <"
              (setq *ans*
                (cond ( *ans* ) ( "J.Marchal" ))
              )
              ">: "
            )
          )
        )
        ( *ans* )
      )
    )
    
    
    
    ;-----------------------------------
    thank you in advance,

    Jaap
    Last edited by Ed Jobe; 2017-02-28 at 03:21 PM. Reason: Added code tags.

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: initget/getkword with space and dots

    Please click the [Go Advanced] button and use code tags (# in the toolbar) to place you lisp.

    Try using a nonbreaking space Alt+255 or Ctrl+Shift+Spacebar instead of space.

  3. #3
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: initget/getkword with space and dots

    Quote Originally Posted by pmxcad View Post
    example J.Marchal has to be J. Marchal.
    If you do this, you are not following the command line syntax rules. This will affect how your command displays at the command line. One rule is that spaces separate words. This will cause "J." and "Marchal" to appear as separate options. Another rule is that a capital letter in the option is that option's shortcut. Don't forget that this syntax affects option menus that appear when you press the down arrow key and that users can mouse click options at the command line.

    It also goes against the idea of making it easy for users to enter command options. What I suggest is just having "[Marchal Scholten vdHorst]". Then in your following logic, if the user types "M", "m" or "Marchal", you substitute "J. Marchal".
    Last edited by Ed Jobe; 2017-02-28 at 03:42 PM.
    C:> ED WORKING....


    LinkedIn

  4. #4
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Re: initget/getkword with space and dots

    Ed's suggestion is a good one, but personally I've always found that initget/getkword may seem perfectly feasible for the guy doing the coding but may not be intuitive for other users unless its for simple things like "Yes, No" "Ok, Cancel" type of stuff. An alternative solution would be to use a pop-up dialog to select your option really quick from a list.

    Try substituting this snippet for your above snippet

    Code:
    ;---------------------------------
    
    (vl-load-com)
    
    (tmpdia)
    
    (setq dcl:id (load_dialog fn))
    (if (not (new_dialog "temp_dialog" dcl:id))
     (exit)
    )
    
    (setq lst (list "J. Marchal" "A. Scholten" "I. vdHorst"))
    
    (start_list "plist")
    (mapcar 'add_list lst)
    (end_list)
    
    (action_tile "accept" "
    (setq *ans* (get_tile \"plist\"))
    (done_dialog)")
    
    (action_tile "cancel" "(done_dialog)")
    
    (start_dialog)
    (unload_dialog dcl:id)
    (vl-file-delete fn)
    
    (setq *ans* (nth (atoi *ans*) lst))
    ;---------------------------------
    and add this sub-function to the end of your lisp file.

    Code:
    (defun tmpdia ()
     (setq fn (vl-filename-mktemp "dcl.dcl"))
     (setq fn (open fn "w"))
     (write-line
     "temp_dialog : temp_dialog : dialog { : popup_list { key = "plist"; label = "Select Name"; value = ""; } ok_cancel; }"
     fn)
     (close fn)
    )
    This is just another suggestion, if it works better for ya.
    ;edit, forgot some lines
    Last edited by ccalder; 2017-03-01 at 05:40 PM.

  5. #5
    Woo! Hoo! my 1st post
    Join Date
    2019-03
    Posts
    1
    Login to Give a bone
    1

    Default Re: initget/getkword with space and dots

    As a way-around, a came with a following solution (which was enough for my needs):

    Code:
    (initget "1 2 3 4")
    (setq x (atoi (getkword "[1 str 1/2 str 2/3 str 3/4 str 4]")))
    (setq x_list '((1 . "str 1") (2 . "str 2") (3 . "str 3") (4 . "str 4")))
    (setq x (cdr (assoc x x_list)))

  6. #6
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: initget/getkword with space and dots

    I wrote Multi radio buttons to replace initget its a single program but can have as many buttons as you like ( subject to Autocad) it uses a string input for the button label so a "N. Armstrong moon" is acceptable. I am not on my computer will post later. (list "N. Armstrong moon" "A Swarzneger Actor")

    Code:
    ; Multi button Dialog box for a single choice repalcment of initget
    ; By Alan H Feb 2019
    
    ; Example code as the radio button click will close the defualt button setting is required 
    ; if you have defined a default setting
    
    ; (if (not AH:Butts)(load "Multi radio buttons.lsp"))
    ; (if (= but nil)(setq but 1)) ; this is needed to set default button
    ; (setq ans (ah:butts but "V"   '("A B C D " "A" "B" "C" "D" ))) ; ans holds the button picked value
    
    ; (setq butlst)
    ; (if (not AH:Butts)(load "Multi Radio buttons.lsp"))
    ; (if (= but nil)(setq but 1))
    ; (setq ans (ah:butts but "h"  '("Yes or No" "Yes" "No"))) ; ans holds the button picked value
    
    
    (vl-load-com)
    (defun AH:Butts (AHdef verhor butlst / fo fname x  k )
    (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
    (write-line  "AHbutts : dialog 	{" fo)
    (write-line  (strcat "	label =" (chr 34) (nth 0 butlst) (chr 34) " ;" )fo)
    (write-line "	: row	{" fo)
    (if (=  (strcase verhor) "V")
    (write-line "	: boxed_radio_column 	{" fo)
    (write-line "	: boxed_radio_row	{" fo)
    )
    (setq x 1)
    (repeat (- (length butlst) 1) 
    (write-line "	: radio_button	{" fo)
    (write-line  (strcat "key = "  (chr 34) "Rb" (rtos x 2 0)  (chr 34) ";") fo)
    (write-line  (strcat "label = " (chr 34) (nth x  butlst) (chr 34) ";") fo)
    (write-line "	}" fo)
    (setq x (+ x 1))
    )
    (write-line "	}" fo)
    (write-line "	}" fo)
    (write-line "spacer_1 ;" fo)
    (write-line "	ok_only;" fo)
    (write-line "	}" fo)
    (close fo)
    (setq dcl_id (load_dialog fname))
    (if (not (new_dialog "AHbutts" dcl_id) )
    (exit)
    )
    (setq x 1)
    (repeat (- (length butlst) 1)
    (setq k (strcat "Rb" (rtos x 2 0)))
    (action_tile k  (strcat "(setq but "  (rtos x 2 0) ")" "(done_dialog)"))
    (if (= ahdef x)(set_tile k "1"))
    (setq x (+ x 1))
    )
    (action_tile "accept" (strcat "(setq but "  (rtos ahdef 2 0) ")" "(done_dialog)"))
    (start_dialog)
    (unload_dialog dcl_id)
    (vl-file-delete fname)
    (nth but butlst)
    )
    Last edited by BIG-AL; 2019-03-20 at 05:14 AM.

Similar Threads

  1. Mysterious dots
    By mr6jam in forum Revit Architecture - General
    Replies: 99
    Last Post: 2010-08-06, 07:12 PM
  2. The 3 dots... what are they called?
    By SRBalliet in forum AutoCAD General
    Replies: 4
    Last Post: 2008-01-29, 09:36 PM
  3. Can't get rid of dots..
    By shari in forum AutoCAD General
    Replies: 8
    Last Post: 2007-10-15, 11:06 PM
  4. initget/getkword with 2 capital letters
    By tflaherty in forum AutoLISP
    Replies: 6
    Last Post: 2005-05-12, 03:17 PM
  5. Help with getkword
    By tflaherty in forum AutoLISP
    Replies: 13
    Last Post: 2005-04-30, 03:22 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
  •