New course! Every coder should learn Generative AI!
Try a free lesson+ 3
Suggestion
Make the function act as another script file. I mean make it work separately.
I m not sure whether this is the best way to do it. So don't forget to do some research on Internet
0
If your code is converted into a linked list of instructions. For a function you can start a new list of instructions. Then make it possible for 1 list to jump to another, function call and return. Remember when calling a function you always start at the beginning, when you return you go back to where you left off.
Would need to see the code to give any more specific advice.