2017-05-30 91 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 
}