Category : Files from Magazines
Archive   : DBMS0790.ZIP
Filename : HEAD.JUL

 
Output of file : HEAD.JUL contained in archive : DBMS0790.ZIP

LISTING 1
---------

1 : /*
2 : LPTSTAT.C
3 :
4 : CLIPPER external function to test the printer port
5 : for more detailed status than ISPRINTER()
6 :
7 : Written by Gene Head - June 15, 1990
8 :
9 : Placed in the public domain NSA (No Strings Attached)
10 :
11 : Quick-C Compile and link command lines:
12 :
13 : qcl /c /Gs /AL lptstat.c
14 : link /NOE prnstat lptstat,,, clipper.lib extend.lib
15 :
16 : Turbo-C Compile and link command lines:
17 :
18 : tcc -c -G -N- -f- -ml lptstat.c
19 : tlink prnstat lptstat,,, clipper.lib extend.lib cl.lib
20 :
21 :
22 :
23 : Include clipper headers and standard bios header
24 : */
25 : #include
26 : #include
27 : #include
28 :
29 : /* Clipper passes an integer parameter
30 : representing printer port number 0-2.
31 :
32 : Routine uses BIOS call to check printer status
33 : and then returns status code. Clipper code is
34 : used to evaluate returned status.
35 : */
36 :
37 : CLIPPER lptstat()
38 : {
39 : /* Declare port and status variables */
40 : int port, status ; /* ports: 0 = LPT1, 1 = LPT2, 2 = LPT3 */
41 :
42 : /* Receive the port parameter */
43 : port = _parni(1);
44 :
45 : /* Test for valid port 0-2 (also tested by calling PRG) */
46 : if ( port < 0 || port > 2 )
47 : status = 255; /* Port error code */
48 : else
49 : /* Get printer status code from bios interrupt. Choose
50 : ONE of the following functions to get status byte,
51 : omit the one you don't use!
52 : */
53 :
54 : /* This is the MicroSoft Quick C version */
55 : status = _bios_printer( _PRINTER_STATUS, port, 0 ) ;
56 :
57 : /* This is the Borland Turbo-C version
58 : /* status = biosprint( 2, port, 0 ) ; */
59 :
60 : /* Return status via Clipper EXTEND system */
61 : _retni(status);
62 : }
63 :


LISTING 2
---------

1 :
2 : * PRNSTAT.PRG
3 : *
4 : * Unfortunately, not all printer\controller\BIOS
5 : * combinations are created equal.
6 : * Use this program to test all sub-printer conditions.
7 : *
8 :
9 : escape = 27
10 :
11 : DO WHILE .T.
12 : CLEAR
13 :
14 : * Assume all bits are off
15 : Binary = "0000-0000"
16 :
17 : * Select port to test. NOTE: Ports: 0 = LPT1, 1 = LPT2, 2 = LPT3
18 : N = 0
19 : @ 04,00 SAY "Enter printer port number -> " ;
20 : GET N PICTURE "#" VALID PORTCHK(N)
21 : READ
22 :
23 : * ESCape key pressed?
24 : IF LASTKEY() = escape
25 : EXIT
26 : ENDIF
27 :
28 : * Execute PRINTER STATUS BIOS CALL via 'C' function
29 : N = LPTSTAT(N)
30 :
31 : * (This is a redundant check since 0-2 are trapped at the READ)
32 : * The 'C' function will return 255 if port is out of range

