The 'APP' array can feed values from the host program to yours, but it can't return any. For that you need 'RESULT', the third 4tH variable. Returning a value is very easy. Just store it in 'RESULT'. Let's assume the host program has send two values to the 'APP' array and you want to return the sum. All you have to do is add them and store the result in 'RESULT':
app 0 th @ app 1 th @ + result !
Nothing to it..