Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Printing in REBOL

 [1/5] from: rphilipp:suffolk:lib:ny:us at: 14-Jan-2001 22:04


Hi, Someone had posted a reply to my inquiry about printing or re-directing output to a printer in Dos/Windows. I can't find the message but they mentioned that the amiga in affect maps i/o ports as files. I think it was someone in support. Thanks for your help, I've been able to redirect output directly to a printer from REBOL/View using the scheme: example:
>> a: "Hello,World!" >> write %lpt1 a
end example. This outputs to my printer but I have to manually eject the paper. I need to know how to send out special characters like LF's to my printer via REBOL. If any body knows how let me know. I'm still searching thru REBOL documentation. I may need to send HEX characters or something. Robert P.

 [2/5] from: al::bri::xtra::co::nz at: 15-Jan-2001 16:27


[ REBOL [ Name: 'Printer Title: "Printer" File: %"Printer.r" Home: http://members.nbci.com/AndrewMartin/Rebol/Enhancements/ Author: "Andrew Martin" eMail: [Al--Bri--xtra--co--nz] Date: 17/October/2000 Version: 1.0.0 Enhancement: 'Printer Example: [ Printer "This goes to the printer!" Printer/Page "This prints this line and feeds a page!" ] ] Printer: func [ "Sends text to printer on //prn." [catch] Text [string!] "The text to be printed." /Page "Append Carriage Return (CR) and Page Feed." ][ throw-on-error [ secure [ %//prn [allow write] ] write %//prn Text if Page [write/binary %//prn "^(0D)^(page)"] Text ] ] ] Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [3/5] from: rphilipp:suffolk:lib:ny:us at: 15-Jan-2001 8:38


Thanks Andrew, It works fine but I have a few problems: 1) My printer is on %//lpt1, I've modified the program and it still works fine but.. 2) The << throw-on-error >> is undocumented and it doesn't seem to work. If I take my printer off-line it hangs up REBOL until I fix the problem. If I leave the printer as %//prn it goes back to command line. Is that what the function is suppose to do? 3) I understand this part of the code << secure [ %//prn [allow write] ] >> to mean that it should write automatically without asking, but the program still ask for permission. 4) Where did you get the codes for the printer? Thanks for your help :-) Robert P.

 [4/5] from: al:bri:xtra at: 16-Jan-2001 7:34


Robert wrote:
> It works fine but I have a few problems: > 1) My printer is on %//lpt1, I've modified the program and it still works
fine but.. prn I believe is diverted automatically to the first available printer. Or so I had believed?
> 2) The << throw-on-error >> is undocumented and it doesn't seem to work.
You might need to update your Rebol? See:
>> help throw-on-error
USAGE: THROW-ON-ERROR blk DESCRIPTION: Evaluates a block, which if it results in an error, throws that error. THROW-ON-ERROR is a function value. ARGUMENTS: blk -- (Type: block) You can delete delete 'Throw-on-error (and the square brackets) if it's not available.
> If I take my printer off-line it hangs up REBOL until I fix the problem.
If I leave the printer as %//prn it goes back to command line. Is that what the function is suppose to do? What do you mean by "it" in "it goes back to command line"? The function returns the text it was given?
> 3) I understand this part of the code << secure [ > %//prn [allow write] > ] >> to mean that it should write automatically without asking, but the
program still ask for permission. Rebol asks if it can lower the security level, which is the 'secure word itself.
> 4) Where did you get the codes for the printer? >From studying a book on serial communications, I knew that the form feed
code feeds a new page. The codes are described in the Rebol/Core PDF manual. I append a CR code to cover cases where the last line hasn't got a newline at the end or if Rebol doesn't convert newlines to CR/LF for Windows on writing to a port, or if the printer doesn't formfeed correctly. I hope that helps! Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [5/5] from: rphilipp:suffolk:lib:ny:us at: 15-Jan-2001 18:22


Thanks again for your help Andrew. :-) 1) %//prn does work with your program the << throw-on error >> function works differently in that the program returns to the command line after a printer error(off-line), The program acts as if it had successfully completed even though it didn't print that's the reason I decided to try %//lpt1. 2) << throw-on -error>> is undocumented in both REBOL/Core 2.3.0.3.1 and REBOL/View 0.10.38.3.1 both for Windows98. Which version of REBOL are you using and for what OS? 3) If a function shows as being undocumented does that mean it won't work in the REBOL version your using? Robert P