C
C#3y ago
TheRanger

Loopcounter issue c sharp

what kind of issue?
19 Replies
TheRanger
TheRangerOP3y ago
fyi loopcounter == maximumLoop || loopcounter > maximumLoop can be simplified as loopcounter >= maximumLoop @MaGiiKx
MaGiiKx
MaGiiKx3y ago
MaGiiKx
MaGiiKx3y ago
this issue
TheRanger
TheRangerOP3y ago
that count is still 0?
MaGiiKx
MaGiiKx3y ago
basically the loopcounter is not incrementing to stop at maximum loop yes thats the problem nothing is incrementing the only thing that is recognised after its parsed is the maximumloop
TheRanger
TheRangerOP3y ago
try debugging $debug
MODiX
MODiX3y ago
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
TheRanger
TheRangerOP3y ago
altho u are printing the loop counter before you increment it and u have a redundant if condition
if (lines[count] == "end" && loopcounter != maximumLoop)
{
count = loopend;
loopAlert = false;
break;
}
else if (lines[count] == "end" && loopcounter != maximumLoop )
{
loopcounter++;
loopend = count++;
count = loopstart;
count++;
break;

}
if (lines[count] == "end" && loopcounter != maximumLoop)
{
count = loopend;
loopAlert = false;
break;
}
else if (lines[count] == "end" && loopcounter != maximumLoop )
{
loopcounter++;
loopend = count++;
count = loopstart;
count++;
break;

}
both if conditions do the same thing in other words, your else if will never get executed
MaGiiKx
MaGiiKx3y ago
So I should get rid of one of the if statement?
TheRanger
TheRangerOP3y ago
well do you need their logics? its up to you to know do you want to execute this piece of code
loopcounter++;
loopend = count++;
count = loopstart;
count++;
loopcounter++;
loopend = count++;
count = loopstart;
count++;
or this
count = loopend;
loopAlert = false;
count = loopend;
loopAlert = false;
or both of them?
MaGiiKx
MaGiiKx3y ago
I just want the loop to end once it’s met the max counter And if loop counter doesn’t equal to maxloop, continue looping So I would need both of them
TheRanger
TheRangerOP3y ago
what loop?
MaGiiKx
MaGiiKx3y ago
ill show you what the application looks like
MaGiiKx
MaGiiKx3y ago
MaGiiKx
MaGiiKx3y ago
basically the user is able to enter the command loop x and a shape and end it should draw the shape x amount of times specified in the loop
TheRanger
TheRangerOP3y ago
better not debug with commandcheck.AppendText and use this one $debug
MODiX
MODiX3y ago
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
TheRanger
TheRangerOP3y ago
there's a flaw in your logic, thats all
MaGiiKx
MaGiiKx3y ago
oh, i tried debugging with console, but it says argument out of range ive not been able to fix it

Did you find this page helpful?