English

How To: Hotlink in ArcView 3.x

Summary

This document shows how to hotlink to:

  • Documents such as views, tables, charts, and layouts
  • Files such as projects, images, and text files
  • External programs and their files, such as sounds, external viewers, Word documents, and spreadsheets

Procedure

  1. Prepare the table for hotlinking.

    See: How To: Prepare a table for hotlinking
  2. Set theme properties for hotlinking.
    1. Open the view.
    2. Make the hotlink theme active.
    3. Select Properties from the Theme menu.
    4. Select the HotLink icon on the right.
    5. Set FIELD to the attribute field containing the hotlink information.
    6. Set PREDEFINED ACTION to:
      • 'Link to Document' for documents
      • 'Link to User Script' for scripts
      • 'Link to Text File' for text files
      • 'Link to Image File' for support images
      • 'Link to Document' for documents
      • 'Link to Project' for projects
    7. Click OK.
      Note:
      See "Setting up and using hot links" (pages 134 and 135) in the "Using ArcView GIS" book.
  3. Reconfigure for custom hotlinking.

    Hotlink to a view in another project

    1. Select 'Link to User Script' for the 'Predefined Action.'
    2. In the new field type the path to the poject you want to open.
'-- This script hotlinks to another project and then opens the views.
'-- SELF is the path to the project file mentioned in the
'-- feature's hot link field.

theVal= SELF

'-- Make a list of the views that are currently in the project
'-- before importing.

theODL=av.Getproject.getdocs
theOVL=List.Make
for each d in theODL
	if (d.is(View)) then
		theOVL.Add(d)
	end
end

'-- If the hotlink field for the selected feature has no path,
'-- then report a message and exit. Otherwise, convert the SELF
'-- string to a FileName and import the project.

if (theVal.IsNull.not) then
	av.GetProject.Import(theVal.AsFileName)
	else
		MsgBox.Info("This feature has no project mentioned in the table","Error")
	exit
end

'-- Make a list of all the views in the project after importing.

theNDL=av.getproject.getdocs
theNVL=List.Make
for each do in theNDL
	if (do.is(View)) then
		theNVL.Add(do)
	end
end

'-- Compare the new view list to the old view list. Isolate those
'-- that are new, and open them.

theUVL=List.Make

for each v in theNVL
	theNum=theOVL.Find(v)
	if (theNum=-1) then
		theUVL.Add(v)
	end
end

for each uv in theUVL
	uv.getwin.open
end

Hotlink to images not supported by normal hotlink.

  1. In the new field type the path to the image file you want to open.
  2. Click 'Link to User Script' and select your script in the Script box of the Theme Properties.
'-- When used as a hotlink script, the value of the hotlink
'-- field for the chosen feature must be the full pathname to a
'-- raster file format supported by the view document.

theVal = SELF
if (Not (theVal.IsNull)) then
	if (File.Exists(theVal.AsFileName)) then
		srcImage = SrcName.Make(theVal)
		t = Theme.Make(srcImage)
		t.SetVisible(TRUE)
		v = View.Make
		v.AddTheme(t)
		v.SetTOCWidth(0)
		v.SetTOCUnresizable(TRUE)
		v.SetName(theVal.AsFileName.GetBaseName)

		if (av.FindScript("View.CloseImageView") = NIL) then
			s = Script.Make("av.GetProject.RemoveDoc(SELF)")
			s.SetName("View.CloseImageView")
			av.GetProject.AddScript(s)
		end

		v.SetCloseScript("View.CloseImageView")
		'-- If you've created a special GUI for this document,
		'-- activate here using something like this:
		'-- v.SetGUI("aNewGUIName")
		'-- av.FindGUI(v.GetGUI).Activate

		v.GetWin.Open

	else
		MsgBox.Warning("File "+theVal+" not found.","Hot Link")
	end
end

atool = av.GetProject.FindGui("View").GetToolBar.FindByScript("View.Select")
atool.Select

Hotlink to external programs and viewers

You will need to modify the path of .exe in the script as the path to the program varies. Search for the .exe on your computer and substitute the location after the exeString. Common examples:
  • Word - Winword.exe
  • Excel - Excel.exe
  • Music/Video - mplayer.exe
  • PDF - AcroRd32.exe
