Special directories
Hi, how can I obtain (under Rebol 2 on WIN) names of special dirs, like temp dir or common app data etc.? TIA, Kai
posted by: Kai 9-Jul-2011/14:17:56-7:00
You can use get-env for that: >> get-env "TEMP" == "C:\Users\Endo\AppData\Local\Temp" >> get-env "APPDATA" == "C:\Users\Endo\AppData\Roaming" ;in Win7 and also try this: s: copy "" call/output "set" s This will write all environment vars into S as string. Then you can parse it: foreach b parse/all s crlf [append [] copy/part b find b #"="] This will return names of all env. vars in a block. == ["ALLUSERSPROFILE" "APPDATA" "CommonProgramFiles" "COMPUTERNAME" ... And also you can get names and the values in one block: env: copy [] foreach b parse/all s crlf [append env reduce [copy/part b t: find b #"=" copy t]] so you can select any of them easily: >> select env "windir" == "=C:\Windows" >> select env "APPDATA" == "C:\Users\Endo\AppData\Roaming" I hope this will help.
posted by: Endo 10-Jul-2011/9:28:36-7:00
Thanks, Endo - that does the trick
posted by: Kai 11-Jul-2011/0:16:53-7:00
One small fix is to add "next" to prevent "=" char in the values: >> env: copy [] foreach b parse/all s crlf [append env reduce [copy/part b t: find b #"=" copy next t]] >> select env "windir" == "C:\Windows" ; instead of "=C:\Windows"
posted by: Endo 11-Jul-2011/2:45:09-7:00
|