Re: I need more eyes on this one.

From: Pedro Graca (hexkid_at_hotpop.com)
Date: 07/04/04


Date: 4 Jul 2004 13:19:46 GMT

KPR wrote:
> I'm getting a "parse error before 'else'" at the line indicated by the
> arrow. Can anybody see what the heck is wrong?
> -----------------------------------------------------------------------------------------------------------------------
> void IS_IT_A_DDR(string& mtgrec,string& temprec,int& ddrrc) {
> string Day2="SunMonTueWedThuFriSat";
> string Daytoken="0123456";
> int badday=0;
> if (mtgrec.size() < 8) {
> ddrrc=0;
> return;
> }
> for (int i=0; i <= 6; i++) {
> if (mtgrec.substr(0,3) == Day2.substr((i+1)*3-3,3)) {
> if ((mtgrec.substr(3,1) == "0") || (mtgrec.substr(3,1) ==
> "1")) {
> if ((mtgrec.substr(7,1)).find_first_of("BCLMOPSTW*") !=
> -1) {
> temprec=Daytoken.substr(i,1) + mtgrec.substr(1);
> ddrrc=1;
> return;
> }
> else {
> ddrrc=2;
> return;
> }
> else {
><<<<<=====================================
> ddrrc=3;
> return;
> }
> }
> }
> else badday++;
> }
> if (badday == 7) {
> ddrrc=4;
> return;
> }
> else ddrrc=5;
> return;
> }
> --------------------------------------------------------------------------------------------------------------------------------

Remove everything execpt the for() loop
------------
for (int i=0; i <= 6; i++) {
    if (mtgrec.substr(0,3) == Day2.substr((i+1)*3-3,3)) {
        if ((mtgrec.substr(3,1) == "0") || (mtgrec.substr(3,1) == "1")) {
            if ((mtgrec.substr(7,1)).find_first_of("BCLMOPSTW*") != -1) {
                temprec=Daytoken.substr(i,1) + mtgrec.substr(1);
                ddrrc=1;
                return;
            }
            else {
                ddrrc=2;
                return;
            }
        else { <<<<<=====================================
            ddrrc=3;
            return;
        }
        }
    }
    else badday++;
}
------------

Now remove all code, keeping just the structure
--------
for () {
    if () {
        if () {
            if () {
            }
            else {
            }
        else { <<<<<=====================================
        }
        }
    }
    else badday++;
}
--------

Now remove the innermost if() else
--------
for () {
    if () {
        if () {
        else { <<<<<=====================================
        }
        }
    }
    else badday++;
}
--------

Do you see the parse error now? :)

-- 
USENET would be a better place if everybody read:   | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html  | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html    | header, textonly |
http://www.expita.com/nomime.html                   | no attachments.  |


Relevant Pages

  • Re: I AM A SUPERHERO!!!!!!!
    ... arrow on the right loop was still lit as my last ball drained. ... I ran out of Killian's and the wife had a few left) the pinball ...
    (rec.games.pinball)
  • Re: equivalent axiom of infinity
    ... Picture x as a bunch of dots, ... The I* premise is every x member has at least one arrow coming ... the degenerate case of an arrow into itself as a loop of size 1). ... We have the set of all finite subsets of x, ...
    (sci.logic)
  • [SLE] Konqueror 3.1.3...back and forward buttons problem
    ... this guy is coll and *very* cheap!). ... Copied them all to a folder and rpm'd ... 'back' arrow or the 'forward' arrow on the main taskbar, ... and I then have to look at it to figure out where the heck ...
    (SuSE)
  • Re: What is this code doing?
    ... This is not a help for an asm ... >Looks like you overwrite the counter in the first line in the loop. ... >But why on earth do you think this helps me as an beginner asm programmer? ... This block of code immediately made me think of C - heck, ...
    (alt.lang.asm)
  • Re: node voltage analysis
    ... I have done a few problems this way and if I assume the current direction 'wrong' (ie. different than the problem book I am using), the simultaneous equations do not solve correctly. ... then draw an arrow next to any element. ... As you collect the terms, any arrow that points in the same direction as the loop is a positive current, any arrow that points against the direction of your loop is a negative term. ...
    (sci.electronics.basics)