Loading ...
Sorry, an error occurred while loading the content.

Re: Problem using FilterWheel.Names and Util.ToStringCollection

Expand Messages
  • Chris
    This works in VB script: set fw = CreateObject( ASCOM.Simulator.FilterWheel ) set util = CreateObject( ASCOM.Utilities.Util ) fw.Connected=true set
    Message 1 of 3 , Oct 31, 2011
    View Source
    • 0 Attachment
      This works in VB script:

      set fw = CreateObject("ASCOM.Simulator.FilterWheel")
      set util = CreateObject("ASCOM.Utilities.Util")
      fw.Connected=true

      set convertedNames = util.ToStringCollection(fw.Names)

      for each i in convertedNames
      Wscript.echo i
      next

      It's not JScript but it should give a clue; I think that the problem is that Wscript.Echo doesn't accept an array.

      Chris

      --- In ASCOM-Talk@yahoogroups.com, "ivarneli" <kivarsen@...> wrote:
      >
      > Hello,
      >
      > I'm trying to access the Names collection of the FilterWheel Simulator object from JScript, but I am having some trouble. There was a thread about this back in April, and the conclusion (in message 23309) seemed to be to use the Util.ToStringcollection() method.
      >
      > Unfortunately I can't get this to work, using either Names directly or converting it via ToStringCollection. See the following code:
      >
      > var fw = new ActiveXObject("ASCOM.Simulator.FilterWheel");
      > var util = new ActiveXObject("ASCOM.Utilities.Util");
      > fw.Connected=true;
      > var convertedNames = util.ToStringCollection(fw.Names);
      >
      > // This crashes with error:
      > // Microsoft JScript runtime error: Type mismatch
      > WScript.Echo(fw.Names);
      >
      > // This crashes with error:
      > // mscorlib: Missing parameter does not have a default value
      > // Parameter name: parameters
      > WScript.Echo(convertedNames);
      >
      >
      >
      > Has anybody run into this before? Any thoughts on how to work around it?
      >
      > Thanks!
      > Kevin
      >
    • Bob Denny
      ... var e = new Enumerator(convertedNames); for( ;!e.atEnd(); e.moveNext()) WScript.Echo(e.item());
      Message 2 of 3 , Nov 1, 2011
      View Source
      • 0 Attachment
        You said:
        var fw = new ActiveXObject("ASCOM.Simulator.FilterWheel");
        var util = new ActiveXObject("ASCOM.Utilities.Util");
        fw.Connected=true;
        var convertedNames = util.ToStringCollection(fw.Names);
        
        var e = new Enumerator(convertedNames);
        for( ;!e.atEnd(); e.moveNext())
            WScript.Echo(e.item());


      Your message has been successfully submitted and would be delivered to recipients shortly.