'-------------------------------- 'Script: "Link.Ext" (MS Windows Only, not unix) ' (Adapted from a script on esri.com called link.web, but it ' works for any application.) Modified by Andy Rowan, ' The GIS Center, andy(at)giscenter(dot)org. 9/12/01 ' ' Script to be used with the ArcView 3.x built-in hotlink feature. ' With filename in link field, ANY valid registered document ' type is opened by its native application. If the app is running already, ' that instance will be opened and used. If not, it will be launched. ' ' Can handle multiple documents: if hotlink field contains multiple ' document names separated by commas, all are opened. ' ' Several configurable options, marked below by "CONFIG:" ' ' CONFIG: Following line determines whether script checks if file exists, ' and also whether script gives error message if hotlinked app generates ' an error condition. ' If FailSilently is set to 'false', script will check for existence ' of file and give message box if it doesn't, BUT this means the script ' won't work with web URLs. The script will also generate a message ' box if the hotlinked app generates an error condition. ' If FailSilently is 'true', the checks are disabled and web URLs ' will work. FailSilently = true ' CONFIG: Following line determines whether script gives error ' message if hot link value is null. If false, hotlink tool ' just does nothing on features with null values. MsgOnNullHotlink = false ' Set working directory for hotlink application to directory containing doc ' (Could set explicitly to something if necessary) LaunchDir = FileName.GetCWD.asString ' NOTE: pathname of system directory is assumed to be the usual, ' if not, the following lines need to be edited. ' 'Set up DLL file objects. 'The GetOSVariant request at 3.2 returns 95 when the OS is 98, ' so this still works fine. Haven't tested windows Me or 2000. if (System.GetOSVariant = #SYSTEM_OSVARIANT_MSWNT) then dllShell32 = DLL.Make("C:\winnt\system32\shell32.dll".AsFileName) dllUser32 = DLL.Make("C:\winnt\system32\user32.dll".AsFileName) ElseIf (System.GetOSVariant = #SYSTEM_OSVARIANT_MSW95) then dllShell32 = DLL.Make("C:\windows\system\shell32.dll".AsFileName) dllUser32 = DLL.Make("C:\windows\system\user32.dll".AsFileName) Else MsgBox.Warning("Required DLL files cannot be found.", "Stop") return nil End ' 'Set up Win32API functions as Avenue DLLProc objects dpGetActiveWindow = DLLProc.Make(dllUser32, "GetActiveWindow", #DLLPROC_TYPE_INT32, 'return value type {} 'argument list ) ' dpShellExecute = DLLProc.Make(dllShell32, "ShellExecuteA", #DLLPROC_TYPE_INT32, 'return value type {#DLLPROC_TYPE_INT32, 'argument list #DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_STR, #DLLPROC_TYPE_INT32} ) ' 'Get the Window Handle (hWnd) of the ArcView window. hWnd_active = dpGetActiveWindow.Call({}) '''or-> hWnd_active = DLL.GetAVWindowHandle ' 'Get the document names for Hotlinking from the active 'theme's hotlink field. FieldVal = SELF ' Check for null value in hot link field, if that check is enabled. if (MsgOnNullHotlink) then if (FieldVal.isNull) then msgbox.info("No document name in table for this feature","Hot link") return nil end end 'Turn it into a list ... items in FieldVal separated by commas HotLinkList = FieldVal.AsTokens(",") 'Go through the list and open each document for each HotLinkVal in HotLinkList 'if we need to check for file existence, do so. if ((FailSilently) or (File.Exists(hotlinkVal.AsFileName))) then 'Send the doc name to the system to launch default application retValue = dpShellExecute.Call({hWnd_active, "Open", hotlinkVal, "", LaunchDir, 1}) ' 'Maybe let the user know if the link failed. The "ShellExecuteA" 'function returns an integer greater than 32 if the process 'succeeded. if (FailSilently.not) then if (retValue <= 32) then MsgBox.Warning("Hotlink failed.","Sorry") End end else msgbox.info("File not found: " + hotlinkVal, "Hot link") end end ' 'End of Script: "Link.Ext" '--------------------------------