Error: missing ) in parenthetical error

Discussion in 'Javascript' started by threepins@gmail.com, Dec 18, 2004.

  1. Guest

    Hi,

    Trying the following ...

    function getCurrentVal(poValue)
    {
    var lcCurrentVal = 0;
    if (isNaN(parseInt(poValue)))
    {
    var loValue = poValue.toUpperCase();
    if (loValue == "/")
    {
    lcCurrentVal = "/";
    }
    if (loValue == "X")
    (
    lcCurrentVal = "X";
    {
    }
    else
    {
    lcCurrentVal = parseInt(poValue);
    }

    if(lcCurrentVal)
    {
    return lcCurrentVal;
    }
    }


    and am getting the error

    Error: missing ) in parenthetical
    Line: 189, Column: 23
    Source Code:
    lcCurrentVal = "X";

    I can't for the life of me figure it out. If i comment this line out it
    works fine (but then that check is removed). Any help would be most
    appreciated.

    Cheers
    Bj McGowan
     
    , Dec 18, 2004
    #1
    1. Advertising

  2. RobB Guest

    wrote:
    > Hi,
    >
    > Trying the following ...
    >
    > function getCurrentVal(poValue)
    > {
    > var lcCurrentVal = 0;
    > if (isNaN(parseInt(poValue)))
    > {
    > var loValue = poValue.toUpperCase();
    > if (loValue == "/")
    > {
    > lcCurrentVal = "/";
    > }
    > if (loValue == "X")
    > (
    > lcCurrentVal = "X";
    > {
    > }
    > else
    > {
    > lcCurrentVal = parseInt(poValue);
    > }
    >
    > if(lcCurrentVal)
    > {
    > return lcCurrentVal;
    > }
    > }
    >
    >
    > and am getting the error
    >
    > Error: missing ) in parenthetical
    > Line: 189, Column: 23
    > Source Code:
    > lcCurrentVal = "X";
    >
    > I can't for the life of me figure it out. If i comment this line out

    it
    > works fine (but then that check is removed). Any help would be most
    > appreciated.
    >
    > Cheers
    > Bj McGowan



    Hard to see this late in the day, but shouldn't this:
    if (loValue == "X")
    ( <----

    ....be a curly brace? ;)

    Rob
     
    RobB, Dec 18, 2004
    #2
    1. Advertising

  3. Guest

    I love you!!

    Thanks man.... been staring at this for ages and didn't even see that.
    Cheers
    Bj
     
    , Dec 18, 2004
    #3
  4. wrote:
    > Hi,
    >
    > Trying the following ...
    >
    > function getCurrentVal(poValue)
    > {
    > var lcCurrentVal = 0;
    > if (isNaN(parseInt(poValue)))
    > {
    > var loValue = poValue.toUpperCase();
    > if (loValue == "/")
    > {
    > lcCurrentVal = "/";
    > }
    > if (loValue == "X")
    > (
    > lcCurrentVal = "X";
    > {
    > }
    > else
    > {
    > lcCurrentVal = parseInt(poValue);
    > }
    >
    > if(lcCurrentVal)
    > {
    > return lcCurrentVal;
    > }
    > }
    >
    >
    > and am getting the error
    >
    > Error: missing ) in parenthetical
    > Line: 189, Column: 23
    > Source Code:
    > lcCurrentVal = "X";
    >
    > I can't for the life of me figure it out. If i comment this line out it
    > works fine (but then that check is removed). Any help would be most
    > appreciated.


    Of course you can't. When code is this ugly, it is impossible to reason
    about its correctness. First you should format it properly. Indent the
    contents of all of the blocks. If you still can't see the problem, then
    run it through JSLINT.

    http://www.crockford.com/javascript/lint.html
     
    Douglas Crockford, Dec 18, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    27,735
    Chris Jefferson
    Dec 14, 2004
  2. Gary Herron
    Replies:
    2
    Views:
    667
    Bruno Desthuilliers
    Jul 4, 2006
  3. John Salerno
    Replies:
    3
    Views:
    564
    John Salerno
    Jun 5, 2008
  4. Replies:
    1
    Views:
    257
  5. Replies:
    2
    Views:
    151
Loading...

Share This Page