i can't stop loop with fileRead and strSplit Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
amrgad
Posts: 2
Joined: 29 Mar 2023, 17:31

i can't stop loop with fileRead and strSplit

Post by amrgad » 29 Mar 2023, 17:42

i have that text file amr.txt contain those lines

Code: Select all

3052226661
44
55
stop
again
when i use that code, the loop did not break on the condition

Code: Select all

FileRead, outVar, amr.txt

lineToGet := StrSplit(outVar, "`n",[A_Space, A_Tab])

Loop, % lineToGet.Length()
{
    store := lineToGet[A_Index]

    if (store = "stop") {
        ; If the current line is "stop", display a message box and break out of the loop
        MsgBox, % "it's there at line " A_index
        Break
    }
    else {
        MsgBox, % store
    }
}
i guess the variable store contain every line like that "stop
"
end with new line

how to fix that
i also couldn't use the lines contain numbers to break the loop or to do math operations with

User avatar
boiler
Posts: 16955
Joined: 21 Dec 2014, 02:44

Re: i can't stop loop with fileRead and strSplit  Topic is solved

Post by boiler » 29 Mar 2023, 18:12

You need to use `r as an omit character because your line breaks are probably `r`n. And the OmitChars parameters isn't supposed to be an array like the Delimiters parameter can be. It's supposed to just be a string of characters.

amrgad
Posts: 2
Joined: 29 Mar 2023, 17:31

Re: i can't stop loop with fileRead and strSplit

Post by amrgad » 31 Mar 2023, 23:20

boiler wrote:
29 Mar 2023, 18:12
You need to use `r as an omit character because your line breaks are probably `r`n. And the OmitChars parameters isn't supposed to be an array like the Delimiters parameter can be. It's supposed to just be a string of characters.
it works, Thank You :offtopic: :+1: :clap:

Post Reply

Return to “Ask for Help (v1)”