What works for me is to design a template document using any html editor
this way your basic code doesn't know or care about formatting and any
changes to the html document is program independent. 

In the variable data in the document is represented as place holders
using a leading and trailing && such as this:

.....[snippet from a working template]....

<table bgcolor="#FFCCCC" width="100%"><tr><td>
<dl style="font: small">
        <dt>Customer Comments:</dt>
        <dd>&&CUSTOMERCOMMENTS&&</dd>
        <dt>Order Comments:</dt>
        <dd>&&ORDERCOMMENTS&&</dd>
        </dl>
</td></tr>
</table>

<table border="1" style="border: thin; empty-cells: show" width="100%"
cellspacing="0" cellpadding="0">
        <tr bgcolor="silver" style="text-align: center; font: small">
                <td >Model</td>
                <td >Description</td>
                <td >Color</td>
        </tr>
<!-- All of the data for an order must remain physically on one single
line in the template -->
<!-- So we can pull the order table line from the html template as one
single field in Universe -->
<!-- ORDER LINES
--><tr><td>&&MODEL&&</td><td>&&DESCR&&</td><td>&&COLOR&&</td></tr>
</table>

.....[end of snippet].....

Using the above template designed using AceHTML Pro (any html editor
will do) we can change the formatting of the document using the html
editor without ever changing basic code... Plus we don't have to worry
about html syntax being correct in the BASIC code, because the basic
code has no concept of HTML imbedded into it.  

For simplicity sake, we use the same variable name in the template as
the variable name in the BASIC code.

The BASIC code to replace the data in the template looks something like
this:

....[begin of basic code snippet]....

      NB="&nbsp;"

      IF TRIM(CUSTOMERCOMMENTS)='' THEN CUSTOMERCOMMENTS=NB
 
TEMPLATE=EREPLACE(TEMPLATE,"&&CUSTOMERCOMMENTS&&",CUSTOMERCOMMENTS)

      IF TRIM(ORDERCOMMENTS)='' THEN ORDERCOMMENTS=NB
      TEMPLATE=EREPLACE(TEMPLATE,"&&ORDERCOMMENTS&&",ORDERCOMMENTS)

*     find where the order line  is found in the template

      FINDSTR "<!-- ORDER LINES -->" IN TEMPLATE SETTING ORDER.LINE ELSE
NULL

*     hold on to a copy of the order line template      
      LINE.ITEM.TEMP=TEMPLATE<ORDER.LINE>

*     go through the order arrays and populate the table

      RETURN.HTML=''
      FOR LINE.ITEM.POINTER=1 TO LINE.ITEM.COUNT
*        get a pristine copy of the order line html
         LINE.ITEM=LINE.ITEM.TEMP

         IF TRIM(MODEL<LINE.ITEM.POINTER>)='' THEN
MODEL<LINE.ITEM.POINTER>=NB
 
LINE.ITEM=EREPLACE(LINE.ITEM,"&&MODEL&&",MODEL<LINE.ITEM.POINTER>)

         IF TRIM(DESCR<LINE.ITEM.POINTER>)='' THEN
DESCR<LINE.ITEM.POINTER>=NB
 
LINE.ITEM=EREPLACE(LINE.ITEM,"&&DESCR&&",DESCR<LINE.ITEM.POINTER>)
        
         IF TRIM(COLOR<LINE.ITEM.POINTER>)='' THEN
COLOR<LINE.ITEM.POINTER>=NB
 
LINE.ITEM=EREPLACE(LINE.ITEM,"&&COLOR&&",COLOR<LINE.ITEM.POINTER>)

         RETURN.HTML<-1>=LINE.ITEM
     NEXT LINE.ITEM.POINTER
 
    TEMPLATE<ORDER.LINE>=RETURN.HTML

....[end of basic code snippet]....

We use is the activeX component of the web browser imbedded into a
wIntegrate dialog box to pull the html in.  

The user has no idea they're looking at an html document, they just see
a nicely formatted report in the dialog box.
 


-----Original Message-----
From: Mark Johnson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 05, 2004 11:09 PM
To: U2 Users Discussion List
Subject: Re: Format Text in Output Data File


I must be missing something. How is creating HTML simpler than CSV for
simple tables.. I may be wrong but i've gotten hung up on the
<head>-like overhead before i can get to the cells. I would like to
learn more if this is an easier way especially if i can export
formatting. Any code examples would be nice.

thanks.
----- Original Message -----
From: "Ian McGowan" <[EMAIL PROTECTED]>
To: "U2 Users Discussion List" <[EMAIL PROTECTED]>
Sent: Thursday, February 05, 2004 10:38 AM
Subject: RE: Format Text in Output Data File


> On Thu, 2004-02-05 at 07:08, Peter Olson wrote:
> > you might want to check out sylk files. not exactly as simple as 
> > .csv but but easier then .xls (?) you should be able to add 
> > style.... maybe search the archive.... i remember someone had a 
> > subroutine...
>
> i posted a routine to create sylk files from a uniquery, but agree 
> with all the other comments recommending html - it's much easier to 
> deal with nowadays...
>
> ian
> --
> Ian McGowan <[EMAIL PROTECTED]>
>
> --
> u2-users mailing list
> [EMAIL PROTECTED] http://www.oliver.com/mailman/listinfo/u2-users

-- 
u2-users mailing list
[EMAIL PROTECTED] http://www.oliver.com/mailman/listinfo/u2-users
--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users

Reply via email to