To order Alpha Four or Alpha Five, click above to go directly to Alpha, or call 800.451.1018 or 781.229.4500

             

Tuesday, October 1, 2002 VOLUME 1 ISSUE 8  
HOME
TOPICS
News & Notes
Learn Alpha Five
Tech Corner
ARTICLES
Creating Web Links with Version 5
Conditional Objects - #101
Creating Web Links with Version 5
by Bill Warner

Create Web Links with Version 5

This will be the first in a series of articles covering one of the new features available in Version 5.  Each article will be a how-to guide for using the new feature, with an example of it's use.  

Since this issue has the new Archive Index, I wanted to see if I could create a web page in V5 that would have links to all the previous articles.  To do this, I'll use the feature that allows the user to create a report and save it in HTML format.  Note that the procedure for creating RTF or PDF files is essentially the same.

I'll divide the article into two sections; creating the HTML output, and then I'll explain the details of how I created the links.

CREATING AN HTML DOCUMENT FROM A REPORT

There are actually a couple different ways to create the document.  I started by creating a report, then printing it using the HTML printer driver.  However, I found an easier way to do it.  Since I don't need to see the report at all (other then previewing it during development), I used a new Xbasic method; report.saveas.

To do this, I created an Xbasic script attached to a button called Print (note that you can also do this with Action Scripting).  This is where I found another neat new feature; the Xbasic Autofill.  As soon as I typed the first part of the command (including the left parenthesis), the following window appeared:



This was great, because it prompted me for the necessary parameters.  Note that the layout name is highlighted.  This is telling me which parameter to insert.  As I finished each parameter, the highlight would move, so I knew what to put in next.  Please note that you have to put in all the parameters; if one is blank, just put in open and closed quotes.  Here's the script to generate the HTML file from the ARCHIVE report:

report.saveas("archive","html","","desc","c:\archdesc.htm","")

When I click the button, I see a brief message telling me the file is being created, and then it's done.  And, sure enough, ARCHDESC.HTM is indeed in the C: folder.  How easy is that??

CREATING HTML LINKS

For those of you unfamiliar with HTML, a link can be inserted in a web page, so you can click on the link and go to another web page.  You clicked on a link ([Full Story]) to get to this article.

A link is defined by a command that looks like this:

<a href="http://www.companyname.com/link.htm">Click Here</a>

So I had to come up with a way to put this into my report, so the resulting HTML would give me a working link.  I studied the HTML from a test report, and discovered that a command that HTML uses to print a space (&#34;) was inserted between every word.  Well, this meant that if I defined a calc field for the link, the a href would end up a&#34;href, and this would not be recognized by HTML as a valid link.

So, I decided to "trick" the HTML by inserting a tilde (~) in place of the space, and then after the HTML was generated, I went to my HTML editor1 and did a global search and replace, finding the tilde and replacing it with a space (I decided on this character because it is hardly ever used).

Next, I had to accommodate the quotation marks in the expression.  Since I was using a calc field to define the link, I couldn't use quotes directly.  Instead, I used CHR(34), which will produce a quote.

The last step was to incorporate the field names from my table in the calc expression.  I used the field TITLE to display the words that will appear as the link (the underlined words that you can click on), and the field TARGET as the name of the file that the user would see when clicking on the link.  Here's how the calc expression looks in the HTML document:

"<a~href="+CHR(34)+"http://www.companyname.com/"+TRIM(TARGET)+CHR(34)+">"+TRIM(TITLE)+"</A>"

And here's how it looks on the web page after replacing the tilde with a space:

TITLE

When you do this, remember that the calc expression will be quite long, so make sure you format the field for a lot of characters.  Then play with it and fine-tune it so it looks the way you want.


[PRINTER FRIENDLY VERSION]

Powered by iMakeNews.com