Subject:
|
Re: Just some really basic questions...
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Tue, 30 Jan 2001 23:24:58 GMT
|
Viewed:
|
2073 times
|
| |
| |
Bernd Frassek wrote:
> 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
Your example did as I have stated. Global variables are global across all program
slots.
Dean
--
Coin-Op's For Sale!: http://www.akasa.bc.ca/tfm/coin-op.html
Dean's Lego Workshop: http://www.akasa.bc.ca/tfm/lego_wr.html
Vancouver Lego Club: http://www.akasa.bc.ca/vlc
|
|
Message has 1 Reply: | | Re: Just some really basic questions...
|
| (...) program (...) Dean, you are right and meanwhile I could test it. However, the definition for the global variables must be in the SAME ORDER order for both of the programs. If you would do this: SLOT 1: int testvar1 = 1; int testvar2 = 2; int (...) (24 years ago, 31-Jan-01, to lugnet.robotics.rcx.nqc)
|
Message is in Reply To:
| | Re: Just some really basic questions...
|
| (...) 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 (...) (24 years ago, 30-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
|
|
|
|