This code makes sure the paretn document is valid, ie it has passed input validation.
It then sees if it is saved, and if not, prompts the user to save.
@If(@IsNewDoc & @IsValid=0;@Return("");"");
r:=@If(@IsNewDoc;@Prompt([YesNo];"Not saved yet.";"Do you want to Save Now?");2);
@If(r=2;"<already saved>";r=1;@Command([FileSave]);@Return("<doesn't want to save>"));
@Command([Compose];"RespDocForm")
Code I use again and again.