Notify discarded changes

Is there some variable inside the program where the value of the modified form to be saved is stored?
I would like to check if form data has been saved before starting a function.
TKS