2017-05-30 73 views
1

如何在循環內調用函數?我試圖運行一個無限循環來運行一個函數。我有這樣的東西循環內的函數 - powershell

#Infinite loop to filter file 
while ($true){ 
    #run this function 
    filterFile 
} 


function filterFile{ 
    #do filtering of files here 
} 

function anotherFunction{ 
    #another function 
} 

如果有可能我該如何實現它,如果不是有其他方式?

+3

將你的函數移到循環之前,你應該會很好。 – TheMadTechnician

+0

這很好。我想我太過分了,忘了這麼做。 Thankss! – user7836693

回答

1

引用「TheMadTechnician's」的答案。改變順序會這樣做:

function filterFile{ 
    #do filtering of files here 
} 

#Infinite loop to filter file 
while ($true){ 
    #run this function 
    filterFile 
}