From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c099e8bb1678b9a3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Frank Beard Newsgroups: comp.lang.ada Subject: Re: Accessing Windows environment vairables in ObjectADA on windows Date: Mon, 18 Oct 2004 13:01:08 -0700 (PDT) Organization: Cuivre, Argent, Or Message-ID: NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: melchior.cuivre.fr.eu.org 1098129711 97587 212.85.156.195 (18 Oct 2004 20:01:51 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Mon, 18 Oct 2004 20:01:51 +0000 (UTC) To: TARAN TRIPATHI , comp.lang.ada@ada-france.org Return-Path: In-Reply-To: X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:5414 Date: 2004-10-18T13:01:08-07:00 You could look at Pascal Obry's POSIX Windows package (http://perso.wanadoo.fr/pascal.obry/archive/w32posix.html). The link to download it is at the bottom of the page. It is bascially the POSIX spec wrapped around the Win32 calls. Look in POSIX_Process_Environment.Environment_Value_Of. I've used it and it works. Frank --- TARAN TRIPATHI wrote: > Hi All, > > This is what I have. > > I have a win batch file which sets an environment > variable say > "TEST_SOURCE_DIR" > > setlocal > .. > set TEST_SOURCE_DIR=%1 > ... > endlocal > > For the purpose of seeing how to do it I used set > TEST_SOURCE_DIR=C:\ > on command prompt to set the variable. > > I have to access this evironment variable in my ADA > code. > This is test code I wrote: > > with ADA.Text_IO,System.RTS.Win32; > procedure GetEnvVar is > EnvVal:String(1..100):=(others=>' '); > len:System.RTS.Win32.DWORD:=100; > begin > > Len:=System.RTS.Win32.GetEnvironmentVariable("TEST_SOURCE_DIR",EnvVal'Address,Len); > Ada.Text_IO.Put_Line(EnvVal); > end GetEnvVar; > > The GetEnvironmentVariable function is defined in > System.RTS32.Win32 > packages in Win32INT file. > > The problem is that the GetEnvironmentVariable > function returns null > for TEST_SOURCE_DIR but gives the correct value for > all other Env > variables like HOME, ALLUSERSPROFILE,APPDATA, > PROCESSOR_ARCHITECTURE > etc, but never for TEST_SOURCE_DIR. > > Also the funnier thing is that if I donot catch the > return value of > GetEnvironmentVariable funtion and use it as such > > System.RTS.Win32.GetEnvironmentVariable("TEST_SOURCE_DIR",EnvVal'Address,Len); > I get a compiler error > " Error: line 34 col 19 LRM:5.1(4), Procedure call, > entry call, or > code statement expected, Continuing " > which relates to BNF for simple statement. I believe > we need not > necessarily capture the return value of any > function(?) > > Does the variable being local or system variable > make any difference? > > I googled many a times for this but no help. I've > looked around at > FAQ's and the > adahome reference pages, but I haven't found > anything. > I an using ObjectAda 7.2 on Windows NT. > > I'm not supposed to use florist package or POSIX/ADA > interface. Even a > C library is not assured so that I can use #pragma > Interface(C,getenv). > I have to use the GetEnvironmentVariable function. > > Any help or pointers would be appreciated. > Thanx in advance. > > Regards, > Taran. > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada-france.org > http://www.ada-france.org/mailman/listinfo/comp.lang.ada > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com