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 / 982
981  |  983
Subject: 
Re: How to read variables from RCX
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Fri, 16 Feb 2001 02:52:36 GMT
Viewed: 
1886 times
  
In lugnet.robotics.rcx.nqc, Dave Baum writes:
In article <G8qBp6.EEz@lugnet.com>, "Chris Hood"
<mixer4663@pleasenospam.home.com> wrote:

It is my understanding that the RCX has 32 "spaces" for variables, I am
trying to set variable A or 10 to the value of 100 and then evaluate it
in
an IF statement. However I am not sure how to read that variable "space"
correctly. Here is what I am trying to do in a snippet of code.

int A;
task main(){
  if(A == 100){
    start sometask;
  }else{
    start someothertask;
  }


I would think that there would be a certain way to call that variable
"space" properly and as I do know that the "spaces" are 0-9 and A-G I
don't
think that I can call "A" as I am doing above because I initialize "A"
but
never set it to any value (because I am trying to pass that value to the
program) so the IF always evaluates false and runs the else.

Your help would be GREATLY appreciated, please respond to my e-mail
address
below as well as posting your reply.

Chris
mixer4663@home.com

In general, you don't have control over where the variables get placed.
If necessary you can take advantage of the fact that globals are
allocated consecutively starting at location 0, so in the above example,
A refers to location 0.  However, this is pretty risky since I may
change the allocation algorithm at some point in the future.

Its possible to tell NQC to not use a storage location...

#pragma reserve 0

will reserve location 0 (no NQC variables will ever be assigned there).
You can then refer directly to storage locations using the @ operator:

// test to see if location 0 contains value 100
if (@0 == 100)
{
...
}

Dave

Dave,
First of all thank you very much, using #pragma reserve 10 works great for
me. I would let you know though that although in your programming guide you
tell how to reserve a storage location you do not tell how to access the
reserved location, maybe you can add this to the next version of your
documentation. It would be of great help to us NQC rookies.

Chris



Message has 1 Reply:
  Re: How to read variables from RCX
 
(...) The latest version of the Programmer's Guide (uploaded last night) has an extra section in the back that explains some of the technical details like direct access of data sources, etc. Dave (24 years ago, 17-Feb-01, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Re: How to read variables from RCX
 
(...) In general, you don't have control over where the variables get placed. If necessary you can take advantage of the fact that globals are allocated consecutively starting at location 0, so in the above example, A refers to location 0. However, (...) (24 years ago, 14-Feb-01, to lugnet.robotics.rcx.nqc)

4 Messages in This Thread:

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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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