General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › How to cancel save when custom validation detects an error
-
wksim December 15, 2010 at 3:33 pm
How to cancel save when custom validation detects an error
December 15, 2010 at 3:33 pmParticipants 3Replies 4Last Activity 12 years, 1 month agoHi all, we have a custom validation logic that needs to be invoked when the document is saved in XMetaL, and we would like to stop saving the document if the validation fails. We tried the logic in to the On_Document_Save and On_Before_Document_Save, but we could not figure out how to cancel the save operation when the validation fails. Is there a way to stop the save operation in one of the macros?
We are using XMetaL v5.1.1.
thanks in advance.
Derek Read December 15, 2010 at 10:43 pm
Reply to: How to cancel save when custom validation detects an error
December 15, 2010 at 10:43 pmYou will need to use a special File menu override event called “File_Save”.
If you create this event and do not explicity call ActiveDocument.Save() then the document will not save (basically the reverse logic of what you are looking for). So you'd have a branching logic in your macro that checks for ActiveDocument.IsValid before saving and if that fails then it does not save.
See the Programmer's Guide topic called “File operations”.
wksim December 15, 2010 at 10:57 pm
Reply to: How to cancel save when custom validation detects an error
December 15, 2010 at 10:57 pmThank you Derek. How about Ctl-S to save the document? Is there a way to override it so that it can call other macro?
Derek Read December 15, 2010 at 11:14 pm
Reply to: How to cancel save when custom validation detects an error
December 15, 2010 at 11:14 pmIf you use File_Save that should intercept all user-initiated saves through our default GUI. Is that what you mean? I think this is probably stated (more clearly than I can described) in the Programmer's Guide.
Or do you mean you want to handle Ctrl+S in a different way from clicking Save on the File menu?
wksim December 15, 2010 at 11:20 pm
Reply to: How to cancel save when custom validation detects an error
December 15, 2010 at 11:20 pmI should have read the document before I posted the last one. No, it should do the same. If overriding File_Save handles all user initiated saves, then it is good.
Thank you Derek.
-
AuthorPosts
- You must be logged in to reply to this topic.