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
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by hmsilva. Go to Solution.
@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
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