![]() |
How redirect PRINT to the printer how makes LPRINT? - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: How redirect PRINT to the printer how makes LPRINT? (/showthread.php?tid=886) |
How redirect PRINT to the printer how makes LPRINT? - maeloterkim - 07-21-2019 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 Re: How redirect PRINT to the printer how makes LPRINT? - boriel - 07-23-2019 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. Re: How redirect PRINT to the printer how makes LPRINT? - maeloterkim - 07-23-2019 Hi ![]() 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 RE: How redirect PRINT to the printer how makes LPRINT? - .fito. - 01-14-2023 (07-23-2019, 02:46 PM)hi mate. did you manage to solve the problem? Your function works perfectly although with the problem you say. You can't mix the PRINT function with CALL 8252 because it corrupts the printout. I have tried to change the channel to try to restore the flow to the screen but it doesn't work. Wrote: I also modified one of the arguments of the function RE: How redirect PRINT to the printer how makes LPRINT? - boriel - 01-14-2023 PRINT does not deal with the ROM. It's an entirely new subroutine made in assembler. It should not interfere with this. Also. if the IX register is changed, it must be preserved (PUSH IX / POP IX) before calling the ROM with CALL 5633 or CALL 8252. Did you manage to make it work? |