2013-08-04 28 views
0

我试图在完成循环之前从文件中返回一个值两次(第一个值,然后是第二个值)。它现在在重复循环之前从文件返回第一个值两次。从文件中返回两次在一个循环内

我可以将信息保存在单独的文件中,但我不知道如何在重复循环之前从每个文件中提取第一个值。想法?

这是我的脚本:

Loop, read, C:\Users\Michael\Google Drive\AutoHotKey\Reference Files\item.txt 
{ 
Loop, parse, A_LoopReadLine, %A_Tab% 
    { 
    sleep 1500 
    send 1 
    sleep 1500 
    send {enter} 
    send 52 
    sleep 1500 
    send {enter} 
    send 4 
    sleep 1500 
    send {enter} 
    sleep 1500 
    Send %A_LoopField% 
    sleep 1500 
    send {enter} 
    sleep 1500 
    Send %A_LoopField% 
} 

}

+1

请详细说明您的问题。提供有关输入和输出的细节。你想阅读的文件的结构是什么?你想要提取什么?发表一个代表*输入 - >输出*例子! – MCL

回答

0

你已经获得的第一个值 - 当循环读取行了,你有a_loopfield - 这是值了第一个在每个文件中行。

但是你只能在一个文件!这就是为什么你只能得到一个价值。如果要循环访问该目录中的所有.txt文件,则必须使用通配符。

这儿有你的示意图(一个想法,你必须调整它):

Loop, read, C:\Users\Michael\Google Drive\AutoHotKey\Reference Files\*.txt ;loop through all .txt files in this directory 
{ 
    thisfile = %a_loopfield% 
    Loop, parse, A_LoopReadLine, %A_Tab% ;now parse the file that is being looped 
     { 
      msgbox The file is: %thisfile%`r and the first line is %a_loopfield% 
      break ;since we only want the *first* line, then don't read any more of this file 
    } 
}