Pages: 1
Print
Author Topic: How to cancel save when custom validation detects an error  (Read 2879 times)
wksim
Member

Posts: 14


« on: December 15, 2010, 09:33:40 AM »

Hi 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.
« Last Edit: December 15, 2010, 09:35:23 AM by wksim » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2580



WWW
« Reply #1 on: December 15, 2010, 04:43:36 PM »

You 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".
Logged
wksim
Member

Posts: 14


« Reply #2 on: December 15, 2010, 04:57:00 PM »

Thank you Derek. How about Ctl-S to save the document? Is there a way to override it so that it can call other macro?
« Last Edit: December 15, 2010, 05:11:21 PM by wksim » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2580



WWW
« Reply #3 on: December 15, 2010, 05:14:08 PM »

If 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?
Logged
wksim
Member

Posts: 14


« Reply #4 on: December 15, 2010, 05:20:56 PM »

I 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.
Logged
Pages: 1
Print
Jump to:  

email us