comp.lang.ada
 help / color / mirror / Atom feed
* HELP: PC System Call
@ 2002-06-08  0:46 John Cupak
  2002-06-08  6:40 ` Adrian Knoth
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: John Cupak @ 2002-06-08  0:46 UTC (permalink / raw)


I teach Ada 95 using N. Cohen's "Ada as a Second Language, 2ed".

In the past, the students used UNIX workstations, and I assigned them
the GETENV problem from them book. You know, call the UNIX
getenv function with an environment variable, and get the mapped
results back. We used all the C interface libraries, and it work just
like in the book!

But, now we've replaced all the UNIX workstations with PCs, and I
need a similar problem to give the students.

Does anyone have a nice, simple, Ada 95 "call" to an existing PC
library function (even a DLL?) that I can substitute for the GETENV
problem?

Let me know both here, as well as my work email: John_J_Cupak@raytheon.com

Thanks,
John





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: HELP: PC System Call
  2002-06-08  0:46 HELP: PC System Call John Cupak
@ 2002-06-08  6:40 ` Adrian Knoth
  2002-06-09  4:04   ` Chad R. Meiners
  2002-06-08  7:59 ` Jerry van Dijk
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Adrian Knoth @ 2002-06-08  6:40 UTC (permalink / raw)


John Cupak <Jcupak744@attbi.com> wrote:

> But, now we've replaced all the UNIX workstations with PCs, and I
> need a similar problem to give the students.

That is your fault. Sponsored by Microsoft? :)

One way is to take your central UNIX-architecture. Using telnet or any
similar remote-login would give you UNIX. This works well for at least
two universities here, where the UNIX-pools can be "extended" by using
the provided X-server from Win2k-machines.

> Does anyone have a nice, simple, Ada 95 "call" to an existing PC
> library function (even a DLL?) that I can substitute for the GETENV
> problem?

Getting the Windows-Login-name could be a question solved by a DLL.

But let me come back to these two universities here: every PC is at least
Dualboot, thus having both, Windows and Linux, mostly Debian. A lot of
stuff is shared via NFS.

I think you should consider a way giving your students UNIX back. They
have a right for it and mankind needs it too (as a counterpart to all
these ugly Windows-stuff, which is probably decreasing intelligence :)

-- 
mail: adi@thur.de  	http://adi.thur.de	PGP: v2-key via keyserver

Shakesbeer fuer Alkoholiker: TWO BEER OR NOT TWO BEER



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: HELP: PC System Call
  2002-06-08  0:46 HELP: PC System Call John Cupak
  2002-06-08  6:40 ` Adrian Knoth
@ 2002-06-08  7:59 ` Jerry van Dijk
  2002-06-08 12:16 ` Robert Dewar
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Jerry van Dijk @ 2002-06-08  7:59 UTC (permalink / raw)



> In the past, the students used UNIX workstations, and I assigned them
> the GETENV problem from them book. You know, call the UNIX
> getenv function with an environment variable, and get the mapped
> results back. We used all the C interface libraries, and it work just
> like in the book!

Hmmmm, I can't find such an exercise in the book, only 19.7, asking a body
for a system call. Since you mentioned DLL's, I gather that you are running
Windows on the PC's. Although I do not understand what it is that does
not work, the following works fine with GNAT 3.14p for NT:

with Ada.Text_IO;          use Ada.Text_IO;
with Interfaces.C.Strings; use Interfaces.C.Strings;

procedure Check is

   function getenv (Name : chars_ptr) return chars_ptr;
   pragma Import (C, getenv, "getenv");

   function Get_Env (Name : String) return String is
      Result : chars_ptr;
      C_Name : chars_ptr := New_String (Name);
   begin
      Result := getenv (C_Name);
      Free (C_Name);
      return Value (Result);
   end Get_Env;

begin
   Put_Line ("COMSPEC = " & Get_Env ("COMSPEC"));
end Check;

-- 
--  Jerry van Dijk   | email: jvandyk@attglobal.net
--  Leiden, Holland  | web:   users.ncrvnet.nl/gmvdijk



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: HELP: PC System Call
  2002-06-08  0:46 HELP: PC System Call John Cupak
  2002-06-08  6:40 ` Adrian Knoth
  2002-06-08  7:59 ` Jerry van Dijk
@ 2002-06-08 12:16 ` Robert Dewar
  2002-06-08 12:17 ` Robert Dewar
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Robert Dewar @ 2002-06-08 12:16 UTC (permalink / raw)


"John Cupak" <Jcupak744@attbi.com> wrote in message news:<ZtcM8.49323$KD3.980836@typhoon.ne.ipsvc.net>...
> I teach Ada 95 using N. Cohen's "Ada as a Second Language, 2ed".
> 
> In the past, the students used UNIX workstations, and I assigned them
> the GETENV problem from them book. You know, call the UNIX
> getenv function with an environment variable, and get the mapped
> results back. We used all the C interface libraries, and it work just
> like in the book!
> 
> But, now we've replaced all the UNIX workstations with PCs, and I
> need a similar problem to give the students.
> 
> Does anyone have a nice, simple, Ada 95 "call" to an existing PC
> library function (even a DLL?) that I can substitute for the GETENV
> problem?
> 
> Let me know both here, as well as my work email: John_J_Cupak@raytheon.com

Well if you did the reasonable thing and ran GNU/Linux on your PC's, you would
not even be asking this question :-)

Even if for some reason you are running Microsoft systems, this should still
work fine (interfacing to getenv) if you have an appropriate compiler interfaced.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: HELP: PC System Call
  2002-06-08  0:46 HELP: PC System Call John Cupak
                   ` (2 preceding siblings ...)
  2002-06-08 12:16 ` Robert Dewar
@ 2002-06-08 12:17 ` Robert Dewar
  2002-06-09 10:51   ` Simon Wright
  2002-06-08 12:42 ` Preben Randhol
  2002-06-09  3:09 ` David Botton
  5 siblings, 1 reply; 9+ messages in thread
From: Robert Dewar @ 2002-06-08 12:17 UTC (permalink / raw)


"John Cupak" <Jcupak744@attbi.com> wrote in message news:<ZtcM8.49323$KD3.980836@typhoon.ne.ipsvc.net>...
> I teach Ada 95 using N. Cohen's "Ada as a Second Language, 2ed".
> 
> In the past, the students used UNIX workstations, and I assigned them
> the GETENV problem from them book. You know, call the UNIX
> getenv function with an environment variable, and get the mapped
> results back. We used all the C interface libraries, and it work just
> like in the book!
> 
> But, now we've replaced all the UNIX workstations with PCs, and I
> need a similar problem to give the students.
> 
> Does anyone have a nice, simple, Ada 95 "call" to an existing PC
> library function (even a DLL?) that I can substitute for the GETENV
> problem?

Actually if you are using GNAT, it would be more appropriate to use the
routine in the GNAT library for accessing environment variables.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: HELP: PC System Call
  2002-06-08  0:46 HELP: PC System Call John Cupak
                   ` (3 preceding siblings ...)
  2002-06-08 12:17 ` Robert Dewar
@ 2002-06-08 12:42 ` Preben Randhol
  2002-06-09  3:09 ` David Botton
  5 siblings, 0 replies; 9+ messages in thread
From: Preben Randhol @ 2002-06-08 12:42 UTC (permalink / raw)


On Sat, 08 Jun 2002 00:46:49 GMT, John Cupak wrote:
> I teach Ada 95 using N. Cohen's "Ada as a Second Language, 2ed".
> 
> In the past, the students used UNIX workstations, and I assigned them
> the GETENV problem from them book. You know, call the UNIX
> getenv function with an environment variable, and get the mapped
> results back. We used all the C interface libraries, and it work just
> like in the book!
> 
> But, now we've replaced all the UNIX workstations with PCs, and I
> need a similar problem to give the students.

Can't they do it on Linuxes on these PCs? Or has PC gotten an even new
meaning now? PC -> Presonal Computer -> Intel x86 Personal Computer ->
Intel x86 Presonal Computer with one of the Windows OS mutations ?

Preben



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PC System Call
  2002-06-08  0:46 HELP: PC System Call John Cupak
                   ` (4 preceding siblings ...)
  2002-06-08 12:42 ` Preben Randhol
@ 2002-06-09  3:09 ` David Botton
  5 siblings, 0 replies; 9+ messages in thread
