Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / while/endwhile loop

Author
Message
bmetcoder
15
Years of Service
User Offline
Joined: 26th Sep 2010
Location:
Posted: 4th Dec 2010 05:36
im having trouble figuring out why my compiler is telling me that my enwhile is out of place??? can someone look over this to tell me what they see? thanks.
MSon
22
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Earth, (I Think).
Posted: 4th Dec 2010 14:59 Edited at: 4th Dec 2010 15:11
i bmetcoder, i've not tried compiling it, but just ad a quick scan threw your code and noticed 2 errors that could be ausing the problem

At line 169 you have this, Change Next to Next ctr


Also at line 138 you have this, but every time you use the command IF, this will also cause that error as there are insufficent EndIf's


Try this instead


Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Dec 2010 15:05 Edited at: 4th Dec 2010 15:07
The problem is that inside your while/endwhile loop you have several nested "if" clauses without corresponding endif statements. The reason you are getting that message is that the compiler "sees" the endwhile before it sees the expected endif statements (which of course are missing). If you consistently indented your code you would probably have noticed the error - or you are used to a language that has an elseif structure (in DBPro each "if" needs a matching "endif" unless you are using the single line if/then combination).

Here's the offending bit with the exta indenting and endif's added:



The compiler now gets past that part of the code - but there are other errors in your code. You'll see them when you try to compile again. Have a close look at your use of "letter", "itemletter" and the things you compare them with. Remember that strings need to be compared with strings.

Hope this helps.

Edit MSon beat me to it. Serves me right for being long-winded (as usual ).
bmetcoder
15
Years of Service
User Offline
Joined: 26th Sep 2010
Location:
Posted: 7th Dec 2010 07:58
ok so i asked for help with this code a few days back and got some useful help. however now my syntax error is telling me that i did not define the variable \"letter\" when it is clearly defined at the beginning of my code. and i did not have this issue before i added on the nested if statements to add the body parts per hang man. any suggestions?? or reasoning why this syntax is occuring? thanks!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Dec 2010 16:07
I told you before to check the following:

Quote: "but there are other errors in your code. You'll see them when you try to compile again. Have a close look at your use of "letter", "itemletter" and the things you compare them with. Remember that strings need to be compared with strings"


Have you done that? Check every occurrence of those in your code and you should see the errors yourself. Here are some hints from your code:







What exactly is "letter(x)" supposed to be?
bmetcoder
15
Years of Service
User Offline
Joined: 26th Sep 2010
Location:
Posted: 8th Dec 2010 06:28
thanks so much!! i was trying to follow the code my teacher gave from the lecture and added things i didnt need. i do have another question. i am trying to add in a seperate word array from a .txt file. i already saved it to the program file and followed the right steps. except im running into a syntax error that says my wordarray is out of place? im a little confused.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Dec 2010 11:30
Quote: "im a little confused. "


So am I. Your code compiles fine. Are you sure it was a syntax error? Or was it a runtime error?

I doubt your code will run. Have another look at this line - and check the Help file:



Remember that while/endwhile loops are executed when the condition is true.

Login to post a reply

Server time is: 2026-07-21 19:18:36
Your offset time is: 2026-07-21 19:18:36