Just to close this out, what you should have typed in the bottom text box was
=loadfile('A/CHDK/SCRIPTS/HDR.LUA')()
A little more explanation. The major commands in chdkptp have a one letter shortcut and a full name.
luar is the same as =
lua is the same as .
Both send lua code to the camera to run, and either should have worked equally well in the above scenario. The difference is that luar (=) waits for the code to finish on the camera before returning control to chdkptp. lua (.) just starts the code and returns immediately.
FYI, you can also run lua code in chdkptp (on your PC, not sent to the camera). This is done using the exec (!) command.
help (h) gives you a full list of commands. help -v gives more detailed descriptions of each command.
The error
Attempting to perform arithmetic on global 'f' (a nil value).
Is probably due to not having set the global variables the script expects from the script menu. The @ commands used to define the menu parameters are ignored unless you run the script form the menu, so all the a-z variables will be undefined.
To set them over chdkptp, you could do something like
lua f=1;loadfile(''A/CHDK/SCRIPTS/HDR.LUA")()