nasty error when using indexOf() array method; how to search arrays in Fiddlerscript

2,886 views
Skip to first unread message

benef...@gmx.com

unread,
Mar 9, 2016, 11:16:29 AM3/9/16
to Fiddler

I'm a novice hacker, and am confused about how to approach arrays in Fiddlerscript.

Using the .indexOf() method of an array generates this pop-up error:

There was a problem with your FiddlerScript.

Function expected
Function expected
  at Microsoft.JScript.LateBinding.Call(Binder binder, Object[] arguments, ParameterModifier[] modifiers, CulterInfo culture, StringP[] namedParameters, Boolean construct, Boolean brackets, VSAEngine engine)
  at Microsoft.JScript.LateBinding.Call(Object[] arguments, Boolean construct, Boolean brackets, VsaEngine engine)
  at Fiddler.ScriptNamespace.Handlers.OnBeforeResponse(Session oSession)
  at Fidderl.FiddlerScript.DoBeforeResponse(Session oSession)


When I use Array.IndexOf(myarray, "thingtofind"), I get "Object doesn't support his property or method"

Thx.


Eric Lawrence

unread,
Mar 9, 2016, 11:36:34 AM3/9/16
to Fiddler
The indexOf operator was added to arrays in ECMAScript 5.1, which appears to be after JScript.NET was created.

As FiddlerScript has full access to all of the collection types in .NET, it's rare that using a classic JavaScript array object is the best way to go; usually you'd be better off using e.g. an ArrayList or equivalent. Can you share more of your code?

benef...@gmx.com

unread,
Mar 9, 2016, 2:44:01 PM3/9/16
to Fiddler
Well, there's really nothing to share: My ignorance combined with various ecma/javascript/jscript language implementation has left me stuck at simply trying to add elements to an array (no problem) then check if a given value is present in the array (problem).

How do you suggest Fiddlerscript-ing that?

indexOf() isn't implemented (good to know)

Array.IndexOf(myarray, 'thingtofind') returns an error

Shortest path: Would you mind posting a simple toy example of 'find in array' that works in Fiddlerscript?

Thx.


benef...@gmx.com

unread,
Mar 9, 2016, 2:45:39 PM3/9/16
to Fiddler
P.S. I could for-loop iterate thru the elements and set a var if something is found. But, lord, that seems silly.

There's something obvious I'm missing.

Eric Lawrence

unread,
Mar 9, 2016, 5:42:02 PM3/9/16
to httpf...@googlegroups.com
The question is why you need to use an array to begin with?

And yes, if it really needs to be a JavaScript-style array (which is more akin to a list than anything else), writing a simple for loop seems like a fine approach.

On the other hand, if you want an array but are happy with the .NET typed arrays (which are of fixed size), you can do this:

 var arrStr:String[] = ["", "This", "That"] ;
 FiddlerObject.alert(System.Array.IndexOf(arrStr, "This") + "\n" + System.Array.IndexOf(arrStr, "That"));
     
Reply all
Reply to author
Forward
0 new messages