Rather then create a new file to execute a constructed G10 command you can simply have a pre-existing file with G10 command(s) using variables for the values you wish to be able to change.
You set the variables to the desired values and execute the file. Or you could pass the values as parameters to the file.
That persists for the duration of the session. To persist the settings you simply execute M500 P10.
You are obtaining the same result but with the extra code for creating the file each time you wish to change the values.
In either case you have the macro and the file with the G10 command(s) which needs to be executed.
Frederick