Announcement

Collapse
No announcement yet.

SyntasError missing ; before statement

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SyntasError missing ; before statement

    The current issue is the syntax error at line 110, missing ; before statement. I can't figure that out. As all prior statements have semi colins.

    The modification that I was trying to make with this file from the one in my last post is that I am trying to plot out both the cumSumEs and cumSumNq in the main function.

    To do this I have broken down the 1 internal "difference" function (that had included both cumSumEs and cumSumNq functions), into three seperate functions.

    Question 1

    Is it necessary to break the "Difference" function down into three functions?? If I had left both cumSumEs and Nq aspects in the "Difference" function and used the

    return new Array (Difference, cumSumEs, cumSumNq);

    as the return statement in my internal function, could I have then seperatly called all three of the values being returned in the internal function's return Array, into my main function and plot them out as seperate lines??

    I tried to do exactly that, but was getting errors, so I assumed that I couln't

    Question 2

    The other problem I was having with attached file, was an error at line 85, xCumSumEs not defined. Isn't it defined at line 81???

    To try to fix this, I tried listing the names of functions cumSumEs and cumSumNq in the perameter of functions Difference.

    Any suggestions are greatly appreciated,

    John
    Attached Files

  • #2
    This is a situation where "scope" of variables becomes an issue. I was talking about this with a client last night.

    When you declare a variable...

    var myvar = 0;

    it depends on "where" you declare (and intend to use it). There are two basic types of "scope" : Global and Local.

    Global means you declare the variable above everything else in the code and defind it (if needed). That means above main() Premain() and any other calls to functions you intend to use.

    Local means you are declaring a variable for use in a specific function or process that can be destroyed when the process is done. These are like temproary variables in bigger code.

    The problem on line 85 is you are trying to USE a variable that you declare on line 94. If you were to declare the variable before you tried to use it, there would be no problem.

    It's best using EFS to try to structure your code in this order.

    PHP Code:
    //  Variables
    var myvar1 0;
    var 
    myvar2 null;
    var 
    myvar3 true;
    var 
    myvar4 = new Array();

    //  Then make any calls for DLLs, internal setup functions or anything you like here.
    fSetupMyEFS();

    //  Then define preMain()
    function preMain() {

    }

    //  Then define the main() function
    function main() {


      return;
    }

    //  Then create any supporting functions down here.
    function fSetupMyEFS() {
      
    // this is my example setup function above.


    Sticking with this structure will help your efs run efficiently.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanx Doji

      Thanx Doji,

      I will keep that format in mind whenever I write EFS's.


      Thanks

      John
      Attached Files
      Last edited by xoprofittaker; 05-15-2008, 02:10 PM.

      Comment

      Working...
      X