Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GETENV value

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
CSM_MAI
409 Views, 4 Replies

GETENV value

I am trying to write a routine that would allow me to be able to use the partial value of an environment variable and apply that to other code. For example, (GETENV "computername") say it returns "Franklyn" for the compuer name, how could I make the value read "Frank" as in only get the return value of the first 5 characters similar to the (substr "computername" 1 4)  returns "comp". Is there a way to apply this value to work with other code? Such as, If the computername returns Frank, then activate command A, and if the computername returns James, then activate Command B. Any direction on this matter would be much appreciated.

 

 

Thanks

 

Chris

4 REPLIES 4
Message 2 of 5
hmsilva
in reply to: CSM_MAI


@CSM_MAI wrote:

I am trying to write a routine that would allow me to be able to use the partial value of an environment variable and apply that to other code. For example, (GETENV "computername") say it returns "Franklyn" for the compuer name, how could I make the value read "Frank" as in only get the return value of the first 5 characters similar to the (substr "computername" 1 4)  returns "comp". Is there a way to apply this value to work with other code? Such as, If the computername returns Frank, then activate command A, and if the computername returns James, then activate Command B. Any direction on this matter would be much appreciated.

 

 

Thanks

 

Chris


Hi Chris,

 

Maybe something like this

(setq CName (substr (GETENV "computername") 1 5))
(cond ((= CName "Frank")
       (command_A)
       )
      ((= CName "James")
       (command_B)
       )
      );; cond

 

Hope that helps

Henrique

EESignature

Message 3 of 5
Kent1Cooper
in reply to: CSM_MAI

One way:

 

(setq comp (substr (getenv "computername") 1 5))

(cond

  ((= comp "Frank") (command "_.whatever"))

  ((= comp "James") (command "_.something"))

  ((= comp "Alice") (command "_.this"))

  ((= comp "Carol") (command "_.that"))

); cond

Kent Cooper, AIA
Message 4 of 5
CSM_MAI
in reply to: CSM_MAI

I thank you both. This has certainly pointed me in the right direction. 

Message 5 of 5
hmsilva
in reply to: CSM_MAI

You're welcome, Chris
Glad I could help

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost