Multiple Functions in one script

5416
2
05-28-2015 05:47 AM
NicolasPeckman
New Contributor

I'm very new to both ArcGIS and vbscript, so any help is appreciated. I'm working on a label making script, and I really want to make helper functions to help process the logic involved. Can I write more functions inside the expression parser? If the parser won't accept multiple functions, is there a way to store these functions in another location and access them in my script?

0 Kudos
2 Replies
WesMiller
Regular Contributor III

Nit sure what your trying to accomplish but you can use multiple functions in label expression. See the python version below. vbscript shouldn't be much different

def FindLabel ( [OWNERNAME] ):
  lab = labelOther([OWNERNAME])
  return lab
def labelOther(x):
  return x
TedKowal
Occasional Contributor III

Using VBScript for multiple function as Wes stated can be done similarly to python.  As to storing and reusing the vbscript functions I do not think vbscript has the availability of the "Include" statement like VBA.  So you would have to develop a snippets library and cut/paste or develop your functions as a class object and run something like:

sub GetLib(Scriptname)
   dim oFile
   set oFile = oFso.OpenTextFile(Scriptname) 'File Script Object
   ExecuteGlobal oFile.ReadAll()
   oFile.Close
End Sub

Function test1(xxx)
   dadfasdf
end Function

Function test2(xxxxx)
    .s;alkjdf;sdlkfj ....
end function

Not worth it!  May have to resort to python for your re-usablitly question

I am a VB guy..... and this is better suited for python and develop your reusable portions as a custom toolbox.

(I hate Python....much prefer VB but it seems we are in the minority now and development goes on.....)