Device names and/or numbers

Q&A's, tips, howto's
Locked
dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

Device names and/or numbers

Post by dukester »

Is there a list of device numbers somewhere? I've searched the manual with no luck. Something like:

Device Name Device#
keyboard 0
crt 1
etc
etc

As well, are:

STDIN
STDOUT
STDERR

defined?

Can I use STDIN in code to mean device#0? etc...
duke

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

If you create new file handles, numbering seems to start at 3. So that leaves 1 and 2 unaccounted for, as 0 is stdin/stdout. Dunno what 1 and 2 might do.

Perhaps you don't need to specify stdin/stdout, as they're the default until you choose another IO device.

Or you could do stuff like this:

Code: Select all

(constant 'stdin 0 'stdout 0)
(device stdout)
(read-line stdin)
but it looks unnecessary to me.

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Post by TedWalther »

cormullion wrote:If you create new file handles, numbering seems to start at 3. So that leaves 1 and 2 unaccounted for, as 0 is stdin/stdout. Dunno what 1 and 2 might do.

Perhaps you don't need to specify stdin/stdout, as they're the default until you choose another IO device.

Or you could do stuff like this:

Code: Select all

(constant 'stdin 0 'stdout 0)
(device stdout)
(read-line stdin)
but it looks unnecessary to me.
1 is stdout. 2 is stderr. 0 is stdin.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Makes sense!

dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

Post by dukester »

TedWalther wrote:
cormullion wrote:If you create new file handles, numbering seems to start at 3. So that leaves 1 and 2 unaccounted for, as 0 is stdin/stdout. Dunno what 1 and 2 might do.

Perhaps you don't need to specify stdin/stdout, as they're the default until you choose another IO device.

Or you could do stuff like this:

Code: Select all

(constant 'stdin 0 'stdout 0)
(device stdout)
(read-line stdin)
but it looks unnecessary to me.
1 is stdout. 2 is stderr. 0 is stdin.
Is this documented anywhere that I should have stumbled upon? Anyway, thanks for the heads-up!
duke

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Post by TedWalther »

dukester wrote:
TedWalther wrote:
cormullion wrote:If you create new file handles, numbering seems to start at 3. So that leaves 1 and 2 unaccounted for, as 0 is stdin/stdout. Dunno what 1 and 2 might do.

Perhaps you don't need to specify stdin/stdout, as they're the default until you choose another IO device.

Or you could do stuff like this:

Code: Select all

(constant 'stdin 0 'stdout 0)
(device stdout)
(read-line stdin)
but it looks unnecessary to me.
1 is stdout. 2 is stderr. 0 is stdin.
Is this documented anywhere that I should have stumbled upon? Anyway, thanks for the heads-up!
It is a standard C/Unix thing. You would come across it in the beginning of any discussion of file handles and file io.

Locked