restarting a script from the beginning

I have been working on a script for users to set up a folder in a particular place on our server and add all subfolders automatically.

The user is asked to choose a client, then asked a job number, then a job title (and various checks are made along the way to see whether folders already exist, whether names are duplicated etc.) and then a job folder with all subfolders is created in the correct client folder.

When it gets to the end I want a dialog box to ask the user if they want to add another job folder or quit. Straight forward enough but is there a command for just making the script run again from the start, resetting all variables? I can put my entire script within a “repeat until user_quits_at_end is true” / “end repeat” loop and keep the variable as false until such time as the user is finished. Trouble is I have a whole host of variables that I would have to reset (i use true/false flags a lot) which could be quite unwieldy and difficult to manage. Happy to do it this way if that’s what it takes but just wondered if there was a more succinct way of doing it.

Thanks as always

Hawkeye

Putting the whole thing in an enclosing repeat block is the standard way to do it. Presumably all your “whole host” of variables have to be set at the beginning of the script anyway for the first run - won’t they just be set again? You don’t show a structure, but you could also put all your initializations into a handler so that for each cycle of the repeat your script would “initVars()” or something like that.