Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Contributor
Prac_Slip_Kerm
Posts: 23
Registered: ‎09-07-2011
Message 1 of 10 (1,037 Views)
Accepted Solution

Put Default Text on Command Line for getstring

1037 Views, 9 Replies
06-06-2012 10:31 PM

Hi All,

  I am trying to get a default value (from global variable) put as the default for getstring command. Problem is I want it as if I had typed it into the getstring command so I can modify it if required. It is for entering filenames which only change slightly ie 1129E09LS1 ...LS2 ...XS1 etc.

Any ideas???

 

Current Code:

(setq BlkName (getstring "\nEnter Civil Cad File to Import: "))

For defaults that I don't want to change I usually use this format:

(or BlkName (setq BlkName (getstring "\nEnter Civil Cad File to Import: ")))

 Thanks In Advance

 

Cheers
Steve :-)

 

Play around with this one

 

(defun c:Test ()
 (setq BlkName (lisped (if (or (null BlkName)
                                      (numberp BlkName))
                                     "" (strcase BlkName))))
        )

 

 

 


pbejse wrote:

 

Play around with this one

 

(defun c:Test ()
 (setq BlkName (lisped (if (or (null BlkName)
                                      (numberp BlkName))
                                     "" (strcase BlkName))))
        )

 

 

 


Hi pBe .

 

What's this lisped ?? You must have forgotten to add that sub-function  :smileywink:

Distinguished Mentor
_Tharwat
Posts: 642
Registered: ‎07-02-2010
Message 2 of 10 (1,034 Views)

Re: Put Default Text on Command Line for getstring

06-06-2012 11:13 PM in reply to: Prac_Slip_Kerm

Maybe ..... change the [My File Name] to your needed one .

 

(if (eq (setq BlkName (getstring  "\nEnter Civil Cad File to Import [My File Name] : ")) "")
  (setq BlkName "My File Name"))

 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 3 of 10 (1,024 Views)

Re: Put Default Text on Command Line for getstring

06-07-2012 01:09 AM in reply to: _Tharwat

 

Play around with this one

 

(defun c:Test ()
 (setq BlkName (lisped (if (or (null BlkName)
                                      (numberp BlkName))
                                     "" (strcase BlkName))))
        )

 

 

 

Distinguished Mentor
_Tharwat
Posts: 642
Registered: ‎07-02-2010
Message 4 of 10 (1,022 Views)

Re: Put Default Text on Command Line for getstring

06-07-2012 01:23 AM in reply to: pbejse

pbejse wrote:

 

Play around with this one

 

(defun c:Test ()
 (setq BlkName (lisped (if (or (null BlkName)
                                      (numberp BlkName))
                                     "" (strcase BlkName))))
        )

 

 

 


Hi pBe .

 

What's this lisped ?? You must have forgotten to add that sub-function  :smileywink:

____________________________________________________
Get learn and learn and practice , to become experienced guy .
*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 5 of 10 (1,020 Views)

Re: Put Default Text on Command Line for getstring

06-07-2012 01:37 AM in reply to: _Tharwat

_Tharwat wrote:

Hi pBe .

 

What's this lisped ?? You must have forgotten to add that sub-function  :smileywink:


Did you try it?

 


 

Distinguished Mentor
_Tharwat
Posts: 642
Registered: ‎07-02-2010
Message 6 of 10 (1,016 Views)

Re: Put Default Text on Command Line for getstring

06-07-2012 01:42 AM in reply to: pbejse

pbejse wrote:

_Tharwat wrote:

Hi pBe .

 

What's this lisped ?? You must have forgotten to add that sub-function  :smileywink:


Did you try it?

 


 


That's awesome . :smileyvery-happy:

____________________________________________________
Get learn and learn and practice , to become experienced guy .
*Expert Elite*
Kent1Cooper
Posts: 5,871
Registered: ‎09-13-2004
Message 7 of 10 (1,000 Views)

Re: Put Default Text on Command Line for getstring

06-07-2012 11:53 AM in reply to: pbejse

pbejse wrote:

....

 (setq BlkName (lisped (if (or (null BlkName)
                                      (numberp BlkName))
                                     "" (strcase BlkName))))
        ) 


That is awesome, as _Tharwat said.  It is beyond my comprehension why a function like (lisped) would not be included in the AutoLISP Reference [it can't be that it's newer than my old version, because the function is present].  How is anyone supposed to know about it?

Kent Cooper
Contributor
Prac_Slip_Kerm
Posts: 23
Registered: ‎09-07-2011
Message 8 of 10 (981 Views)

Re: Put Default Text on Command Line for getstring

06-07-2012 06:02 PM in reply to: pbejse

Thanks heaps pbejse!!!!

I ended up copying lisped out of acad.dcl and modifying it to suit my needs and using your code.

;Call DCL to display dialog with previous BlkName if it Exists
  (setq BlkName (CCIdcl
		  (if (or (null BlkName) (numberp BlkName));or
		    "" (strcase BlkName)
		  );if
		 );CCIdcl
  );setq 
  ;Check if BlkName /= ""
  (cond
    ((= "" BlkName)
      (princ "\n No Filename Entered - Function Cancelled")
    );Cond BlkName = ""
    ( T
      (progn
        ... Code to run here ...
      );progn
    );cond BlkName Exists
  );cond  

 lisped changed to CCIdcl, modified labels & removed mtext editor button

(defun CCIdcl (contents / fname dcl state)
  ;;;(if (not (setq fname (getvar "program")))
  (setq fname "BK-Std")
  ;;;)
  (strcat fname ".dcl")
  (setq dcl (load_dialog fname))
  (if (not (new_dialog "CCI" dcl)) (exit))
  (set_tile "contents" contents)
  (mode_tile "contents" 2)
  (action_tile "contents" "(setq contents $value)")
  (action_tile "accept" "(done_dialog 1)")
;;;  (action_tile "mtexted" "(done_dialog 2)" )
  (setq state (start_dialog))
  (unload_dialog dcl)
  (cond
    ((= state 1) contents)
    ((= state 2) -1)
    (t 0)
  );cond
);defun

 Thanks again for your help!

 

Cheers
Steve :-)
*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 9 of 10 (970 Views)

Re: Put Default Text on Command Line for getstring

06-07-2012 09:54 PM in reply to: Prac_Slip_Kerm

Prac_Slip_Kerm wrote:

Thanks heaps pbejse!!!!

,.....

 

 


You are welocme, glad i could help 

Keep on coding,

 

Cheers

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 10 of 10 (953 Views)

Re: Put Default Text on Command Line for getstring

06-08-2012 04:35 AM in reply to: Kent1Cooper

Cool huh? :smileyhappy:

 

One soruce is thru atoms-list function, when evaluating  an item you will get #<USUBR @161e3e24 LISPED> , and its unrecognizable  then you'll start to wonder what that is...the local search button on this forum or Mr. google will find it for you.

 

Most of the time i just jumped from one forum to another. :smileyvery-happy:

 

Another source is  JTB World Undocumented section  or Manusoft

 

 

HTH

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.