Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How redirect PRINT to the printer how makes LPRINT?
#1
How redirect PRINT to the printer? how makes LPRINT?

HI

Is possible redirect the output of the PRINT to the printer ?

Something like
PRINT #3; "This go to the printer"
that print on the printer

or something like
OPEN #4, "p"
that redirects the channel four to the printer and after this we can do

PRINT #4; "This go to the printer"

Is there some "easy way" to do that with the ZX basic ?

Maybe there are some library that makes the LPRINT of the ZX spectrum

Thanks
Reply
#2
No, there is not such thing.
Someone could make a library (or you can point me to an existing one I can port to ZX Basic), and I'll include it with ZX Basic.
Reply
#3
Hi Smile

I tried this program below, that works if i don't use PRINT instruction. I don't know why

There is a note on the program next to the PRINT instruction

maybe is a workaround wiith the compiling or something and streams

If i try directly with the s$ variable with @s$ the zx spectrum resets itself

I don't know how access to the memory address of the s$ for sending directly to the LPRINT routine

For this i did a intermediate variable printerStringBuffer that seems "to work" if i don't use PRINT

Maybe you can adjust to do a little library file with this example

You can try with the print and without the print for example on ZX Spin

You must first open the ZX printer output on ZXSpin, before running the example to see the output

This is good for example for debugging big list of numbers that don't fit on one screen


----------------------------------------------------------------------------------------------------------


' ROUTINE FOR TEST LPRINT

' PROGRAM BEGIN HERE

bufferPrinter:
DIM printerStringBuffer (32) AS UBYTE ' Buffer FOR PRINT 32 BYTES LINES

CLS ' CLEAR SCREEN

' TEST LPRINT
s$ = "PRINTER Routine Example"
printStringOnChannel(3, s$ , @printerStringBuffer(0))

' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' If I put the following print the program does not work. Just do, the screen print.
' I don't know why. But if I don't put the print it works
' Just uncomment the print instruction to see it
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

' PRINT "LPRINT done"



STOP ' PROGRAM END HERE


' SUBROUTINES BEGIN HERE

' SUBROUTINE THAT OPENS CHANEL 3 FOR LPRINT
' CHANNEL = 3 FOR "p" => "PRINTER"
SUB fastcall printOnChannel ( channel AS UBYTE, bufferAddress AS UINTEGER , lengthString AS UINTEGER )
ASM
;' A = CHANNEL CHOOSE
CALL 5633 ;' SelecT CHANNEL

POP HL ;' Return Address
POP DE ;' String Address
POP BC ;' String Length
PUSH HL ;' Save Return Address

CALL 8252 ;' print our string on the channel

END ASM
END SUB


' SUBROUTINE THAT COPY STRING s$ TO printerStringBuffer AND ADD END OF STRING
SUB stringToBuffer( text AS STRING, bufferAddress AS UINTEGER )

DIM index AS UBYTE

FOR f = 0 TO LEN (text) - 1
POKE ( bufferAddress + f ) , CODE ( text ( f ) )
index = f
NEXT f

POKE (bufferAddress+index+1),0 ' END of string

END SUB

' SUBROUTINE THAT Print a string on printer max length 31 characters
SUB printStringOnChannel(numChannel AS UBYTE, text AS STRING, bufferAddress AS UINTEGER)

' put the string on the buffer
stringToBuffer( text, bufferAddress )

' LPRINT string buffer
printOnChannel ( 3, bufferAddress , LEN(text) )

END SUB

' SUBROUTINES END HERE
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)