Creating Html Pages on the Fly Using Avenue

Caitlin Dempsey

Updated:

You can use Avenue to write html code in order to create html pages on the fly. In the Avenue code below I wrote a script that would allow me to send the multiple images as a result of a hotlink selection to an html page created within this script.

The need to write this script originally arose from a hotlinking project. Photos of business signs had been collected from field surveys. Information about the signs was also collected along with the physical location of the stores.

As many of the stores were located in strip malls, multiple businesses could occur at the same point. A simple hotlinking function could result in over twenty popup windows of the sign pictures! This may viewing of the store signs tedious and confusing.

The solution was to create a hotlinking script that would send the pictures along with some information culled from the attribute table. The result in one html file containing all the photos as well as the supplemental information listed from the selected fields.

The viewer can easily scroll through browser to find the necessary information. In the tradition hotlink method, the viewer would have to open and close multiple windows without any guidance from listed attribute information.



Free weekly newsletter

Fill out your e-mail address to receive our newsletter!
Email:  

By entering your email address you agree to receive our newsletter and agree with our privacy policy.
You may unsubscribe at any time.



Some Avenue terminology is defined below to make this script easier to read.ReturnUserPoint
This command returns the point clicked on the display.System.execute
This request launches batch or executable files. It is the command used to open Internet Explorer in this example.

WriteElt
This writes character strings to a text file. The text string is passed to the file within quotation marks.

‘BEGIN SCRIPT

‘This set of Avenue script sets up the theme and fields from the attribute table to be used.’Make sure the hotlink theme is the first and active theme in your legend list.theView = av.GetActiveDoc

theTheme = theView.GetThemes.Get( 0 )

theFtab = theTheme.GetFtab

theLink=theFtab.FindField(“photoxxx”)

theName=theFtab.FindField(“bus_name”)

theSign=theFtab.FindField(“Sign_ID”)

siteNumber=theFtab.FindField(“st_number”)

siteName=theFtab.FindField(“st_name”)

siteSte=theFtab.findField(“ste_num”)

‘This returns the point clicked on the screenpnt = theView.GetDisplay.ReturnUserPoint ‘This code sets the selections based on the point – the selection tolerance is also designated which in this case is 50.thePick = TheFTab.SelectByPoint(pnt, 50, #VTAB_SELTYPE_NEW)theBitmap = TheFtab.GetSelection

‘This line of code sets the name of the html file. I chose to name the file based on a timestamp. The “m s” are used to set the file using the system time in the form of minutes and seconds.theImageFile = Date.Now.SetFormat(“m s”).asString ‘This sets the file location as well as adds the extension “.htm” to the end of the filename.theHtmlFile =FileName.Make(“g:\cmd\signs\avtemp\”+theImageFile.AsString)theHtmlFile.SetExtension(“htm”)

theFTab.UpdateSelection

‘Now it’s time to construct the html file – for this html code is needed. These lines set up the header html code that set the html file.htmlfile = LineFile.Make( theHtmlFile, #FILE_PERM_WRITE )htmlfile.WriteElt(“<HTML><HEAD></HEAD><BODY>”)

‘From the selected points of the coverage the attribute information is now collected. This is a loop function that retrieves the selected values in this section and writes them to the html file in the following section.for each l in theBitmaplinkinfo = theFTab.ReturnValue(theLink, l)

theFile = “g:\cmd\signs\images\” + linkinfo

nameinfo = theFtab.ReturnValue(theName, l)

signinfo = theFtab.ReturnValue(theSign, l)

sitenuminfo = theFtab.ReturnValue(siteNumber, l)

sitesnameinfo = theFtab.ReturnValue(siteName, l)

steinfo = theFtab.ReturnValue(siteSte, l)

‘Now the html code is written inputting the information collected from the selected points.htmlfile.WriteElt(“<P><IMG SRC='” + theFile + “‘HEIGHT=480 WIDTH=640> “)htmlfile.WriteElt(“<BR> “)

htmlfile.WriteElt(“<BR>” + “Business:” + ” ” + nameinfo)

htmlfile.WriteElt(“<BR>” + sitenuminfo.AsString + ” ” + sitesnameinfo.AsString + ” ” + steinfo.AsString)

htmlfile.WriteElt(“<BR>” + “Sign ID:” + ” ” + signinfo.asstring)

htmlfile.WriteElt(“<BR>” + “Filename:” + ” ” + linkinfo)

htmlfile.WriteElt(“<HR SIZE=5 WIDTH=100%>”)

end

‘The footer html code is written and the file is closed.htmlfile.WriteElt( “</BODY></HTML>”)htmlfile.Close

‘Now with the system.execute function the newly created html file is open using Internet Explorer. To launch your browser find the location of the executable and add it to the code in the appropriate place.system.execute(“C:\program files\internet explorer\iexplore.exe ” + theHtmlFile.AsString)’END OF SCRIPT

Add this compiled script as a tool button to your View to execute.

Related Features:

Using ArcView with Access
Avenue is a great tool for adding functionality to ArcView 3x. This article runs through two sets of code for using Avenue programming to work with Microsoft Access databases.

Thirty Tips and Tricks for Programming in Avenue
Chockfull of advice on better avenue programming. From GIS programmer Marco Morais.

Photo of author
About the author
Caitlin Dempsey
Caitlin Dempsey is the editor of Geography Realm and holds a master's degree in Geography from UCLA as well as a Master of Library and Information Science (MLIS) from SJSU.