This script should work for any external program.
'-- Use this script to hotlink a external file
'-- Modify the path to executable to on your machine
linkfile = Self
exeString = "c:\program files\microsoft office\office\winword.exe" ++ linkfile
System.Execute(exeString) 

Hotlink to multiple objects

  1. Place the "View.MultiToolApply" script as the "Apply" script on a new tool.
  2. Set up the "View.MultiThemeProp" script to be run in the theme's Hotlink Theme Properties.
These scripts assume your feature theme attribute table contains three fields. Each one contains the full path name to each image or document that you want to hotlink to. Modify these scripts to suit your needs.
Note:
No hotlink field should be specified in the Theme's Hotlink Properties.
'-- Script: VIEW.MULTITOOLAPPLY
'
'-- This script requires that the CAD Reader extension is turned on.

theView = av.GetActiveDoc
found = FALSE
listofFieldNames = {"BMPfield","Textfield","DWGfield"}
'-- Edit the field names above to match yours
listofValues = {}
p = theView.GetDisplay.ReturnUserPoint
t = theView.GetActiveThemes.Get(0)
	if (t.Is(FTheme))
		then
			found = TRUE
			theFtab = t.GetFTab
			rec = t.FindByPoint(p).Get(0)
				for each f in listofFieldNames
					theVal = theFTab.ReturnValueString(theFTab.FindField(f),rec)
						if (theVal <> NIL)
							then
								listofValues.Add(theVal)
							else
								listofValues.Add("a")
						end
				end
		end
av.Run(t.GetHotScriptName,listofValues)
if (not found)
	then
		System.Beep
end
'-- Script: VIEW.MULTITHEMEPROP
'
theBMPFileName = Self.Get(0)
theTextFileName = Self.Get(1)
theDXFFileName = Self.Get(2)
MsgBox.Info("One moment please..."
	+NL+"Hit OK to continue.","Multi Hotlink")

'-- For BMP Image
if (File.Exists(theBMPFileName.AsFileName))
	then
		theImageWin = ImageWin.Make(theBMPFileName.AsFileName,theBMPFileName)
		else
		MsgBox.Info("There is no Image File","")
end

'-- For Text File
if (File.Exists(theTextFileName.AsFileName))
	then
		theTextWin = TextWin.Make(theTextFileName.AsFileName,theTextFileName)
else
	MsgBox.Info("There is no Text File","")
end

'-- For DXF drawing
if (File.Exists(theDXFFileName.AsFileName))
	then
		srcDrawingLine = SrcName.Make(theDXFFileName ++ "line")
		srcDrawingPoint = SrcName.Make(theDXFFileName ++ "point")
		srcDrawingPoly = SrcName.Make(theDXFFileName ++ "polygon")
		srcDrawingAnno = SrcName.Make(theDXFFileName ++ "annotation")
		tPoly = Theme.Make(srcDrawingPoly)
		tLine = Theme.Make(srcDrawingLine)
		tPoint = Theme.Make(srcDrawingPoint)
		tAnno = Theme.Make(srcDrawingAnno)
		v = View.Make
		v.AddTheme(tPoly)
		v.AddTheme(tLine)
		v.AddTheme(tPoint)
		v.AddTheme(tAnno)
		tLine.SetVisible(TRUE)
		tPoint.SetVisible(TRUE)
		tPoly.SetVisible(TRUE)
		tAnno.SetVisible(TRUE)
		v.SetTOCWidth(45)
		v.SetTOCUnresizable(FALSE)
		v.SetName(theDXFFileName)
			if (av.FindScript("View.CloseImageView") = NIL)
				then
					s = Script.Make("av.GetProject.RemoveDoc(SELF)")
					s.SetName("View.CloseImageView")
					av.GetProject.AddScript(s)
			end
		v.SetCloseScript("View.CloseImageView")
		theDXFWin = v.GetWin
		theDXFWin.Resize(310,260)
		theDXFWin.MoveTo(300,50)
	else
		MsgBox.Info("There is no Drawing to open","")
		theDXFWin = nil
end

'-- Open the windows
if (theImageWin <> nil) then
	theImageWin.Open
	theImageWin.Resize(240,180)
	theImageWin.MoveTo(1,100)
end
if (theTextWin <> nil) then
	theTextWin.Open
	theTextWin.Resize(240,180)
	theTextWin.MoveTo(21,100)
end
if (theDXFWin <> nil) then
	theDXFWin.Open
end