To do something repeatedly in Splus, you need to either write a script, or create a function. The relevant Splus code is distributed along with the project management utilities. With version 4, the manuals seem to focus on writing scripts. However, functions have many advantages over scripts. In particular, functions parameters which can easily be changed, and functions have no nasty side-effects of creating unwanted variables, or accidentally overwriting precious existing ones.
New functions have bugs.
Splus now has a debugger, though it must be said that the debugger is not a thing of beauty nor a joy forever, at least not if you have programmed in other languages this side of the Stone Age. I have recently tarted this up for version 4, and will be releasing it soon. Your question is very relevant for all new users. It is a lot better to get the basics sorted out to begin with, rather than try to organize things post-hoc. This is of course a heavily partisan posting, in that I favour my own way of working.