Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
循环内的函数-powershell_Powershell - Fatal编程技术网

循环内的函数-powershell

循环内的函数-powershell,powershell,Powershell,如何在循环内调用函数?我正在尝试运行一个无限循环来运行一个函数。我有类似的东西 #Infinite loop to filter file while ($true){ #run this function filterFile } function filterFile{ #do filtering of files here } function anotherFunction{ #another function } 如果可能的话,我如何实现它,如果

如何在循环内调用函数?我正在尝试运行一个无限循环来运行一个函数。我有类似的东西

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


function filterFile{
   #do filtering of files here
}

function anotherFunction{
    #another function 
}
如果可能的话,我如何实现它,如果没有,还有其他方法吗?

引用“MadTechnician”的答案。更改顺序将执行以下操作:

function filterFile{
   #do filtering of files here
}

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

把你的函数移到循环之前,你应该会没事的。这很好。我想我想得太多了,忘了做这件事。谢谢!