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 / 980
979  |  981
Subject: 
Re: How to read variables from RCX
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Wed, 14 Feb 2001 05:56:53 GMT
Viewed: 
2036 times
  
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

--
reply to: dbaum at enteract dot com



Message has 1 Reply:
  Re: How to read variables from RCX
 
(...) 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 (...) (24 years ago, 16-Feb-01, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  How to read variables from RCX
 
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 (...) (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