33 : IF N = 255 && Port Number Ok?
34 : ? "Invalid port number"
35 : Binary = "1111-1111"
36 :
37 : ELSE
38 : @ 05,00
39 : ?
40 : ? "Printer status returns decimal value -> " +STR(N,3)
41 : ?
42 :
43 : * Scan the return code bit-by-bit
44 :
45 : IF N >= 128
46 : B7 = "Bit 7 is on"
47 : N = N - 128
48 : Binary = STUFF(Binary,1,1,"1")
49 : ELSE
50 : B7 = "Bit 7 is off"
51 : ENDIF && N >= 128
52 :
53 : IF N >= 64
54 : B6 = "Bit 6 is on"
55 : N = N - 64
56 : Binary = STUFF(Binary,2,1,"1")
57 : ELSE
58 : B6 = "Bit 6 is off"
59 : ENDIF && N >= 64
60 :
61 : IF N >= 32
62 : B5 = "Bit 5 is on"
63 : N = N - 32
64 : Binary = STUFF(Binary,3,1,"1")
65 : ELSE
66 : B5 = "Bit 5 is off"
67 : ENDIF && N >= 32
68 :
69 : IF N >= 16
70 : B4 = "Bit 4 is on"
71 : N = N - 16
72 : Binary = STUFF(Binary,4,1,"1")
73 : ELSE
74 : B4 = "Bit 4 is off"
75 : ENDIF && N >= 16
76 :
77 : IF N >= 8
78 : B3 = "Bit 3 is on"
79 : N = N - 8
80 : Binary = STUFF(Binary,6,1,"1")
81 : ELSE
82 : B3 = "Bit 3 is off"
83 : ENDIF && N >= 8
84 :
85 : IF N >= 4
86 : B2 = "Bit 2 is on"
87 : N = N - 4
88 : Binary = STUFF(Binary,7,1,"1")
89 : ELSE
90 : B2 = "Bit 2 is off"
91 : ENDIF && N >= 4
92 :
93 : IF N >= 2
94 : B1 = "Bit 1 is on"
95 : N = N - 2
96 : Binary = STUFF(Binary,8,1,"1")
97 : ELSE
98 : B1 = "Bit 1 is off"
99 : ENDIF && N >= 2
100 :
101 : IF N > 0
102 : B0 = "Bit 0 is on"
103 : Binary = STUFF(Binary,9,1,"1")
104 : ELSE
105 : B0 = "Bit 0 is off"
106 : ENDIF && N > 0
107 :
108 : ? "Printer status reports: "
109 : ?
110 : ? B7
111 : ? B6
112 : ? B5
113 : ? B4
114 : ? B3
115 : ? B2
116 : ? B1
117 : ? B0
118 :
119 : ?
120 : ?
121 : ? "Binary bit pattern -> " + Binary
122 :
123 : ?
124 : ?
125 : ?
126 : ENDIF N = 255 && Port Number Ok?
127 :
128 : WAIT "Press ESCape to exit, any other key to continue . . ."
129 :
130 : * EXIT on ESCape key - otherwise loop through again
131 : IF LASTKEY() = 27
132 : CLEAR
133 : EXIT
134 : ENDIF && LASTKEY() = 27
135 :
136 : ENDDO && WHILE .T.
137 :
138 : ** End of program - Function(s) follow
139 :
140 : **************
141 : FUNCTION PORTCHK
142 : PARAMETER number
143 : PRIVATE flag
144 : IF (number <= 2 .AND. number >= 0)
145 : @ ROW(), COL() + 1
146 : flag = .T.
147 : ELSE
148 : @ ROW(), COL() + 1 SAY "<- INVALID! Printer port range 0-2"
149 : flag = .F.
150 : ENDIF
151 : RETURN (flag)




LISTING 3
---------

Clipper compile:

d:\>clipper prnstat -q -m

Quick-C Compile and Quick-C Link:

d:\>qcl /c /Gs /AL LPTSTAT.C
d:\>link /NOE prnstat LPTSTAT ,,, CLIPPER.LIB EXTEND.LIB

Turbo-C Compile and Link:

d:\>tcc -c -G -N- -f- -ml lptstat.c
d:\>tlink prnstat lptstat,,,CLIPPER.LIB EXTEND.LIB CL.LIB


END ALL

  3 Responses to “Category : Files from Magazines
Archive   : DBMS0790.ZIP
Filename : HEAD.JUL

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/