The concept of these lines is as follows: if the script is called by MATLAB outside optiSLang, the variable OSL_REGULAR_EXECUTION does not exist. If you do a Test Run when editing the Matlab node, it is set to false, in a regular run of the workflow it is set to true by optiSLang. This way, you have on the one hand default values to run the script outside optiSLang context, on the other hand you avoid that design values generated by optiSLang are overwritten. Your code looks good so far.
Still, the values of F_o_f* are overwritten. I suspect it happens elsewhere in the code. Outside the code snippet we see above, you shouldn't touch these variables. Please check your code for this.