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

[REBOL] Re: Printing with Rebol on Windows network

From: al:bri:xtra at: 22-Aug-2002 20:24

Greg claimed:
> A thought for the list. (I know you can not do this in Rebol.) > > To print html pages to a printer eg. invoices, group letters....
I'll just design a Rebol CGI script, then launch a browser, and print from that! Here's a script that does just that. It requires my ML and CSS dialects (and a high school database). This script will print out class lists of pupils to a browser, and enables the user to choose an appropriate orientation, and by modifying the URL (or clicking the Back button) change some parameters appropriately. Andrew Martin Rebol *CAN* do that! :) ICQ: 26227169 http://valley.150m.com/ -><- #! C:\Rebol\View\rebol.exe -cs Rebol [ Name: 'ClassList Title: "Class List" File: %ClassList.r Author: "Andrew Martin" eMail: [Al--Bri--xtra--co--nz] Web: http://valley.150m.com Date: 7/August/2002 Version: 1.2.0 Purpose: {Creates class lists for teachers.} Category: [util net markup 5] ] Stylesheet: %Wiki.css Subjects: sort load %/C/Rebol/MUSAC/Subjects.txt Forms: sort load %/C/Rebol/MUSAC/Forms.txt Years: sort load %/C/Rebol/MUSAC/Years.txt Command: all [ "GET" = Rebol/options/cgi/request-method string? Rebol/options/cgi/query-string not empty? Rebol/options/cgi/query-string make object! decode-cgi Rebol/options/cgi/query-string ] if all [ object? Command in Command 'Partition "on" Command/Partition any [ in Command 'Subject in Command 'Form in Command 'Year ] in Command 'Period parse Command/Period [digits end] Command/Period: load Command/Period in Command 'Points parse Command/Points [digits end] Command/Points: load Command/Points ] [ Partition: none Pupils: load %/C/Rebol/MUSAC/Pupils.txt Columns: Pupils/1 Rows: Pupils/2 Intersections: Pupils/3 IncludeLeavers: all [ in Command 'Leavers "on" = Command/Leavers ] Title: any [ all [ in Command 'Subject PartitionColumn: index? find Columns to-string Command/Subject/1 Partition: next Command/Subject ] all [ in Command 'Form PartitionColumn: index? find Columns "Form" Partition: Command/Form ] all [ in Command 'Year PartitionColumn: index? find Columns "Year" Partition: load Command/Year ] "No Assigned Form Class!" ] TitleValues: [ "Preferred" "Family Name" "Form" ] for TitleValue 1 length? TitleValues 1 [ change at TitleValues TitleValue index? find Columns TitleValues/:TitleValue ] Class: make block! 500 any [ Partition Partition: "" ] StatusColumn: index? find Columns "Status" for Row 1 length? Rows 1 [ if all [ Partition = select Intersections make pair! reduce [PartitionColumn Row] Status: select Intersections make pair! reduce [StatusColumn Row] any [ #"F" = Status #"P" = Status all [ IncludeLeavers #"L" = Status ] ] ] [ foreach TitleValue TitleValues [ append Class select Intersections make pair! reduce [TitleValue Row] ] ] ] sort/skip/compare Class 3 2 content-type 'text/html print newline print ML compose/deep [ <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> html [ title (Title) style/type/media "text/css" "screen,print" [ "<!--^/" ( CSS compose/deep [ [h1 p table] [ margin: 0 px ] td [ font-size: (Command/Points) pt margin: 0 px ] td.Grid [width: 1.5 em] p + h1 [page-break-after: always] ] ) "//-->" ] ] body [ h1 (Title) ( use [Row Rows] [ Rows: make block! 2 * 500 Row: make block! 100 foreach TitleValue TitleValues [ append Row compose [ th (Columns/:TitleValue) ] ] loop Command/Period [ append Row compose [th/class "Grid" ("&nbsp;")] ] append Rows reduce ['tr Row] while [not empty? Class] [ Row: make block! 100 for TitleValue 1 length? TitleValues 1 [ append Row compose [ td (Class/:TitleValue) ] ] loop Command/Period [ append Row [td/class "Grid" "&nbsp;"] ] repend Rows ['tr Row] Class: skip Class length? TitleValues ] compose/deep [ table/border/bordercolor/cellspacing 1 "black" 0 [ (Rows) ] ] ] ) p [ b "Number of Pupils" ": " (/ length? head Class length? TitleValues) "." ] ] ] quit ] Title: Rebol/script/header/Title Idn: "Partition" content-type 'text/html print newline print ML compose/deep [ <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> html [ head [ title (Title) link/rel/type/href "stylesheet" "text/css" (Stylesheet) script/language "JavaScript" { function Able (Object) { document.forms[0].Subject.disabled=true; document.forms[0].Form.disabled= true; document.forms[0].Year.disabled= true; Object.disabled= false; document.forms[0].Submit.disabled= false; } } ] body [ div/id "Center_Column" [ h1 (Title) form/method/action "GET" (Rebol/script/header/file) [ fieldset [ legend "Dimensions" fieldset/style "display: inline" [ legend "Vertical" p/class "Initial" "Click radio button to select: input/type/id/name/onclick radio" (Idn) (Idn) Able (Subject) label [ "Subject: " select/name/disabled "Subject" disabled [ ( use [Options] [ Options: make block! length? Subjects foreach Subject Subjects [ append Options compose [ option (Subject) ] ] Options ] ) ] ] br input/type/id/name/onclick "radio" (Idn) (Idn) Able (Form) label [ "Form: " select/name/disabled "Form" disabled [ ( use [Options] [ Options: make block! length? Forms foreach Form_Class Forms [ append Options compose [ option (Form_Class) ] ] Options ] ) ] ] label [ input/type/name "checkbox" "All_Forms" "All" ] br input/type/id/name/onclick "radio" (Idn) (Idn) Able (Year) label [ "Year: " select/name/disabled "Year" disabled [ ( use [Options] [ Options: make block! length? Years foreach Year Years [ append Options compose [ option (Year) ] ] Options ] ) ] ] label [ input/type/name "checkbox" "All_Years" "All" ] br ] fieldset/style "display: inline" [ legend "Horizontal" label [ "Columns: " select/name "Period" [ option/value 0 "None (0)" option/value 7 "Week (7)" option/value 14 "Fortnight (14)" option/value 33 "Subject Term (33)" option/value 60 "Term (60)" option/value 24 "Form folder (24)" ] ] ] fieldset/style "display: inline" [ legend "Font Size" label [ "Points: " select/name "Points" [ option 6 option/selected "selected" 8 option 10 option 12 option 14 option 16 option 18 ] ] ] ] label ["Include leavers: " input/type/name "checkbox" Leavers ] input/type/id/value/disabled "submit" "Submit" "Show Class List" "disabled" ] ] ] ] ]