Error in Function, not variable

Results 1 to 2 of 2

Thread: Error in Function, not variable

  1. #1
    Join Date
    Dec 1969

    Default Error in Function, not variable

    Just a quick question, (or 2 :)<BR><BR>I had an error on a server where I received an "Variable is undefined:" for a FUNCTION call<BR>This is while using Option explicit.<BR><BR>Running the same script on a totally different server, I dont get the same problem.<BR><BR>Should I be using a "call" for the function?<BR><BR>The original script went something like this :<BR><BR>&#060;%If ThisIsTrue then DoFunction("Parameters") %&#062;<BR><BR>DoFunction errored as an undefined "variable"<BR><BR>Changing the code to :<BR><BR>&#060;%If ThisIsTrue then <BR> DoFunction("Parameters") <BR>End if%&#062;<BR>Fixed the problem.<BR><BR>Why would this be causing a problem on one server and not another?<BR><BR>Also, I read that you cant dimension a "split()" as an array. What is the proper method for diming arrString = Split(String,",") and all of its variables arrString(1),(2) etc?<BR><BR>TIA

  2. #2
    Join Date
    Dec 1969

    Default RE: Error in Function, not variable

    Regarding the IF ... THEN function(...) on one line versus multiple lines: I would bet it is because of a difference in the version of VBScript on one server versus the other. If you really care, you can find the version of the script engine in use on each machine. If you don&#039t care, keep using your nice workaround.<BR><BR>******************<BR><BR>Re SPLIT:<BR><BR>You should *NEVER* dimension the target variable of a call to SPLIT. Split *ALWAYS* creates a BRAND NEW array (on the fly), so even if you had an array there it would be wiped out (thrown on the OLE Garbage Collection heap, thus just eating time).<BR><BR>Just do something like:<BR><BR>&#060;%<BR>str = "this is just a demo"<BR>ary = Split( str )<BR>For i = 0 To UBound( ary )<BR>&nbsp; &nbsp; Response.Write "element " & i & " contains " & ary(i) & "&lt;BR&#062;"<BR>Next<BR>%&#062;<BR><BR><BR>N OTE: The array starts at ZERO, not 1, as do all VBS arrays.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts