Thread overview | |||||
---|---|---|---|---|---|
|
September 02, 2003 environment variable | ||||
---|---|---|---|---|
| ||||
Hello, how can i get the environment variable's in D. In c i can do this: int main(int argc, char* argv[],char* envp[]) { int i = 0; while (envp[i]!=NULL) { printf("\n"); printf(envp[i++]); } return 0; } |
September 02, 2003 Re: environment variable | ||||
---|---|---|---|---|
| ||||
Posted in reply to manfred | If this is windows, you can use DIG's Control.OS.environmentalVariable(char [] name) http://www.opend.org/dig/classControl_1_1OS.html But only if you know the env variable name. Charles <manfred@toppoint.de> wrote in message news:bj27g4$28a4$1@digitaldaemon.com... > Hello, > > how can i get the environment variable's in D. > > In c i can do this: > > int main(int argc, char* argv[],char* envp[]) { > int i = 0; > while (envp[i]!=NULL) { > printf("\n"); > printf(envp[i++]); > } > return 0; > } > > |
September 02, 2003 Re: environment variable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles Sanders | Charles Sanders wrote: > > If this is windows, you can use DIG's > > Control.OS.environmentalVariable(char [] name) > > http://www.opend.org/dig/classControl_1_1OS.html > > But only if you know the env variable name. > > Charles > > <manfred@toppoint.de> wrote in message news:bj27g4$28a4$1@digitaldaemon.com... > > Hello, > > > > how can i get the environment variable's in D. > > > > In c i can do this: > > > > int main(int argc, char* argv[],char* envp[]) { > > int i = 0; > > while (envp[i]!=NULL) { > > printf("\n"); > > printf(envp[i++]); > > } > > return 0; > > } > > > > It seems that Burton has only put a thin wrapping over standard Phobos functions: /* from stdlib.d */ extern (C) char *getenv(char *varname); extern (C) int putenv(char *envstring); /* from net\BurtonRadons\dig\windows\windows.d */ /** Return an environment variable or null if this is not assigned. */ static char [] environmentVariable (char [] name) { return string.toString (getenv (toStringz (name))).dup; } /** Assign an environment variable. */ static void environmentVariable (char [] name, char [] value) { putenv (toStringz (name ~ "=" ~ value)); } -- Helmut Leitner leitner@hls.via.at Graz, Austria www.hls-software.com |
Copyright © 1999-2021 by the D Language Foundation