Variable Scope and fixing error: '_______' was not declared in this scope?

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 พ.ย. 2024

ความคิดเห็น • 41

  • @bassman2162
    @bassman2162 3 ปีที่แล้ว +11

    As a long time programmer, this is one of the best explanations of variable scope I’ve seen. You should show an example of declaring two variables with the same name in different scopes to show they are separate variables. It would have been nice to see an example of passing variables and an example to go with the part about global variable problems in larger programs. These examples would help explain scope in using variables in included functions. I guess you can only squeeze so much into these videos.
    Excellent video, I would like to have seen it when I was first starting. I will pass it along to new programmers like my son.

  • @stl7694
    @stl7694 2 ปีที่แล้ว +4

    Massive help. I was having a scope error issue with a function and didn't understand. I was missing a closing bracket but would not have found it without your help. Thank you so much.

  • @ADHDbuilt
    @ADHDbuilt 3 ปีที่แล้ว +3

    I've been banging my head against the wall. This really helps!

  • @ryansmithza
    @ryansmithza 3 ปีที่แล้ว +5

    LIGHT BULB 🙈🙈🙈🙈🙈
    Sometimes when you don't know what you don't know you can spend days or weeks trying to fix some code that should be really simple. I think this could have been the reason many MANY attempts at making some Arduino code failed! 🙈
    Thanks for the video, it makes perfect sense, now 🤪

  • @kurtdecena8681
    @kurtdecena8681 2 ปีที่แล้ว +3

    i love this video your explanation is so simple and its quite easy to understand

  • @DodgyBrothersEngineering
    @DodgyBrothersEngineering 3 ปีที่แล้ว +3

    Another great video, interesting how the If or While allows you to pass an external local variable. Passing variables might have been a nice inclusion to this video.

  • @jamworthy14
    @jamworthy14 ปีที่แล้ว +2

    i was frustrated for 25 minutes, it was giving me this error. and then later i realized that i forgot to put the F in scan.

  • @lexxatech
    @lexxatech 2 ปีที่แล้ว +1

    When my problem is solved my heart rejoices

  • @techtalk7051
    @techtalk7051 3 ปีที่แล้ว +1

    Thank you so much dude ,this video help me a lot

  • @Laugh_out_loud_hahah
    @Laugh_out_loud_hahah ปีที่แล้ว +1

    thx i really needed this

  • @Evelisk
    @Evelisk 2 ปีที่แล้ว +2

    Can you tell me why I am getting result1 and result2 "not declared in this scope in function void loop()"?
    double value1 = 5.5;
    double value2 = 4.4;
    double result1;
    int result2;
    void setup(){
    Serial.begin(9600);
    }
    void loop(){
    result1 = (value1 + value2);
    result2 = (value1 + value2);
    Serial.println(" ");
    Serial.print(result1);
    Serial.print(" ");
    Serial.println(result2);
    delay(500);
    }

    • @programmingelectronics
      @programmingelectronics  2 ปีที่แล้ว +1

      Hmmm. I am not sure. It is compiling ok on my machine.
      This is a stretch, but did the code get copied and pasted in? Maybe there is a hidden character in result1 and result2 in the loop that is different from above. I don't know though...
      Could you paste the entire error in?

    • @Evelisk
      @Evelisk 2 ปีที่แล้ว +1

      @@programmingelectronics It was tinkercad arduino simulator acting up actually lol, But thank you so much for taking your time to look at my issue!

  • @RicardoPenders
    @RicardoPenders 3 ปีที่แล้ว

    So with that last example genieBreath when you put it in between the first and the second function, it would be good for the last two functions right and not for the first one right?

  • @tomatoasmr5258
    @tomatoasmr5258 2 ปีที่แล้ว +1

    it telling mine like this, Its a simple button to turn on and off the led. ' ledPin ' was not declared in this scope

    • @programmingelectronics
      @programmingelectronics  2 ปีที่แล้ว

      In the error message does it have a line number? If so, check the line number, and see if you accidentally misspelled ledPin from how it was first declared above setup() -> that may be the issue.

    • @tomatoasmr5258
      @tomatoasmr5258 2 ปีที่แล้ว +1

      @@programmingelectronics Ya that was the problem, Again thanks so much for ur reply :) Have a nice day ahead.

    • @programmingelectronics
      @programmingelectronics  2 ปีที่แล้ว

      @@tomatoasmr5258 Glad it helped!

  • @ntontouu
    @ntontouu ปีที่แล้ว

    yeah what if i create my variables outside the loop and setup, you know making them global and i still get the same error ??

  • @rithikadithi1592
    @rithikadithi1592 3 ปีที่แล้ว +1

    Sir ,How can I add vertical lines between curly bracket in arduino ide, i mean settings

    • @programmingelectronics
      @programmingelectronics  3 ปีที่แล้ว +1

      That’s the new Arduino IDE 2.0 Beta, which adds those. You can download it from the Arduino website. Also, the online Arduino editor adds those vertical lines as well.

    • @rithikadithi1592
      @rithikadithi1592 3 ปีที่แล้ว +1

      @@programmingelectronics thank you so much for reply sir🙏

  • @RBJxDeathRepare
    @RBJxDeathRepare 4 หลายเดือนก่อน

    char.cpp: In member function 'void CHARACTER::ApplyPoint(BYTE, int, bool)':
    char.cpp:4757:8: error: 'APPLY_ATTBONUS_SHADOW' was not declared in this scope; did you mean 'APPLY_ATTBONUS_SHAMAN'?
    4757 | case APPLY_ATTBONUS_SHADOW:

  • @izzathafiz5947
    @izzathafiz5947 2 ปีที่แล้ว

    hello why positive not declared ? how to fix it ?

  • @mehradaf8098
    @mehradaf8098 3 ปีที่แล้ว +1

    it is very useful

  • @كثيرالطيب
    @كثيرالطيب 3 ปีที่แล้ว +1

    Thanks🇰🇼احسنت

  • @adnanhamid3397
    @adnanhamid3397 2 ปีที่แล้ว +1

    i love you