C
C#2y ago
MaGiiKx

❔ 'if' command not working.

Hi, In my program, it uses user input to execute a command (just a mini IDE) but these commands are executed to draw shapes. I am having a problem if my case: "if" and my case "endif". I have attached an image to this post. the explanation of the commands : moveto 200 200 (this sets the location of the coordinates to 200, 200) var size 10 (this declares a variable called size with the value of 10) If 10 > 20 (if 10 is greater than 20) Loop 10 (it will draw the shape 10 times) Circle size (this will draw circle with the value retrieved from the variable called size) size size + 10 (each time circle is drawn, it will increase variable size by 10. End (the loop ends here) Endif (if statement ends here) my problem is, 10 is not greater than 20, so nothing below the if command should be executed. the code is below. https://hastebin.com/novohajilo.http
Hastebin: Send and Save Text or Code Snippets for Free | Toptal®
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
23 Replies
MaGiiKx
MaGiiKx2y ago
basically in this set of execution commands. it looks like
if 10 > 20
if 10 > 20
is able to read upto the next line which is to
loop 10
loop 10
and anything after that it doesnt read i say this because, it doesnt loop the circle 10 times Which is a good thing , because it shouldn’t
Jester
Jester2y ago
whats not working? its not looping bcuz it shouldnt bcuz 10 isnt greater than 20
MaGiiKx
MaGiiKx2y ago
That’s good That’s what I want
Jester
Jester2y ago
whats not working like you want then?
MaGiiKx
MaGiiKx2y ago
But I don’t want the circle to draw
Jester
Jester2y ago
what programming language is this?
MaGiiKx
MaGiiKx2y ago
Because 10 is not greater than 20 It’s c sharp
Jester
Jester2y ago
the magical language in that textbox is not c# did you make that up?
MaGiiKx
MaGiiKx2y ago
No, that’s my program It’s basically for kids They can enter simple commands to draw shapes
Jester
Jester2y ago
if its your programming language then why dont you understand what the problem is?
MaGiiKx
MaGiiKx2y ago
Cos I’m stuck on this one problem in the if command?
Jester
Jester2y ago
i see no draw command in your programming language so it always draws the circle?
MaGiiKx
MaGiiKx2y ago
No lol that’s not how it works
Jester
Jester2y ago
Circle size is supposed to draw the circle?
MaGiiKx
MaGiiKx2y ago
Circle size , draws the circle Yes It shouldn’t do because 10 is not greater than 20
Jester
Jester2y ago
i dont think there is anything wrong with the if statement, but maybe somewhere else in your code in the c# code you draw a circle with radius 11? or 20 looking at the output idk what your code looks like that interpertrets your own language so i cant tell you whats wrong with it
MaGiiKx
MaGiiKx2y ago
If 10 is less than 20, it will activate a loop to draw a shape 10 times. It will draw the circle using the value retrieved from the size variable. Each time a circle is drawn it will add another 10 to the value of size variable. It will continue till it has done 10 loops then it will end the loop and then endif statement should be encountered So it begins to look like this
MaGiiKx
MaGiiKx2y ago
MaGiiKx
MaGiiKx2y ago
Just look at the shape Not the commands
Anu6is
Anu6is2y ago
You should debug your code to see where exactly things are going wrong. If you can't figure out the exact problem at least you should be able to narrow down where it's occurring Share that section of code, explain what your expectation is for it and what it's actually doing Then someone may be able to assist
MaGiiKx
MaGiiKx2y ago
I personally think it’s in the if case block or the endif case block
Anu6is
Anu6is2y ago
that's the point of the debugger, it shouldn't be that you "think"... you should know you've sent like 200 lines of code... saying you think it's in the if isn't very helpful (also, I don't think it's in the if)
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.