Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
dtiemeyer
Posts: 403
Registered: ‎01-09-2004
Message 1 of 6 (304 Views)
Accepted Solution

load .LSP file named for windows login

304 Views, 5 Replies
09-14-2012 02:52 PM

If my windows login name is HSIMPSON and i have created HSIMPSON.lsp in a Supported Directory, how do I load that Lisp file via the command line?

 

I have tried:

(load "loginname")

 

but that doesn't work because the 'load' command seems to want an explicit name, not a variable name.

 

Any suggestions?

 

Striving to be a WOMBAT, Waste Of Money, Brains, & Talent...

⁞|⁞ Please use the Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos functions as appropriate to further enhance the value of these forums. Thank you!

(load  (strcat (getvar "loginname") ".lsp") "Failed to Load")

 

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

Re: load .LSP file named for windows login

09-14-2012 04:53 PM in reply to: dtiemeyer

(load  (strcat (getvar "loginname") ".lsp") "Failed to Load")

 

Mentor
dtiemeyer
Posts: 403
Registered: ‎01-09-2004
Message 3 of 6 (269 Views)

Re: load .LSP file named for windows login

09-18-2012 10:19 AM in reply to: pbejse

Thanks!

 

Just out of curiosity, what does the   "Failed to Load"  part do?

Striving to be a WOMBAT, Waste Of Money, Brains, & Talent...

⁞|⁞ Please use the Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos functions as appropriate to further enhance the value of these forums. Thank you!
*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 4 of 6 (255 Views)

Re: load .LSP file named for windows login

09-19-2012 12:09 AM in reply to: dtiemeyer

According to the help button:

 

Evaluates the AutoLISP expressions in a file

(load filename [onfailure])

 

onfailure

 

A value returned if load fails.

If the onfailure argument is a valid AutoLISP function, it is evaluated. In most cases, the onfailure argument should be a string or an atom. This allows an AutoLISP application calling load to take alternative action upon failure

 

Clear as mud eh? :smileyhappy:

 

HTH

 

 

Valued Mentor
martti.halminen
Posts: 349
Registered: ‎12-31-2009
Message 5 of 6 (251 Views)

Re: load .LSP file named for windows login

09-19-2012 12:52 AM in reply to: pbejse

pbejse wrote:

According to the help button:

 

Evaluates the AutoLISP expressions in a file

(load filename [onfailure])

 

onfailure

 

A value returned if load fails.

If the onfailure argument is a valid AutoLISP function, it is evaluated. In most cases, the onfailure argument should be a string or an atom. This allows an AutoLISP application calling load to take alternative action upon failure

 


 

 

A little warning here, the document is somewhat unclear. LOAD is an ordinary function, so it lives under normal Lisp evaluation rules: all the arguments are evaluated before the function is called.

 

So, if you have a function in the onfailure argument, it is always called regardless of whether there is a failure or not. The only difference is that in the failure case its result is returned as the value of the LOAD call.

 

So

 

(load "foo.lsp" (alert "FOO!"))

 

would always produce the alert even if foo.lsp loaded with no problems.

 

There is no special evaluation behaviour for the onfailure argument: if you pass it an actual function, it is just returned as such with no additional evaluation:

 

_$ (load "C:/temp/roska.lsp" alert)
#<SUBR @24c07ad8 ALERT>

 

 

--

 

 

Mentor
dtiemeyer
Posts: 403
Registered: ‎01-09-2004
Message 6 of 6 (227 Views)

Re: load .LSP file named for windows login

09-19-2012 10:11 AM in reply to: martti.halminen

Thanks all. These responses are a little over my pay grade. But it's working, and thats what matters. Thanks!

Striving to be a WOMBAT, Waste Of Money, Brains, & Talent...

⁞|⁞ Please use the Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos functions as appropriate to further enhance the value of these forums. Thank you!
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.