Answers.Body: <p>First guess: the wait for button command is bad practice.  Well, not the whole thing, just the use of the middle button.  The reason is that that button is also used to start the program.  The program may be jumping past the wait for and saving to "Midpoint" before humans notice that the program has started. Try any other brick button.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-18T17:24:52.510Z
Answers.LastActivityDate: 2017-09-18T17:24:52.510Z
Answers.UserDisplayName: dfrevert
Answers.Body: <p>Your example doesn't read a RLI value.  It reads and stores a color index value (0 through 8).  This wouldn't stop you using the variable, but the value may not be what you expect.</p>
  
  <p>Variables are global.  You can read or write them anywhere in your program.  The value of the variable is the last value written.  Variables are not persistant.  When your program ends the variable goes away.  This means you cannot use variables to set a value and use it in a different program.  To do something like that use a file,</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-15T13:39:13.883Z
Answers.LastActivityDate: 2018-01-15T13:39:13.883Z
Answers.UserDisplayName: Dean Hystad
Body: <p>I've seen teams, mostly in the world festival do this, and what they do is they program the robot so that when a brick button is pressed, the robot detects a value (usually RLI) and it is used later in the program. My program looks something like this so far.<a href="https://i.sstatic.net/7zkdG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7zkdG.png" alt="enter image description here"></a></p>
  
  <p>Am I on the right track? Is this program correct? Or am I completely wrong?</p>
  
  <p>The program runs OK, but the variable can't be used later in the program.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-18T22:17:36.393Z
Comments.Text: Hi, the program runs but the variable can't be used later in the program. Thanks!
Comments.UserDisplayName: Richard 4707
Tags: <ev3><programming><colour><sensor>
Title: How To Plug Detected Light Values into Variables and Still be Usable in Programs in EV3-G
UserDisplayName: Richard 4707
ThreadText: # How To Plug Detected Light Values into Variables and Still be Usable in Programs in EV3-G
  
  (Asked by: username_0 on 2017-09-18)
  
  I've seen teams, mostly in the world festival do this, and what they do is they program the robot so that when a brick button is pressed, the robot detects a value (usually RLI) and it is used later in the program. My program looks something like this so far.[![enter image description here](https://i.sstatic.net/7zkdG.png)](https://i.sstatic.net/7zkdG.png)
  
  Am I on the right track? Is this program correct? Or am I completely wrong?
  
  The program runs OK, but the variable can't be used later in the program.
  
  **Tags:** ev3, programming, colour, sensor
  
  > **Comments:**
  > **username_0**: Hi, the program runs but the variable can't be used later in the program. Thanks!  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-09-18. Score: 2
  
  First guess: the wait for button command is bad practice. Well, not the whole thing, just the use of the middle button. The reason is that that button is also used to start the program. The program may be jumping past the wait for and saving to "Midpoint" before humans notice that the program has started. Try any other brick button.
  
  
  ---
  
  ### Answer by username_2 on 2018-01-15. Score: 2
  
  Your example doesn't read a RLI value. It reads and stores a color index value (0 through 8). This wouldn't stop you using the variable, but the value may not be what you expect.
  
  Variables are global. You can read or write them anywhere in your program. The value of the variable is the last value written. Variables are not persistant. When your program ends the variable goes away. This means you cannot use variables to set a value and use it in a different program. To do something like that use a file,
  
  
  ---
  
  