To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.spyboticsOpen lugnet.robotics.spybotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Spybotics / 95
94  |  96
Subject: 
Re: variables and spybot
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Mon, 9 Sep 2002 18:01:05 GMT
Viewed: 
5261 times
  
In lugnet.robotics.spybotics, André Koopman writes:
As a newbee I was wondering about the use of Brackets [ ] in the world
subroutine instead of the normal ( ) , what is the difference between both
systems ?

For reasons unknown to me the designers of MindScript decided to use array
property notation much like that used in Delphi to implement various
features in the Spybot firmware.  world should not be thought of as a
subroutine.  It is a two-dimensional array property.  The same goes for
target[i], eeprom[i], led[i], link[i], ping[i], and message[i] (except they
are 1-dimensional array properties).  Some are read-only, others are read/write.

Also the use of nIndex is not very clear, is this a dummy variable ?

The find looping construct actually sets the value of nIndex - which could
be any local or global variable you choose.  Each time through the find loop
this variable is updated to the index of the "found" item.  You can then
obtain information about this item via world[nIndex, something] or you can
set target = nIndex and obtain the same information via target[something].
So nIndex is something like a for-loop (which doesn't exist in MindScript)
index variable.

Watching the value of a variable in the watch window (BrickCC) I discovered
that without the use of #include “globals.h” the first variable used by the
bot or BrickCC is var 31 every next variable used gets a lower number. Var
30 , var 29 and so on.

The variable number that the compiler chooses for your named global
variables is not something you should rely on.  As you noticed, variables
declared in any include file will adjust the actual global variable number
chosen for your variables.  If you want to use a specific variable number
then you should use pointers to variables.

Local variables should not (as far as I am aware) show up in the BricxCC
watch window at all.  I haven't added support to BricxCC for watching local
variables.  The only way locals should show in the watch window is if they
actually use the global variable slots - which I thought they did not do.

Question: is there a way to point to a special variable location when you
use local variables ?

I do not know (yet) exactly how local variables work and have not decided
how to support viewing them in BricxCC.

In your last message you used syntax like n ^ and n+ and n- , has this any
relation with my question ?

I used n^ (pointer dereferencing) to set the value of the variable pointed
to by n.  My local variable n had the value of 1-14.  Setting n^ when n = 0
will set the value of global variable zero.  Fortunately, my program code
did not have any global variables (which the compiler might have assigned to
one of those 14 variables) so I wasn't clobbering anything accidentally.
The other syntax I used was += and -= which are the most optimal means for
writing n = n + something or n = n - something.  There are also *=, /=, |=,
and &=.

Last question about iShortID, I get the value 3, is this value the number of
the secure channel between the bot and the controller ?

It has nothing to do with the secure channel to the best of my knowledge.
Exactly what it is and whether the ID can be changed are both things I do
not yet know.

HTH,

John Hansen
http://members.aol.com/johnbinder/bricxcc.htm



Message has 1 Reply:
  Re: variables and spybot
 
(...) Something tricky about MindScript is the way it handles whitespace around certain things. I just noticed that I had written: n^= 0 in my program. For a minute or two I was thinking that was using a ^= operator on the variable n. But there (...) (22 years ago, 9-Sep-02, to lugnet.robotics.spybotics)

Message is in Reply To:
  variables and spybot
 
Hello John. Thanks again for the info about IR related syntax . With your information I wrote a small target finding related program. The bot produces four different sounds depending on the distance between the bot and the controller. I used the (...) (22 years ago, 9-Sep-02, to lugnet.robotics.spybotics)

3 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