General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion How to cancel save when custom validation detects an error

  • wksim

    How to cancel save when custom validation detects an error

    Participants 3
    Replies 4
    Last Activity 11 years, 9 months ago

    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.

    Reply

    Derek Read

    Reply to: How to cancel save when custom validation detects an error

    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”.

    Reply

    wksim

    Reply to: How to cancel save when custom validation detects an error

    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?

    Reply

    Derek Read

    Reply to: How to cancel save when custom validation detects an error

    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?

    Reply

    wksim

    Reply to: How to cancel save when custom validation detects an error

    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.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support