Posted: Mon Nov 28, 2011 5:05 pm Post subject: im having a syntax error (please run the program and you will see it.
Turing:
var player1, player2, play1, gender1, gender2 :string var word1, word2, word3, word4, word5 :int var stream :int var wordList :flexiblearray1.. 20ofstring var declare :int var choices :string var p1, p2 :string var first, second :string View.Set("graphics:700;800")
% procedure torso
drawfillbox(300, 350, 350, 540, 121) end torso
% procedure head
drawfilloval(325, 600, 60, 70, 48) end head
%still working on finishing procedure rightArm
%drawfillbox (,91) end rightArm
%till here, and the rest of the body parts procedure choice1
var choice :string(1) locate(30, 10) put"Press any key to continue..." getch(choice) cls end choice1
%
procedure playgame
colorback(91) color(48) cls if gender1 ="m"or gender1 ="M"then put"Welcome to the game Mr. ", player1
elsif gender1 ="f"or gender1 ="F"then put"Welcome to the game Ms. ", player1
endif % if gender2 ="m"or gender2 ="M"then put"Welcome to the game Mr. ", player2
elsif gender2 ="f"or gender2 ="F"then put"Welcome to the game Ms. ", player2
endif % open: stream, "WordList.txt",get loop exitwheneof(stream) get: stream, wordList (upper(wordList)) new wordList, upper(wordList) + 1 endloop % put"The computer is now generating your word."
declare := Rand.Int (1, 20) put wordList (declare) put"Who will be choosing a letter first? [yes for first, no for last]" put"Player1? "..
get p1
put"Player2? "..
get p2
if p1 ="yes"then
p1 := first
put"Player 1 will go first." elsif p1 ="no"then
p1 := second
put"..." endif if p2 ="yes"then
p2 := first
put"Player 2 will go first." elsif p2 ="no"then
p2 := second
put"..." endif end playgame
% procedure game
put"Ready to play Hangman? [Y or N] "..
get play1
cls end game
% put"Player1, what is your lastname? "..
get player1
put"Player1, what is your gender? [M for male, F for female] "..
get gender1
%
choice1
% put"Player2, what is your lastname? "..
get player2
put"Player2, what is your gender? [M for male, F for female] "..
get gender2
%
choice1
%
if play1 ="y"or play1 ="Y"then
playgame
elsif play1 ="n"or play1 ="N"then put"Well then, good day to you sir!" else put"You have to enter 'y' or 'n' " put"Let's try that again..." Time.Delay(2000) cls
game
endif View.UpdateArea(0, 0, maxx, maxy)
Please specify what version of Turing you are using
4.1.1a
It says it the variable has no value + bits to answerer/helper asap please and karma!
Sponsor Sponsor
Velocity
Posted: Mon Nov 28, 2011 5:41 pm Post subject: RE:im having a syntax error (please run the program and you will see it.
anyone?? please. still want to know.
Insectoid
Posted: Mon Nov 28, 2011 5:45 pm Post subject: RE:im having a syntax error (please run the program and you will see it.
Quote:
It says it the variable has no value
Well, there's your problem. Turing told you what you did wrong. Try reading the error messages and figuring out what they mean.
Also, this isn't a syntax error. It's a logic error.
Aange10
Posted: Mon Nov 28, 2011 5:45 pm Post subject: RE:im having a syntax error (please run the program and you will see it.
You forgot the part where you tell us what you've tried.
ttm
Posted: Mon Nov 28, 2011 6:57 pm Post subject: Re: im having a syntax error (please run the program and you will see it.
I believe it's because your wordList array already has an initial size of 20, but when you read new values, you increase its size. Try changing line 4 of your program to read:
code:
var wordList : flexible array 1 .. 1 of string
ttm
Posted: Mon Nov 28, 2011 7:03 pm Post subject: Re: im having a syntax error (please run the program and you will see it.
Also, you forgot to set values for your first and second variables. From the looks of it, you can set them to pretty much anything.
code:
var first : string := "aoeuidhtns-"
var second : string := "etaoinshrdlcu"
Velocity
Posted: Tue Nov 29, 2011 12:01 pm Post subject: RE:im having a syntax error (please run the program and you will see it.
ttm you gave me the best answer ever!!! Thank you so much! I love you.
Raknarg
Posted: Tue Nov 29, 2011 12:47 pm Post subject: RE:im having a syntax error (please run the program and you will see it.
I think it still make make it a problem if the wordList is 1 .. 1, try changing it to 1 .. 0 (aka an array with no elements to begin with)
Sponsor Sponsor
ttm
Posted: Tue Nov 29, 2011 4:12 pm Post subject: Re: im having a syntax error (please run the program and you will see it.
Nope. In his code, he assigns before expanding the array, so there must be 1 blank spot first. See:
code:
loop
exit when eof (stream)
get : stream, wordList (upper (wordList))
new wordList, upper (wordList) + 1
end loop
Raknarg
Posted: Tue Nov 29, 2011 5:28 pm Post subject: RE:im having a syntax error (please run the program and you will see it.
Why doesnt he resize it first and then assign it? He probably shouldnt have more elements than he's going to use.
ttm
Posted: Tue Nov 29, 2011 5:42 pm Post subject: Re: im having a syntax error (please run the program and you will see it.
1 extra element isn't going to make a difference.
Also no @Velocity, no prob
Velocity
Posted: Wed Nov 30, 2011 11:25 am Post subject: RE:im having a syntax error (please run the program and you will see it.
@ttm
@raknarg i want to add the fact to allow the user to choose a letter in the word and if they get it right it pops up in a blank line of the word, like any other hangman game, how would i go about doing this?
Dragon20942
Posted: Wed Nov 30, 2011 1:14 pm Post subject: RE:im having a syntax error (please run the program and you will see it.
Use an array to store each letter of the word, then check if any of the indexes are the guessed letter using a for loop.
Velocity
Posted: Wed Nov 30, 2011 10:57 pm Post subject: RE:im having a syntax error (please run the program and you will see it.
what do you mean by "check if any of the indexes are the guessed letter" - how would i go about donig that?
Aange10
Posted: Wed Nov 30, 2011 11:25 pm Post subject: Re: RE:im having a syntax error (please run the program and you will see it.
Velocity @ 30/11/2011, 9:57 pm wrote:
what do you mean by "check if any of the indexes are the guessed letter" - how would i go about donig that?