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 / 591
590  |  592
Subject: 
Re: NQC 2.2 a1 available for public test
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Sun, 7 May 2000 22:17:59 GMT
Reply-To: 
rkra@gmx.+spamless+de
Viewed: 
1957 times
  
Hi,

that 's right, global variables could be displayed but not the local ones.
Therefore I 've another test file which uses a global variable i and a
local variable k.

If you run the program on your rcx you would see first the global i that
is 100.
After this there should be displayed the local variable k that is 50.
But there
is the mistake. You see the global i and not the local k. The third value
should be the global i .. is 200 and is okay. And the last one should be 300.

Dave wrote that locals can't be displayed. I 've tested this and it
seems
so but I don't know why

Ralf


// ------------------------------------------------------------------------------
//
// test2.nqc
//
// by
// Ralf Krause <rkra@gmx.de>
//
// for
// nqc-mpw-2.2.a1 or nqc-win-2.2.a1
//
// ---------------------------------------
//
// To use the new rcx22 api you have to
// download this file with the parameters
//
// nqc -Trcx2 -d test1.nqc
//
// ---------------------------------------


// Turn off the RCX
// I can't find this in the rcx22 api
void SleepNow()   { asm { 0x60 }; }  // switch off immediately



int i;                               // global variable

void vartest() {
int k;                        // local variable
k = 50;
Display (k, 0);               // display of a local variable
                              // doesn't work
                                    // k is 50 but the display shows
                                    // 200 (this is i)
PlaySound (SOUND_CLICK);
Wait (100);

Display (i, 0);               // display of the global variable
PlaySound (SOUND_CLICK);
Wait (100);
}


task main() {

PlaySound (SOUND_UP);
Wait (100);

i = 100;
Display (i, 0);               //  displays 100
PlaySound (SOUND_CLICK);
Wait (100);

i = 200;
vartest();

i = 300;
Display (i, 0);               // displays 300
PlaySound (SOUND_CLICK);
Wait (100);

PlaySound (SOUND_DOWN);
SleepNow ();
}

// ------------------------------------------------------------------------------

Dave Baum wrote:

I assume it worked as expected.  If not, let me know and I'll debug.
One note...you can't display local variables (vars 32-47).  You can
only display globals (vars 0-31).  That's the Lego terminology, not
mine.  Actually, the 'locals' refers to being local to a task, not
local to a scope as is the case in something like NQC.  NQC 'locals'
are either assigned to global or local slots depending on what's
available.

I'll have to add the sleepnow call to the api.  I think I was
advocating a different name for it a while back...time to check the
Lugnet archives.

Dave

Hi,

thank you Dave for the new version 2.2 a1 of NQC.
I 've done some test because I want to display some messages.
Have a look to the attached test1.nqc.

Ralf



Dave Baum wrote:

Preliminary NQC support for RCX 2.0 is now available in NQC version
2.2a1.  Its in the beta test area of the NQC site:
http://www.enteract.com/~dbaum/nqc

There have been a lot of changes internal to the compiler itself, and
RCX 2.0 support is only partially complete at the moment, but I figured
an early release would be better than nothing.

Dave Baum

--
reply to: dbaum at enteract dot com



//     ---------------------------------------
//
//     test1.nqc
//
//     by
//     Ralf Krause <rkra@gmx.de>
//
//     for
//     nqc-mpw-2.2.a1 or nqc-win-2.2.a1
//
//     ---------------------------------------
//
//     To use the new rcx22 api you have to
//     download this file with the parameters
//
//             nqc -Trcx2 -d test1.nqc
//
//     ---------------------------------------



// Turn off the RCX
// I can't find this in the rcx22 api
void SleepNow()   { asm { 0x60 }; }  // switch off immediately



int i;


task main() {

      PlaySound (SOUND_UP);
      Wait (100);

      SetUserDisplay (100, 0);         // #1  displays 100
      SelectDisplay (DISPLAY_USER);
      PlaySound (SOUND_CLICK);
      Wait (100);

      SetUserDisplay (200, 1);         // #2  displays 20.0
      SelectDisplay (DISPLAY_USER);
      PlaySound (SOUND_CLICK);
      Wait (100);

      SetUserDisplay (300, 2);         // #3  displays 3.00
      SelectDisplay (DISPLAY_USER);
      PlaySound (SOUND_CLICK);
      Wait (100);

      SetUserDisplay (400, 3);         // #4  displays 0.400
      SelectDisplay (DISPLAY_USER);
      PlaySound (SOUND_CLICK);
      Wait (100);

      i = 100;                         // #5  works also with variables
      Display (i, 0);                  //     displays 100 as #1 did
      PlaySound (SOUND_CLICK);
      Wait (100);

      i += 100;
      Display (i, 1);                  // #6  displays 20.0 as #2 did
      PlaySound (SOUND_CLICK);
      Wait (100);

      i += 100;
      Display (i, 2);                  // #7  displays 3.00 as #3 did
      PlaySound (SOUND_CLICK);
      Wait (100);

      i += 100;
      Display (i, 3);                  // #8  displays 0.400 as #4 did
      PlaySound (SOUND_CLICK);
      Wait (100);

      Display (BatteryLevel(), 3);     // #9  displays the battery
                                       //     level (in Volts)
      PlaySound (SOUND_CLICK);
      Wait (100);

      Display (Program(), 0);          // #10 should show one less
                                       //     than the prgm number
      PlaySound (SOUND_CLICK);
      Wait (100);

      Display (FirmwareVersion(), 2);  // #11 should show 3.26 if
                                       //     you use firm0326.lgo
      PlaySound (SOUND_CLICK);
      Wait (100);

      SelectDisplay(DISPLAY_WATCH);    // #12 should show the current time
      Wait (20);
      PlaySound (SOUND_CLICK);
      Wait (100);

      SetWatch (12, 34);               // #13 sets watch to 12.34
//     SelectDisplay(DISPLAY_WATCH);    //     watch is already shown
      PlaySound (SOUND_CLICK);
      Wait(100);

      PlaySound (SOUND_DOWN);
      SleepNow ();
}

--

-------------------------------------------------
Ralf Krause
Bertha-von-Suttner-Gesamtschule Dormagen
Marie-Schlei-Strasse 6
41542 Dormagen
Germany

http://www.bvsdormagen.de
mailto:rkra@gmx.de
-------------------------------------------------



Message has 1 Reply:
  Re: NQC 2.2 a1 available for public test
 
(...) Lego's concept of 'local' variables are variables that are context swapped per task, as opposed to the normal variables that are not context swapped (all tasks share the same vars). Thus, 'local' RCX variables are local to the task. This is a (...) (25 years ago, 8-May-00, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Re: NQC 2.2 a1 available for public test
 
Hi, thank you Dave for the new version 2.2 a1 of NQC. I 've done some test because I want to display some messages. Have a look to the attached test1.nqc. Ralf (...) (25 years ago, 6-May-00, to lugnet.robotics.rcx.nqc)

22 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