| Subject |
Re: printer paper source |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Wed, 12 Aug 2020 15:29:53 +0200 |
| Newsgroups |
dbase.getting-started |
| Attachment(s) |
paperbin.prg |
On 2020-08-12 13:44, Mustansir Ghor wrote:
> Dear Mervyn Sir
>
> Can you put again in the thread latest Paperbin.cc woking program, I have somehow lost last thread link.
>
paperbin.prg is attached. papersize.prg is in the dUFLP.
Mervyn.
| /*
PaperBin.prg
This a direct copy of PapeSize.prg posted by Rick Miller with the necessary
changes so as to be able to identify the available paper sources.
2020-08-09 Mervyn Bick
This program will return the binName and PapeBin information
for the default printer. The number returned for each option
could then be used for a report. This is really not a production
program, but meant to be used by a developer to help as needed.
Output is to the output pane of the Command Window.
Usage:
do :dUFLP:PapeBin
or to use a printer other than the default, you would need
to know the name of the printer:
cPrinter = "HP LaserJet 1020"
do :dUFLP:PapeBin with cPrinter
Includes:
getBins()
getPrinterDefault()
*/
#define DC_PAPERNAMES 16
#define DC_PAPERS 2
#define DC_BINNAMES 12
#define DC_BINS 6
#define ZEROS(n) replicate(chr(0), n)
parameters cDevice
initExterns()
if not type("argVector(1)") == "C"
cDevice := getPrinterDefault()
// ? cDevice // moved out of if...endif MB 2020-08-10
endif
? cDevice
local a, i
a = getBins( cDevice, "")
for i = 1 to int((a.size + 1) / 2)
? a[i, 2]
?? " - "
?? a[i, 1]
endfor
return
//------------------------------------------------------------//
// return a 2 column array of paper bins for a printerName.
// column 1 = binName <char>,
// column 2 = PapeBin <int>.
function getBins(cDevice, cPort)
local aRet, cName, i, ii, lpDevMode, nPair, nWord,;
sPaperName, sPapeBin
lpDevMode = 0
// get the number of PapeBin/paperName pairs.
nPair = RMM_DeviceCapability(;
cDevice,;
cPort,;
DC_BINS,;
null,;
lpDevMode)
if nPair > 0
// create empty PapeBin buffer of proper length.
sPapeBin = ZEROS(nPair * 2)
// fill the PapeBin buffer.
RMM_DeviceCapability(;
cDevice,;
cPort,;
DC_BINS,;
sPapeBin,;
lpDevMode)
// create empty paperName buffer of proper length.
sPaperName = ZEROS(nPair * 24)
// fill the paperName buffer.
RMM_DeviceCapability(;
cDevice,;
cPort,;
DC_BINNAMES,;
sPaperName,;
lpDevMode)
// create the return array.
aRet = new array(nPair, 2)
for i = 0 to nPair - 1
// loop through and assign the array values.
// store the PapeBin number into nX.
nWord = getWord(sPapeBin, i * 2)
cName = ""
for ii = 0 to 23 //63
// loop through reading the paperName buffer.
if sPaperName.getByte((i * 24) + ii) == 0
// ran into a string terminator.
// assign ii to exit the loop.
ii := 24
else
// add the character to c.
cName += chr(sPaperName.getByte( ;
(i * 24) + ii))
endif
endfor
// assign the pair to a row in the array.
aRet[i + 1, 1] = cName // paperName.
aRet[i + 1, 2] = nWord // PapeBin.
endfor
else
aRet = new array()
endif
return aRet
//------------------------------------------------------------//
// return the windows default printer as a string.
function getPrinterDefault
Local sBuff, cRet, nLen
sBuff = ZEROS(250)
nLen = RMM_GetWinIniString( ;
"windows", "device", ;
",,,", sBuff, sBuff.length)
cRet = sBuff.left(sBuff.indexOf(","))
return cRet.rightTrim()
//------------------------------------------------------------//
// return a WORD from the string sValu starting at nByte.
function getWord(sValu, nByte)
return int(sValu.getByte(nByte) + ;
bitlshift(sValu.getByte(nByte + 1), 8))
//------------------------------------------------------------//
function initExterns
if not type("RMM_DeviceCapability") == "FP"
extern CINT RMM_DeviceCapability( ;
CSTRING, CSTRING, CWORD, CPTR, CPTR);
winspool.drv from 'DeviceCapabilitiesA'
endif
if not type("RMM_GetWinIniString") == "FP"
extern CULONG RMM_GetWinIniString( ;
CSTRING, CSTRING, CSTRING, CSTRING, CULONG);
kernel32 from "GetProfileStringA"
endif
return
// end of file: PapeBin.prg
|
|