Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReGaHss: Abbruch von geschachtelten foreach / while-Schleifen mittels "break" #878

Closed
mabel-gh opened this issue Jul 23, 2020 · 1 comment
Labels
🐛 bug-report Something isn't working 🏷️ ReGaHss This refs the ReGaHss component 👍 important This is an important issue/ticket with high priority

Comments

@mabel-gh
Copy link

mabel-gh commented Jul 23, 2020

Describe the bug
Wenn mehrere Schleifen verschachtelt programmiert werden, ist es aktuell entscheidend, an welcher Stelle der Abbruchbefehl "break" verwendet wird, damit das Programm überhaupt ausgeführt wird. Das sollte aber so nicht sein! siehe Beispiel unten

To Reproduce
Steps to reproduce the behavior:

  1. Folgendes Beispielskript funktioniert problemlos:
WriteLine("Start Skript!");
string LISTE1 = ("A\tB\tC\tD");
string ELEMENT1; 
string LISTE2 = ("1\t2\t3\t4");
string ELEMENT2; 
boolean GEFUNDEN = false;
foreach(ELEMENT1, LISTE1) 
{
  Write("-");
  if(GEFUNDEN) { Write("break1"); break; }
  
  foreach(ELEMENT2, LISTE2)
  {
    Write(".");
    if((ELEMENT2 == 3) && (ELEMENT1 == "C")) { GEFUNDEN = true; }
  }
            
  Write("x");
  ! if(GEFUNDEN) { Write("break2"); break; }
}
WriteLine("\nEnde Skript");

und es wird folgendes korrektes Resultat zurückgegeben:

Start Skript!
-....x-....x-....x-break1
Ende Skript
  1. Sobald nun jedoch die Zeile mit dem break2 nach dem Write("x"); auskommentiert wird (d.h. das ! davor entfernt wird kommt es fälschlicherweise zu folgendem Syntax-Error:
Error 1 at row 19 col 41 near ^; }
}
WriteLine("\nEnde Skript");
Error 1 at row 19 col 41 near ^; }
}
WriteLine("\nEnde Skript");
Error 1 at row 19 col 41 near ^; }
}
WriteLine("\nEnde Skript");

Expected behavior
Es sollte egal sein, an welcher Stelle der äußeren Schleife der Abbruch via break erfolgen soll!

Screenshots
If applicable, add screenshots to help explain your problem.

System information (please complete the following information):

  • Version [RaspberryMatic [3.51.6.20200613]
  • Hardware [RaspberryPi3]

Additional context
Das exakt selbe Probleme existiert mit der Verwendung von continue statt break. D.h. beide Statements verlieren nach der zweiten inneren Schleife Ihre Gültigkeit und können fälschlicherweise nicht mehr angewendet werden.

@jens-maus jens-maus added 🐛 bug-report Something isn't working 🏷️ ReGaHss This refs the ReGaHss component ❓ undecided No decision to accept or reject ticket yet labels Jul 26, 2020
@jens-maus jens-maus changed the title Abbruch von geschachtelten foreach / while-Schleifen mittels "break" [ReGaHss]: Abbruch von geschachtelten foreach / while-Schleifen mittels "break" Jul 26, 2020
@jens-maus jens-maus changed the title [ReGaHss]: Abbruch von geschachtelten foreach / while-Schleifen mittels "break" ReGaHss: Abbruch von geschachtelten foreach / while-Schleifen mittels "break" Aug 1, 2020
@jens-maus jens-maus added 👍 important This is an important issue/ticket with high priority and removed ❓ undecided No decision to accept or reject ticket yet labels Aug 2, 2020
@jens-maus jens-maus added this to the next release milestone Aug 2, 2020
@jens-maus
Copy link
Owner

Starting with ReGaHss R1.00.0388.0223 this issue with break and continue uses after a nested foreach() or while() loop should be solved. Thanks for the bugreport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug-report Something isn't working 🏷️ ReGaHss This refs the ReGaHss component 👍 important This is an important issue/ticket with high priority
Projects
Development

No branches or pull requests

2 participants