2

How do I call a function inside loop? I'm trying to run an infinite loop that will run a function(s). I have something like this

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


function filterFile{
   #do filtering of files here
}

function anotherFunction{
    #another function 
}

If it possible how can I achieve it, if not is there other way?

2
  • 4
    Move your functions to before the loop, and you should be just fine. Commented May 30, 2017 at 23:07
  • That works great. I think i was overthinking too much and forgot to do this. Thankss! Commented May 30, 2017 at 23:09

1 Answer 1

2

Quoting the "TheMadTechnician's" answer. Changing the order will do that:

function filterFile{
   #do filtering of files here
}

#Infinite loop to filter file
while ($true){
    #run this function
    filterFile
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.