Skimming this script, this line that was triggering your original problem:
textFieldButtonGrp -buttonLabel "Browse" -tx $cfp -bc rsFileDialog rsTxtFld -ed true filepath;
Should probably be: (rsTxtFld moved to the end)
textFieldButtonGrp -buttonLabel "Browse" -tx $cfp -bc rsFileDialog -ed true filepath rsTxtFld;
The error "Flags must come before objects" means that in the grammar of the command, "verb, adverbs, object", the final object you are operating on has to come last. In this case, the command `textFieldButtonGrp` is creating the `rsTxtFld` object and assigning it that name. Everything in the middle is controlled by flags (-stuff -that -follows -dashes) or flag values (-this value -that value -the other value). The object needs to come last.
Later in the script, that `rsTxtFld` object is being updated/edited, and if it is not named here, it will not be found. (That creates the error in Message 4 in this thread).