Should something like this work?
⎕cmd 'echo %cas%'
C:\github\cas-6.0
]cd
C:\Users\norbet\Desktop
]cd %cas%
* Command Execution Failed: Unable to change directory
Environment variables with user commands. I.e. ]cd %temp%
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
- norbertjurkiewicz84
- Posts: 62
- Joined: Mon Nov 01, 2010 7:26 pm
-
- Posts: 439
- Joined: Wed Oct 01, 2008 9:39 am
Re: Environment variables with user commands. I.e. ]cd %tem
Hi Norbert,
I have logged this as an RFE 18348.
Regards,
Vince
I have logged this as an RFE 18348.
Regards,
Vince
- Adam|Dyalog
- Posts: 143
- Joined: Thu Jun 25, 2015 1:13 pm
Re: Environment variables with user commands. I.e. ]cd %tem
In general, environment variable syntax is only recognised by shells and shell interfaces, not by applications, so this behaviour is consistent across all programs, by Dyalog and others.
The %name% syntax is specific to the Windows/DOS shells, while UX shells use $NAME, or ${NAME} if the name has unusual characters in it. SALT uses [name], but user commands in general don't support this. In any case, such a syntax might need a way to escape it if the literal characters are needed.
The formal way to achieve what you wrote is:
A couple of notes are in order:
The %name% syntax is specific to the Windows/DOS shells, while UX shells use $NAME, or ${NAME} if the name has unusual characters in it. SALT uses [name], but user commands in general don't support this. In any case, such a syntax might need a way to escape it if the literal characters are needed.
The formal way to achieve what you wrote is:
⎕SE.UCMD'CD ',⎕SE.Dyalog.Utils.Config'cas'
A couple of notes are in order:
- Changing directory while code is running can have unexpected consequences.
- It is considered bad practice to use user commands under program control.
'\[[^]]+]'⎕R{⎕SE.Dyalog.Utils.Config 1↓¯1↓⍵.Match}which replaces text in square brackets with the corresponding environment variable.