2016-08-06 47 views
2

我讀了一個config.ini文件,其中運行了一些.exe的位置,但是我想跳過config.ini中的註釋行(因爲我想解釋如何使用該文件),如果有人能幫助我感謝Autohotkey:在循環/ FileReadLine中跳過註釋行

#NoEnv 
#SingleInstance force 
Loop 
    { 
    FileReadLine, exe, config.ini, %A_Index% 
      if ErrorLevel 
      break 
    Run %exe% 
    Sleep , 300 
    } 
return 
ExitApp 

的config.ini

// Put here location of your programs << line to skip 
// Thanks << line to skip 
C:\WINDOWS\notepad.exe 
C:\WINDOWS\****.exe 
... 

回答

1
Loop 
    { 
    FileReadLine, exe, config.ini, %A_Index% 
      if ErrorLevel 
      break 
      else if SubStr(exe,1,2)=="//" 
      continue 
    Run %exe% 
    Sleep , 300 
    } 

使用SubStr()檢查,如果符合前兩個字符是//如果是使用continue來跳過循環的其餘部分並開始下一次迭代。