07-12-2022, 03:11 PM
Hi, I have just recently found my program needs to print out some of the results on paper. I much prefer to print to the screen however now find I can compare present results better if I had a printed copy of the past results. I was sure I'd be able to search our site for hints on this topic but wasn't able to find a clue as to what I'm missing in the code I have picked up from the WIKI.
If you can see where I may be going wrong, thanks in advance for your help. This code I'm using is printing a BLACK page on my printer and I can't tell if it is printing the test phrase or not.
If you can see where I may be going wrong, thanks in advance for your help. This code I'm using is printing a BLACK page on my printer and I can't tell if it is printing the test phrase or not.
Code: (Select All)
'NOTE: THIS ROUTINE DOESN'T WORK ... SUPPOSTED HAVE A WHITE BACKGROUND BUT GETTING AN ALL BLACK INK PAGE
'Printing on the Printer - an example using "_PrintImage" command
'Assumes a menu where an option to print to printer is the letter "p" or "P"
DIM img AS LONG
DIM Page AS LONG
PageScale = 10
PageHeight = 297 * PageScale
PageWidth = 210 * PageScale
Page& = _NEWIMAGE(PageWidth, PageHeight, 32)
a$ = "P"
Text$ = "The Rain in Spain falls mainly in the Plain."
PRINT
PRINT
PRINT Text$ 'This text is printing to the screen ok
IF a$ = "p" OR a$ = "P" THEN
IF img& <> 0 THEN _FREEIMAGE (img&)
_DEST Page& ' This is meant to capture the PRINTER data, making the size of the print the same size as the typical paper found in the printer and set the focus to the printer
CLS , _RGB32(255, 255, 255) ' Insterestingly, this CLS does not Clear the computer screen but setting the RGB color to white seems to NEED Cls plus the comma, _RGB(255,255,255) on it's own generates an error
' according to the _PRINTIMAGE wiki , this line sets a white background
'.....I think things go wrong from here on down. .....
_DEST 0 ' This is supposed to set the focus on the computer screen
_PRINTSTRING (1, 1), Text$ 'This re-writes the phrase to the computer screen, so the phrase is written once at line 22 and again here
img& = _COPYIMAGE(0) ' This is supposed to capture the computer screen where the phrase is written twice
_PRINTIMAGE img& ' this command is supposed to send the img just captured to the printer
_DELAY 5
END IF