in reply to Merge two scripts into one

I am at this point stuck since what I have tried does not seem to be working.

It's a shame you didn't just show us the merged script (rather than the two separate ones). We might have been able to help you find the problem.