Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

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

load .LSP file named for windows login

296 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!
*Expert Elite*
pbejse
Posts: 2,441
Registered: ‎11-24-2009
Message 2 of 6 (290 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: 377
Registered: ‎01-09-2004
Message 3 of 6 (261 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,441
Registered: ‎11-24-2009
Message 4 of 6 (247 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: 319
Registered: ‎12-31-2009
Message 5 of 6 (243 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: 377
Registered: ‎01-09-2004
Message 6 of 6 (219 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!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community