element undo function

Status
Not open for further replies.

Ray Joslyn

Usenet Archive
Joined
Jan 19, 2000
Messages
73
Reaction score
0
I want to read info from a cell that has been deleted and then undone. I'm trapping the event with the userUndo_command. But when I try to read the element descriptor from the filepos from the undo info I get NULL. Here is a sample of what I'm doing

first I set the undo function with:
mdlUndo_setFunction(UNDOFUNC_UNDO_COMMAND,undoCommand);

int undoCommand
(
UndoInfo *undoInfo,
MSElementUnion *element
)

{
MSElementDescr *elmDesP;

if(element->hdr.ehdr.type=CELL_HEADER_ELM)
mdlElmdscr_read(&elmDesP, undoInfo->filePos, MASTERFILE, FALSE, NULL);

any suggestions on what I'm doing wrong?
Thanks
Ray
 
Perhaps your following 'if' statement

if(element->hdr.ehdr.type=CELL_HEADER_ELM)

should like this

if(element->hdr.ehdr.type == CELL_HEADER_ELM)

double equal mark is needed.

Foo.
 
foo...

Well spotted!

Perhaps your following 'if' statement

if(element->hdr.ehdr.type=CELL_HEADER_ELM)

should like this

if(element->hdr.ehdr.type == CELL_HEADER_ELM)

double equal mark is needed.

Some people write comparisons like this:
if (CELL_HEADER_ELM == element->hdr.ehdr.type) {
}

Because the compiler will pick up on the case where you omit one of the equals:
// Compiler will throw out this statement
if (CELL_HEADER_ELM = element->hdr.ehdr.type) {
}
 
thanks guys, I'm almost embarrassed to let that pass, however it still did not solve the problem, I'm still getting a null value for the elmDesP after the mdlElmdscr_read function.
Ray

On Wed, 19 Dec 2001 21:10:42 GMT, (Ray Joslyn)
wrote:

I want to read info from a cell that has been deleted and then undone. I'm trapping the event with the userUndo_command. But when I try to read the element descriptor from the filepos from the undo info I get NULL. Here is a sample of what I'm doing

first I set the undo function with:
mdlUndo_setFunction(UNDOFUNC_UNDO_COMMAND,undoCommand);

...
 
Oh, Yes. MDL function 'mdlElmdscr_read' can NOT read deleted elems from desgin file. So the returned 'elmDesP' is always NULL.

The mdlUndo_setFunction(UNDOFUNC_UNDO_COMMAND,undoCommand) 's mainly purpose is to prevent user to undo some deleted elems.

Would you like to tell me your task's details. Perhaps I can give you some suggestion.

Foo.
 
Basically, I'm tring to read a cell that has a text string in it to display the text in a dialog box, and I want to update the dialog box automatically when the cell is modified, deleted, etc.
Ray

On 24 Dec 2001 01:10:06 -0800, (foo) wrote:

Oh, Yes. MDL function 'mdlElmdscr_read' can NOT read deleted elems from desgin file. So the returned 'elmDesP' is always NULL.

The mdlUndo_setFunction(UNDOFUNC_UNDO_COMMAND,undoCommand) 's mainly purpose is to prevent user to undo some deleted elems.

Would you like to tell me your task's details. Perhaps I can give you some suggestion.

Foo.
 
Perhaps you can use MDL function 'mdlSystem_setFunction (SYSTEM_ELMDSCR_TO_FILE, elmDscrToFile)' to set the event you capture. And then, in user function 'elmDscrToFile', you can take your action according to the parameter 'action'. The possible values are:
ELMDTF_ACTION_APPEND, ELMDTF_ACTION_DELETE,ELMDTF_ACTION_REPLACE.

Good luck.

Foo.
 
Actually, I'm already using that function, if the element is deleted or modified, what I want to be able to do is to read the element back after an undo is performed.
Ray

On 26 Dec 2001 23:02:15 -0800, (foo) wrote:

Perhaps you can use MDL function 'mdlSystem_setFunction (SYSTEM_ELMDSCR_TO_FILE, elmDscrToFile)' to set the event you capture. And then, in user function 'elmDscrToFile', you can take your action according to the parameter 'action'. The possible values are:
ELMDTF_ACTION_APPEND, ELMDTF_ACTION_DELETE,ELMDTF_ACTION_REPLACE.

Good luck.

Foo.
 
Your task is too difficult to accomplish. I have no good idea but a not-too-bad idea. You can use 'mdlSystem_setFunction (SYSTEM_ELMDSCR_TO_FILE, elmDscrToFile)' and 'mdlUndo_setFunction(UNDOFUNC_UNDO_COMMAND,undoCommand)' to capture elms-deleted events and elms-undo events simultaneously. In your 'elmDscrToFile' function, you can record the 'fileNum', 'filePos' and 'oldEdP' to a separate temporary file when you encounter elms-deleted event. Then when the elms-deleted event occur, you can query your temporary file according to the 'filePos' and get the corresponding element descriptor. Is it doable?

Sorry for my English.

Foo.
 
That would probably be the way I would have to do it, since there doesn't seem to be a 'cleaner' way to accomplish it. Thanks for your responses.
Ray

On 27 Dec 2001 18:09:53 -0800, (foo) wrote:

Your task is too difficult to accomplish. I have no good idea but a not-too-bad idea. You can use 'mdlSystem_setFunction (SYSTEM_ELMDSCR_TO_FILE, elmDscrToFile)' and 'mdlUndo_setFunction(UNDOFUNC_UNDO_COMMAND,undoCommand)' to capture elms-deleted events and elms-undo events simultaneously. In your 'elmDscrToFile' function, you can record the 'fileNum', 'filePos' and 'oldEdP' to a separate temporary file when you encounter elms-deleted event. Then when the elms-deleted event occur, you can query your temporary file according to the 'filePos' and get the corresponding element descriptor. Is it doable?

Sorry for my English.
...
 
Status
Not open for further replies.

Latest threads

Back
Top