Error in hyperlink script

862
3
Jump to solution
03-31-2014 05:26 AM
Zeke
by
Regular Contributor III
I wrote a hyperlink script in Python for the Display tab. It has an if/elif structure based on the value of a field. With just the if clause, it runs fine an opens the document. But when I add the elif clause, Arc gives me an error saying '...name OpenLink is not defined'. This makes no sense to me, it's the default name of the function. Any ideas? Thanks.

import os, threading def OpenLink ([SubtypeCD], [Name] ):     if [SubtypeCD] == 'Recorded' and [Name] is not None:         parsedName = [Name].partition('-')         folderPrefix = parsedName[0].zfill(4)         fileSuffix = parsedName[2].zfill(4)         extension = '.TIF'         fileName = folderPrefix + fileSuffix + extension         loc = r"\\base\path"         image = os.path.join(loc, folderPrefix, fileName)         threading.Thread(target=os.startfile, args=(image,)).start()     elif [SubtypeCD] == 'Unrecorded' and [Name] is not None:         parsedName =[Name].split('-')         folderOne = parsedName[0] + '_Survey'         folderTwo = [Name]         fileName = [Name] + '0001.tif'         loc = r"\\other\base\path'         image = os.path.join(loc, folderOne, folderTwo, fileName)         threading.Thread(target=os.startfile, args=(image,)).start()       else:         pass         return
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JoshuaChisholm
Occasional Contributor III
Hello Greg,

I might be as simple as a syntax error:

loc = r"\\other\base\path' should be loc = r"\\other\base\path"

Let me know if that does the trick!

View solution in original post

0 Kudos
3 Replies
JoshuaChisholm
Occasional Contributor III
Hello Greg,

I might be as simple as a syntax error:

loc = r"\\other\base\path' should be loc = r"\\other\base\path"

Let me know if that does the trick!
0 Kudos
benberman
Occasional Contributor
I am also thinking along similar lines of Josh's suggestions.

Try changing loc = r"\\base\path" to loc = r'\\base\path'
0 Kudos
Zeke
by
Regular Contributor III
Yes, that appears to have fixed it. Dumb mistake on my part, but an even dumber error message. Thanks.
0 Kudos