To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 640
639  |  641
Subject: 
Re: NQC 2.x event processing
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Tue, 13 Jun 2000 03:04:32 GMT
Viewed: 
2015 times
  
In article <393BDEDF.3CDC@gmccomb.com>, Gordon McComb
<gmccomb@gmccomb.com> wrote:

Dave Baum wrote:

If I get assignment working, I may then move to an array style syntax:

UpperLimit[0] = 10;

since "UpperLimit(0) = 10;" looks very strange to most people (although
some C++ programs have a lot of this sort of thing).

I like UpperLimit[0] = 10; just fine. The parens look too much like
Basic! <g>

Getting things like

Timer[0] = 100;

to work while still allowing

if (Timer(0) < 100)
{
}

is a lot harder than I had anticipated, so I'm punting on array-style
setting of the various RCX source (such as Timer(), UpperLimit(), etc).

There are presently three ways to set these things (in the
soon-to-be-released NQC 2.2.b1).  Here are examples of settint timer #1
to 100

1) Assignment syntax.  Any data source can be used as the target of
assignment, subject to the read/write constraints of the specific
target.  Currently, only the RCX 2 allows writing of sources other than
variables, and even so, some of the sources are read-only):

Timer(1) = 100;

2) Set(dst, src).  This call takes two data sources and copies the value
from the second to the first:

Set(Timer(1), 100);

This is an artifact of earlier 2.2 releases.  I'm keeping it around
simply because it makes a lot of other functions in the API easier to
specify.  Personally, I think it looks hideous and is likely to cause
confusion for beginners.

3) Specialized calls per data source.

SetTimer(0, 100);

I think option #3 will be the prefered method in the long run because it
affords the greatest chance of portability to other targets.  #1 and #2
depend on the fact that all sources can be treated identically.  #3
would allow different sources to be set with different opcodes if a
generic opcode wasn't supported.  For example, although

Watch() = 123;

works on RCX 2, it doesn't work on RCX 1 (because RCX 1 doesn't support
setting of sources).  However, SetWatch() works fine on both because RCX
1 does have a special opcode to set the watch.

Given the above, I'm really tempted to remove Set() from the
documentation and make it an internal-only call (there are other such
macros in the API file).  I'm also tempted to disable #1 since it leads
to a programming style that isn't very C-like and is not likely to be
portable to other lego targets.

Comments?

Dave

--
reply to: dbaum at enteract dot com



Message is in Reply To:
  Re: NQC 2.x event processing
 
(...) #3, which was the approach you took. (...) I think what I liked about the approach in pBrick script was that it was fairly like coding a microcontroller in assembler: set up an interrupt vector and then include a label and code for the (...) (24 years ago, 5-Jun-00, to lugnet.robotics.rcx.nqc)

6 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