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 / 939
938  |  940
Subject: 
Re: Just some really basic questions...
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Tue, 30 Jan 2001 17:51:54 GMT
Viewed: 
2023 times
  
In lugnet.robotics.rcx.nqc, Dean Husby writes:

... But you get 32 global variables. All programs can read them.
So you can leave your 'bits' where you want them and
jump to another program to use them.

Dean,

I am not sure that this is correct what you write about global variables.
As far as I know, the followoing is correct:

- 32 global variables are only valid WITHIN one program slot.
- Within this slot, all tasks, functions and subroutines can use them.
- As soon as you switch to another program slot, that program can define 32 new
variables.

See the following example for your statement:

SLOT 1:

int globvar1 = 7;
int globvar2 = 0;
task main () {
  globvar2 = globvar2 + 5;
  SelectProgram (4}; // program 4 = slot 5
}

SLOT 5:

int globvar1;
int globvar2;
task main () {
  SetUserDisplay (globvar1, 0);
  Wait (100);
  SetUserDisplay (globvar2, 0);
  Wait (100);
}

If you are right, the program in slot 5 should display 7 and afterwards 5.

As I said - I am not sure but can't try this out at the moment. If you do,
please let us know.

Best regards
Bernd



Message has 1 Reply:
  Re: Just some really basic questions...
 
(...) Your example did as I have stated. Global variables are global across all program slots. Dean -- Coin-Op's For Sale!: (URL) Lego Workshop: (URL) Lego Club: (URL) (24 years ago, 30-Jan-01, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Re: Just some really basic questions...
 
(...) Yes. To be more precise I believe it's 6100 bytes of space. (The SCOUT has 400 bytes of space) (...) if message = 5 then jump off table... It's that easy... (...) Well if you can keep all the code in one program it's easier. But you get 32 (...) (24 years ago, 29-Jan-01, to lugnet.robotics.rcx.nqc)

9 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