Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Issue With JavaScript and ClearScript

Issue With JavaScript and ClearScript

Scheduled Pinned Locked Moved JavaScript
helpjavascripthtmlcomtools
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alan Burkhart
    wrote on last edited by
    #1

    I'm learning to script an application with ClearScript. My program is a tabbed text editor and the idea is to have access to all the open files via a List. For scripting, the program opens a separate window (so that the script is not part of the scriptable collection). Results are written to a second textbox. And there is where I discovered the problem. At present I'm just having the Javascript display the "FilePath" property of each item in the collection. This works fine with this script:

    parent.OutPut.Text="";
    var i;
    var y=0;
    for (i = 0; i < parent.OpenFiles.Count; i++) {
    y += 1
    parent.OutPut.Text += y + " " + parent.OpenFiles[i].FilePath + "\r\n";

    }
    parent.OutPut.Text += parent.OpenFiles.Count;

    I get the following correct result in the textbox: 1 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\WikipediaCrimeData_RawText.txt 2 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\conspiracytheory.html 3 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\USConsSearch.html 4 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\wordley.html 5 C:\Users\Alan\Documents\new 1.txt 6 C:\Users\Alan\Documents\10Comms.txt 7 C:\Users\Alan\Documents\testfile.txt 8 C:\Users\Alan\Documents\Transfer\From Toshiba\TestSpellChecker.txt 9 C:\Users\Alan\Documents\Projects\NetPadd2 Help Files\AdntlRsc.html 10 C:\Users\Alan\Documents\Projects\NetPadd2 Help Files\intro.html 11 C:\Users\Alan\Documents\ForLoop.js 12 untitled_2.txt 13 C:\Users\Alan\Documents\ForEach.js 13 ("13" is the number of items in the collection.) However, if I use this script:

    parent.OutPut.Text="";
    var x;
    var i=0
    for (x in parent.OpenFiles) {
    i+=1
    parent.OutPut.Text += i + " " + parent.OpenFiles[x].FilePath + "\r\n";}
    parent.OutPut.Text += parent.OpenFiles.Count;

    I get the following result: 1 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\WikipediaCrimeData_RawText.txt 2 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\conspiracytheory.html 3 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\USConsSearch.html 4 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\wordley.html 5 C:\Users\Alan\Documents\new 1.txt 6 C:\Users\Alan\Documents\10Comms.txt 7 C:\Users\Alan\Documents\testfile.txt 8 C:\Users\Alan\Documents\Transfer\From Toshiba\TestSpellChecker.txt 9 C:\

    G 1 Reply Last reply
    0
    • A Alan Burkhart

      I'm learning to script an application with ClearScript. My program is a tabbed text editor and the idea is to have access to all the open files via a List. For scripting, the program opens a separate window (so that the script is not part of the scriptable collection). Results are written to a second textbox. And there is where I discovered the problem. At present I'm just having the Javascript display the "FilePath" property of each item in the collection. This works fine with this script:

      parent.OutPut.Text="";
      var i;
      var y=0;
      for (i = 0; i < parent.OpenFiles.Count; i++) {
      y += 1
      parent.OutPut.Text += y + " " + parent.OpenFiles[i].FilePath + "\r\n";

      }
      parent.OutPut.Text += parent.OpenFiles.Count;

      I get the following correct result in the textbox: 1 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\WikipediaCrimeData_RawText.txt 2 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\conspiracytheory.html 3 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\USConsSearch.html 4 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\wordley.html 5 C:\Users\Alan\Documents\new 1.txt 6 C:\Users\Alan\Documents\10Comms.txt 7 C:\Users\Alan\Documents\testfile.txt 8 C:\Users\Alan\Documents\Transfer\From Toshiba\TestSpellChecker.txt 9 C:\Users\Alan\Documents\Projects\NetPadd2 Help Files\AdntlRsc.html 10 C:\Users\Alan\Documents\Projects\NetPadd2 Help Files\intro.html 11 C:\Users\Alan\Documents\ForLoop.js 12 untitled_2.txt 13 C:\Users\Alan\Documents\ForEach.js 13 ("13" is the number of items in the collection.) However, if I use this script:

      parent.OutPut.Text="";
      var x;
      var i=0
      for (x in parent.OpenFiles) {
      i+=1
      parent.OutPut.Text += i + " " + parent.OpenFiles[x].FilePath + "\r\n";}
      parent.OutPut.Text += parent.OpenFiles.Count;

      I get the following result: 1 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\WikipediaCrimeData_RawText.txt 2 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\conspiracytheory.html 3 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\USConsSearch.html 4 C:\Users\Alan\Documents\Transfer\From Toshiba\Projects\alanburkhart.com\wordley.html 5 C:\Users\Alan\Documents\new 1.txt 6 C:\Users\Alan\Documents\10Comms.txt 7 C:\Users\Alan\Documents\testfile.txt 8 C:\Users\Alan\Documents\Transfer\From Toshiba\TestSpellChecker.txt 9 C:\

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      I don't know anything about ClearScript, but in Javascript using

      for(x in parent.OpenFiles) {

      iterates over all the members of whatever parent.OpenFiles happens to be. That will include parent.OpenFiles.Count and any other attributes it has (attributes can be accessed using parent.OpenFiles.Count or parent['OpenFiles']['Count']). Your lines of undefined values are members of parent.OpenFiles that don't have their own member called FilePath, and there must be 37 of them. Try using

      parent.OutPut.Text += x + " " + parent.OpenFiles[x].FilePath + "\r\n";}

      to see the attribute names instead of the numeric value you are assigning them.

      A 1 Reply Last reply
      0
      • G Graham Breach

        I don't know anything about ClearScript, but in Javascript using

        for(x in parent.OpenFiles) {

        iterates over all the members of whatever parent.OpenFiles happens to be. That will include parent.OpenFiles.Count and any other attributes it has (attributes can be accessed using parent.OpenFiles.Count or parent['OpenFiles']['Count']). Your lines of undefined values are members of parent.OpenFiles that don't have their own member called FilePath, and there must be 37 of them. Try using

        parent.OutPut.Text += x + " " + parent.OpenFiles[x].FilePath + "\r\n";}

        to see the attribute names instead of the numeric value you are assigning them.

        A Offline
        A Offline
        Alan Burkhart
        wrote on last edited by
        #3

        Graham Breach wrote:

        and any other attributes it has

        I didn't realize that. Thank you. I was thinking in terms of the For Each loop in VB.

        Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups