Code: Select all
#singleinstance, force
inputbox, file, input, which .txt file
+.::
if ( file > 0 ) {
Loop, Read, %file% {
lines = %A_Index%
}
msgbox, %lines%
return
}
else if ( file = file) {
msgbox, no file selected!
ExitApp
}
Code: Select all
#singleinstance, force
inputbox, file, input, which .txt file
+.::
if ( file > 0 ) {
Loop, Read, %file% {
lines = %A_Index%
}
msgbox, %lines%
return
}
else if ( file = file) {
msgbox, no file selected!
ExitApp
}
Code: Select all
Loop, Read, %file%
{
so it should be likegregster wrote: ↑31 Jan 2019, 21:21The one-true-brace style (block's opening brace on the same line as the block's controlling statement rather than underneath on a line by itself) is only allowed for normal loops:
https://autohotkey.com/docs/commands/Block.htm#otb
https://autohotkey.com/docs/commands/Loop.htm#Remarks
this means, use:Code: Select all
Loop, Read, %file% {
Code: Select all
loop, read, %file%
{
lines= %A_index%
}
msgbox, lines in file = %lines%
Code: Select all
#singleinstance, force
inputbox, file, input txt, file to read (press < to activate)
+.::
if ( file > 0 )
{
Loop, Read, %file%
{
lines = %A_Index%
}
random, rngline , 1 , %lines%
filereadline , text, %file%, %rngline%
msgbox, %text%
}
else if ( 1 = 1)
{
msgbox, no file selected!
ExitApp
}
Return
Users browsing this forum: FanaticGuru, Google [Bot] and 140 guests