Page 1 of 1

Device names and/or numbers

Posted: Sat Sep 19, 2009 11:41 am
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...

Posted: Sat Sep 19, 2009 9:41 pm
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.

Posted: Sun Sep 20, 2009 12:40 am
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.

Posted: Sun Sep 20, 2009 9:41 am
by cormullion
Makes sense!

Posted: Fri Sep 25, 2009 5:04 pm
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!

Posted: Sat Sep 26, 2009 12:31 am
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.