Hi all,
I can't figure out why "if (userinput=word)" is not triggering It's corresponding "then".
Here is my code -
file := "M:My\txtfile\location.txt" ; location of word list
FileRead, LoadedText, %file% ; load list
Sort, LoadedText, random ; randomize words in list
Stringsplit, Array, LoadedText,`n ; Split into array
Loop, ; Get words one at a time
{
Word = % Array%A_Index%
Loop, ; Prompt the current word
{
InputBox, UserInput,%Word%,, , 300,100,0,880
if (Userinput = "End") ; Provide an exit
Exitapp
if (userinput=word) ;**Move on to the next word
Break
else ;Continue prompting same word
Continue
}
}
Exitapp
The goal is to make a flashcard script that takes words from a text file, prompts them in a random order, and moves onto the next word only after writing the prompted word into the userinput box (if it was real flashcards the front and the back would have the same words on them). I want to use the script to practice custom text expansions.
I've tried every combination of %'s and :='s and searched for the solution in as many ways as I can think to phrase it with no success if someone could point me in the right direction I'd greatly appreciate it!
If if two strings are equal (words/sentences not numbers) - Can't figure out how to trigger then Topic is solved
-
- Posts: 440
- Joined: 28 Apr 2018, 21:59
Re: If if two strings are equal (words/sentences not numbers) - Can't figure out how to trigger then
Code: Select all
file := "M:My\txtfile\location.txt" ; location of word list
FileRead, LoadedText, %file% ; load list
Sort, LoadedText, random ; randomize words in list
arrWords := StrSplit(LoadedText, "`r`n")
for i,v in arrWords {
InputBox, UserInput,v,, , 300,100,0,880
if (Userinput = "End") ; Provide an exit
Exitapp
if (Userinput = v) ;**Move on to the next word
Break
else ;Continue prompting same word
Continue
}
Exitapp
Re: If if two strings are equal (words/sentences not numbers) - Can't figure out how to trigger then Topic is solved
Code: Select all
file := "M:My\txtfile\location.txt" ; location of word list
FileRead, LoadedText, %file% ; load list
Sort, LoadedText, random ; randomize words in list
Loop, Parse, LoadedText, `n, `r
{
Loop
{
InputBox, UserInput, % A_LoopField,,, 300,100,0,880
if (ErrorLevel = 1) ; user pressed cancel
break 2
else if (UserInput = A_LoopField) ; correct word. move to next word
break
else ; wrong word. repeat same word
continue
}
}
ExitApp
Re: If if two strings are equal (words/sentences not numbers) - Can't figure out how to trigger then
check with MsgBox what LoadedText contains.
then correct the path.
replace file := "M:My\txtfile\location.txt"
with file := "M:\My\txtfile\location.txt"
also untested.
then correct the path.
replace file := "M:My\txtfile\location.txt"
with file := "M:\My\txtfile\location.txt"
also untested.
Re: If if two strings are equal (words/sentences not numbers) - Can't figure out how to trigger then
Thank you very much for your responses ! It works perfectly now