Transfer parameter-value from loop to function

Sounds like you need to read about C++ Function Parameters