Added: 5 months ago
From: hamoid
Views: 229
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (6)

Sign In or Sign Up now to post a comment!
  • and how to make local variable to global ?

  • @vitserp You can make a local variable global while writing the program, as far as I know you can't do that once the program has started. Making a local variable global is very easy, you just move the declaration of the variable from inside a function to the beginning of your program. myvar in this example is local: void setup() { int myvar = 3; } and here it's global: int myvar; void setup() { myvar = 3; }

  • @vitserp Even you can't change the type of a variable once the program is running, you can copy the value of a local variable into a global variable and the other way around. For example: int myglobalvar = 3; void setup() { int mylocalvar = 77; myglobalvar = mylocalvar; } This way the variable myglobalvar will have a value of 77. You can access myglobalvar from inside any function in your program (setup(), draw(), mousePressed(), ...)

  • @hamoid thanks good explanation :)

  • congratulations for your 50th video, a great (and big) work!

  • @gumli Thank you! :)

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more