Help with loop, read Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Help with loop, read

03 Jun 2018, 01:58

Hey,

i have a list of names and want to get a MsgBox, found when i type in the editbox at least 1 name from the list,
what im doing wrong ?
thanks!

Code: Select all

#SingleInstance, force
#NoEnv

txtlist = c:\namelist.txt

FileDelete, %txtlist%

FileAppend, 
(
David
Mike
Jow
)
,%txtlist%

loop, read, %txtlist%
break

Gui Add, Edit, vUser1,
Gui, Add, Button,gCheck Default,check
Gui, Show
return

Check:
Gui,Submit,NoHide

if (User1 = A_LoopReadLine)
{
	MsgBox, found
}
else
{
	MsgBox, not found
}
return

GuiClose:
GuiEscape:
ExitApp
Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help with loop, read

03 Jun 2018, 02:24

Hallo,
try:

Code: Select all

#SingleInstance, force
#NoEnv

txtlist = c:\namelist.txt

FileDelete, %txtlist%

FileAppend, 
(
David
Mike
Jow
)
,%txtlist%

Gui Add, Edit, vUser1,
Gui, Add, Button,gCheck Default,check
Gui, Show
return

Check:
Gui,Submit,NoHide
FileRead, namelist, c:\namelist.txt
if InStr(namelist,User1)
{
	MsgBox, found
}
else
{
	MsgBox, not found
}
return

GuiClose:
GuiEscape:
ExitApp
(type only 1 name)
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: Help with loop, read

03 Jun 2018, 02:38

Tnx Roh,

but for e.x in this method its found also names like: "Da" since "Da" is included in the name "David"

Ive come with this code,
But may be a better method from this one?
coz i dont like its looping all the list..

Code: Select all

#SingleInstance, force
#NoEnv

txtlist = c:\namelist.txt

FileDelete, %txtlist%

FileAppend, 
(
David
Mike
Jow
)
,%txtlist%




Gui Add, Edit, vUser1,
Gui, Add, Button,gCheck Default,check
Gui, Show
return

Check:
Gui,Submit,NoHide

loop, read, %txtlist%
{
   if (User1 = A_LoopReadLine)
     {
	MsgBox, found
     }
}

MsgBox, not found

return

GuiClose:
GuiEscape:
ExitApp
Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help with loop, read  Topic is solved

03 Jun 2018, 03:09

Hallo,
perhaps:

Code: Select all

#SingleInstance, force
#NoEnv

txtlist = c:\namelist.txt

FileDelete, %txtlist%

FileAppend, 
(
David
Mike
Jow
`r
)
,%txtlist%

FileRead, namelist, c:\namelist.txt
Gui Add, Edit, vUser1,
Gui, Add, Button,gCheck Default,check
Gui, Show
return

Check:
Gui,Submit,NoHide

if InStr(namelist,User1 . "`r")
{
	MsgBox, found
}
else
{
	MsgBox, not found
}
return

GuiClose:
GuiEscape:
ExitApp
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: Help with loop, read

03 Jun 2018, 04:29

Thanks Rohwedder!
so far looks working well.
Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help with loop, read

04 Jun 2018, 02:44

Hallo asad41163,
you haven't even tried to write a script line that deletes files!
Try to find someone who will do it for money.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 227 guests