newLISP Fan Club

Forum => newLISP in the real world => Topic started by: dukester on September 19, 2009, 04:41:27 AM

Title: Device names and/or numbers
Post by: dukester on September 19, 2009, 04:41:27 AM
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...
Title:
Post by: cormullion on September 19, 2009, 02:41:16 PM
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:


(constant 'stdin 0 'stdout 0)
(device stdout)
(read-line stdin)


but it looks unnecessary to me.
Title:
Post by: TedWalther on September 19, 2009, 05:40:17 PM
Quote from: "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:


(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.
Title:
Post by: cormullion on September 20, 2009, 02:41:36 AM
Makes sense!
Title:
Post by: dukester on September 25, 2009, 10:04:24 AM
Quote from: "TedWalther"
Quote from: "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:


(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!
Title:
Post by: TedWalther on September 25, 2009, 05:31:34 PM
Quote from: "dukester"
Quote from: "TedWalther"
Quote from: "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:


(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.