❔ '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
basically in this set of execution commands. it looks like
is able to read upto the next line which is to
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
whats not working? its not looping bcuz it shouldnt bcuz 10 isnt greater than 20
That’s good
That’s what I want
whats not working like you want then?
But I don’t want the circle to draw
what programming language is this?
Because 10 is not greater than 20
It’s c sharp
the magical language in that textbox is not c#
did you make that up?
No, that’s my program
It’s basically for kids
They can enter simple commands to draw shapes
if its your programming language then why dont you understand what the problem is?
Cos I’m stuck on this one problem in the if command?
i see no draw command in your programming language so it always draws the circle?
No lol that’s not how it works
Circle size is supposed to draw the circle?
Circle size , draws the circle
Yes
It shouldn’t do because 10 is not greater than 20
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
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
Just look at the shape
Not the commands
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
I personally think it’s in the if case block or the endif case block
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)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.