I am on the fence about that one Lee but if "yes" i vote txt file (so it would be avail after a restart).
I was just considering that the layer setup may be quite different from file to file, so a simple global would be the least intrusive (and easiest to code), whilst still aiding the user.
...to add to the `yes options' (this thought just came to me): what about if we re-write the program file (append a function to it something like: "(defun globalvar ( / ) "my-last-layer")" or something like that). Of course we would have to build some error proofing on that but you get the idea.
That could be another option, yes - I suppose one would have to weigh the coding needed to read/write the lsp file coupled with testing for existence of the globalvar function against a single read/write to another (separate) text file but with the baggage of an extra file (albeit small).
Another option could be to define a subfunction as a list, i.e.:
(defun-q MySub ( / x )
(setq x 1)
(setq x (cond ( (getint (strcat "\nEnter a Number <" (itoa x) "> : ")) ) ( x )))
(setq MySub (cons (car MySub) (cons (list 'setq 'x x) (cddr MySub))))
(princ)
)
This would behave in the same way as the use of a Global Variable, but removes the need for a Global Variable floating around.
Lee