My ultimate goal is not to have a single hardcoded script. Thought this could be a good one to start on because it's complex.
Good luck with that. While it is possible with some scripts it often is not possible to do this due to limitations to what you can indirectly reference. I have a nice delete portal row script that I routinely import into each new file as it has no hardcoded steps and all is controlled via a list of parameters passed to the script. You can download my known bugs list database to see a copy and to import it into your own files if you wish.
On the other hand, I just spent several hours this weekend attempting to put together another such "utility script" and kept banging my head on steps that could not be anything but "hard coded". I plan to put a feedback post up in the near future on my experiences with that.
See my response to your other thread on using Halt script instead of exit.
Great, thank you!