To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 12953
12952  |  12954
Subject: 
Re: Semicolon (;) Confusion
Newsgroups: 
lugnet.robotics
Date: 
Fri, 27 Oct 2000 21:28:54 GMT
Viewed: 
625 times
  
John, Thanks for that answer. That same question has haunted me for some
time.

--
Bob Fay
rfay@we.mediaone.net

The Shop
http://www.geocities.com/Heartland/Bluffs/7900/
"John A. Tamplin" <lego-robotics@crynwr.com> wrote in message
news:Pine.A32.3.91.1001027130949.16770f-100000@cyclone.liveonthenet.com...
On Fri, 27 Oct 2000, Jerry Kalpin wrote:

In some cases Mark Overmars great RCX Command Center does not flag • syntax
errors for incorrect use of an ending semicolon, as in the example • below.
Could someone please explain how semicolons work in NQC?  Perhaps there • is a
good reason for *not* flagging syntax errors in those cases.

//a flasher program
task main()
{
    SetSensor(SENSOR_1,SENSOR_TOUCH);
    while (true)   // A semicolon here disables program
    {
        if (SENSOR_1 == 1)  //a semicolon here runs the flasher all the • time
        {
            On (OUT_B);
            Wait (10);
            Off (OUT_B);
            Wait (100);
        }
    }
}

NQC implements a syntax similar to C.  In C, while and if statements have
a single statement that is executed if the condition is true.  A null
statement is a valid statement, and a block of statements enclosed in {}
can be substituted or a statement.  So, if you add a semicolon after the
while:

while(true);
{
...
}

You have a valid statement that loops continuously doing nothing.  The
rest of the program is never reached.  Likewise, if you put it after the
if, the null statement is executed if the condition is true, and then the
following block of statements is unconditionally executed.

John A. Tamplin LiveOnTheNet.COM, Inc.
jat@LiveOnTheNet.COM 2104 West Ferry Way
256/705-7007 - FAX 256/705-7100 Huntsville, AL 35801





Message is in Reply To:
  Re: Semicolon (;) Confusion
 
(...) NQC implements a syntax similar to C. In C, while and if statements have a single statement that is executed if the condition is true. A null statement is a valid statement, and a block of statements enclosed in {} can be substituted or a (...) (24 years ago, 27-Oct-00, to lugnet.robotics)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR