Page 1 of 1

Copy Contents of one Field to Another

Posted: Mon Aug 30, 2010 8:57 am
by Bantymom
Hello again...

Yes, I'm stuck again.

My game now creates a list of words to show to the children to spell. As they spell a word correctly, that word is deleted from the list.

Here is the code for that part:

on RunGame
put 0 into gAttempts
get any word of field "TempList" of card "List Card"
put it into gWord

move field "word" to the loc of gButton in 1 tick
set the locktext of field "word" to true
put gWord into field "word"
show field "word"
wait 2 seconds
put empty into field "word"

set the locktext of field "word" to false
click at the loc of field "word"
end RunGame

on returnInField
put field "word" into tAnswer
--that is the word the students typed into the field, which is then compared to the original word
select empty
if tAnswer = gWord then
put yes into field "word"
hide button gButton
hide field "word" -- this with the above reveal a piece of the picture
replace gWord with empty in field "List 1" of card "List Card"
--removes the word from the list, but delets parts of other words that match as well!

I was using "any" because it seemed the easiest way to randomize the word selection but it looks like I will have to randomize a number and ask for a word by number instead, then after deleting that word, move up the other words and select a random number from 1-19 instead of from 1-20. It would be easier, however, if I could instead delete only whole words instead of parts of words.

Suggestions?

*sets out chocolate-chip cookies as a bribe*

Thanks,
Banty

Re: Copy Contents of one Field to Another

Posted: Mon Aug 30, 2010 10:28 am
by bn
Bantymom,

instead of

Code: Select all

replace gWord with empty in field "List 1" of card "List Card"
put this

Code: Select all

 put wordOffset(gWord,field "List 1") into tWordNumber
put empty into word tWordNumber of field "List 1"
this assumes that you only have unique words "in List 1", multiple occurences of a word would be a little different.
--removes the word from the list, but delets parts of other words that match as well!
that is a very useful aspect of replace, it just does not work if you want to operate on words
regards
Bernd

Re: Copy Contents of one Field to Another

Posted: Mon Aug 30, 2010 12:45 pm
by Mark
Hi,

Here's a simple routine to delete all words gWord from a field.
lock screen
repeat with x = number of words of fld "Word List" down to 1
if word x of fld "Word List" is gWord then
delete word x of fld "Word List"
end if
end repeat
unlock screen
Best,

Mark