Menu

AND conditions

Help
2008-11-30
2013-05-30
  • Nobody/Anonymous

    having some issues with this line..

    [code]

    #define BUTTON1 GPIO.2
    dir BUTTON1 in

    If BUTTON1 on AND Flashed = 0 Then gosub Flash1

    [code]

    Its giving me this when I compile: "Error: GCASM: Symbol 5.20 has not been defined"

    and what is 5.20 its nowhere near line 5, but it is 20 char into the line it is on?? but i know its this line thats causeing the issue b/c if i REM it out the code compiles fine.

     
    • Nobody/Anonymous

      I don't prefer combining conditionals as it adds a lot more code over two if's.  Since it's "and", just break into two if statements.
      If Button1 On Then
        If Flashed = 0 Then

       
    • Tom

      Tom - 2008-11-30

      Evening

      I can't recall exactly what it was I read, or where I'm afraid at the moment, but I'm sure I recall something about using bit level tests in IF statements.

      I'll try and find it again, but I think combining bit tests with other tests in a single IF statement is not supported.  A bit test on it's own is fine, and having two byte size comparisons joined with AND is OK, just not a bit and a byte comparison joined.

      Long and short of it, if you break the statement into two parts as recommened by the previous poster, you should be OK.

      Tom

       
    • Nobody/Anonymous

      yeah your right Tom its on the conditions page of the help wish i cought it the first time i looked it over, or the second time even.. i guess until you need something it doesnt hit you right away, lol

      reply #2 fixed it, now im working out other bugs i created, lol

      "It is also possible to test individual bits in conditions. To do this, specify the bit to test, then 1 or 0 (or ON and OFF respectively). Presently there is no way to combine bit tests with other conditions - NOT, AND, OR and XOR will not work."

      Thanx everyone,
      Bill

       
    • Nobody/Anonymous

      ok now its gotten deep, lol... i think i have tried every combo and arangemnt but the one that will work :D

      Ind = 0
      Flashed = 0

      'this section works out fine:
      '(1st IF)
          If Ind = 0 then gosub Ind1
      '(2nd If)
               If Button1 off Then
          If Flashed = 0 then gosub Flash1
               end if
      'here doesntwork out:
      '(3rd If)       
               If Go_Button on Then
               set PIN_7 on then
               Flashed1 = 0
               end if

      '============================================================

      sub Ind1
              set Ind_Led off
              PulseOut Ind_Led , 20ms   
              wait Mode_Blink_Time
              PulseOut Ind_Led , 20ms
              wait Mode_Blink_Time
              Ind = 1
      return

      sub Flash1
              set PIN_7 off   
              wait 30 ms
              set PIN_7 on
              wait 30 ms
              Ind = 1
      return

       
    • Nobody/Anonymous

      Think about the syntax a little more.  If you indent each if (add 2 spaces to each line between the then and end if statement), it will make more sense and easier to see.  Each if needs an end if.  You are missing an end if in the second if.  The third if has the then statement that doesn't match anywhere.  Your close.

       
    • Nobody/Anonymous

      Oops.  Disregard the missing end if in the second.  It's ok.  The problem is with the extra then in the third.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.