From: David Botton @ 2002-06-09  3:09 UTC (permalink / raw)


There is an example on AdaPower of using GNAT.OS_Lib.getenv -
http://www.adapower.com/lang/gnat-os-getenv.html

If you need to, you can look at the source of  GNAT.OS_Lib (included with
the gnat distributions) and see how it is done.

David Botton



"John Cupak" <Jcupak744@attbi.com> wrote in message
news:ZtcM8.49323$KD3.980836@typhoon.ne.ipsvc.net...
> I teach Ada 95 using N. Cohen's "Ada as a Second Language, 2ed".
>
> In the past, the students used UNIX workstations, and I assigned them
> the GETENV problem from them book. You know, call the UNIX
> getenv function with an environment variable, and get the mapped
> results back. We used all the C interface libraries, and it work just
> like in the book!
>
> But, now we've replaced all the UNIX workstations with PCs, and I
> need a similar problem to give the students.
>
> Does anyone have a nice, simple, Ada 95 "call" to an existing PC
> library function (even a DLL?) that I can substitute for the GETENV
> problem?
>
> Let me know both here, as well as my work email: John_J_Cupak@raytheon.com
>
> Thanks,
> John
>
>





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: HELP: PC System Call
  2002-06-08  6:40 ` Adrian Knoth
@ 2002-06-09  4:04   ` Chad R. Meiners
  0 siblings, 0 replies; 9+ messages in thread
From: Chad R. Meiners @ 2002-06-09  4:04 UTC (permalink / raw)



"Adrian Knoth" <adi@drcomp.erfurt.thur.de> wrote in message
news:slrnag39n7.15h.adi@drcomp.erfurt.thur.de...
> I think you should consider a way giving your students UNIX back. They
> have a right for it and mankind needs it too (as a counterpart to all
> these ugly Windows-stuff, which is probably decreasing intelligence :)
>

Actually I would bet that ignorance and hatred are more apt to decrease
rational reasoning.

-CRM





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: HELP: PC System Call
  2002-06-08 12:17 ` Robert Dewar
@ 2002-06-09 10:51   ` Simon Wright
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Wright @ 2002-06-09 10:51 UTC (permalink / raw)


dewar@gnat.com (Robert Dewar) writes:

> Actually if you are using GNAT, it would be more appropriate to use
> the routine in the GNAT library for accessing environment variables.

Perhaps not if the point of the exercise is to teach interfacing to C?



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-06-09 10:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-08  0:46 HELP: PC System Call John Cupak
2002-06-08  6:40 ` Adrian Knoth
2002-06-09  4:04   ` Chad R. Meiners
2002-06-08  7:59 ` Jerry van Dijk
2002-06-08 12:16 ` Robert Dewar
2002-06-08 12:17 ` Robert Dewar
2002-06-09 10:51   ` Simon Wright
2002-06-08 12:42 ` Preben Randhol
2002-06-09  3:09 ` David Botton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox