New Sample - How to create a text or HTML file for printing in DataEase 8 (Ver. 8.0.0.1308)
DataEase for Windows has been a nightmare when it comes to exporting and printing. It seems that this basic need has eluded the high and mighty ;-)
Not so anymore. Popular demand has forced our hand and we have spent some hours creating a small sample to give you an idea on how you can achieve this with DataEase 8 "Native".
The functions we use to achieve this is: MemoWriteToFile(), WriteToFile(), Chr(), MemoExecDQL(), PrintHtml() etc.
So maybe we should start with the results to get you interested:
define temp "retval" text .This is the DQL that generate the text document.
define temp "spacer" text 255 .
define temp "line" text 69 .
spacer :=" " .
line := "-------------------------------------------------------------------------------------------------------------------------" .
for WriteToFile with OrderNr = Data-entry Field1 ;
retval := MemoWriteToFile( Header, data-entry field2, 1) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) . . -- Line Change, will be uncessary when we update WritToFile an MemoWriteTofile with option 4 and 5. CR before Append or after Insert.
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(Subject,data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval :=WriteToFile(concat("Productnr",chr(9),"Product Description",chr(9),chr(9),chr(9),"Price",chr(9),chr(9),"#",chr(9),"Total",chr(10),chr(13)), data-entry field2,0) .
retval := WriteToFile(line,data-entry field2, 0) .
for Orderlines with Ordernr = WriteToFile Ordernr ;
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(concat(productNr,chr(9),firstc(concat(Description,spacer),30),chr(9),lastc(concat(spacer,Prices),8),chr(9),lastc(concat(spacer,Count ),3),chr(9),lastc(concat(spacer,Total),10)),data-entry field2, 0) .
end
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(line,data-entry field2, 0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(lastc(concat(Spacer,"Total Order: ", Total Order),69),data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(line,data-entry field2, 0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := MemoWriteToFile(Footer,data-entry field2, 0) .
define temp "retval" text .
for WriteToFile HTML Version with OrderNr = Data-entry Field1 ;
retval := MemoWriteToFile( Header, data-entry field2, 1) .
retval := WriteToFile("<br>",data-entry field2,0) . -- Line Change, will be uncessary when we update WritToFile an MemoWriteTofile with option 4 and 5. CR before Append or after Insert.
retval := WriteToFile(concat("<h2>",Subject,"</h2>"),data-entry field2,0) .
retval := WriteToFile("<table><tr><th>Productnr</th><th>Product Description</th><th>Price</th><th>#</th><th>Total</th></tr>",data-entry field2,0) .
for Orderlines with Ordernr = WriteToFile HTML Version Ordernr ;
retval := WriteToFile(concat("<tr><td width=",chr(34),"100",chr(34),">",productNr,"</td><td width=",chr(34),"300",chr(34),">",Description,"</td><td width=",chr(34),"150",chr(34)," align=",chr(34),"right",chr(34),">",Prices,"</td>"),data-entry field2, 0) .
retval := WriteToFile(concat("<td width=",chr(34),"50",chr(34)," align=",chr(34),"right",chr(34),">",Count ,"</td><td width=",chr(34),"150",chr(34)," align=",chr(34),"right",chr(34),">",Total,"</td></tr>"),data-entry field2, 0) .
end
retval := WriteToFile("</table>",data-entry field2,0) .
retval := WriteToFile(concat("<p align=",chr(34), "right" , chr(34) ,"><b>Total Order: ", Total Order, "</b></p>"),data-entry field2,0) .
retval := MemoWriteToFile(Footer,data-entry field2, 0) .