undo, retry

Posted by ecsousa on 12-Dec-2014 11:38

Hello,

UNDO statement:
Backs out all modifications to fields and variables made during the current iteration of a block, and indicates what action to take next.

Someone can explain me why the examples have different behavior:

example 1:

DEFINE VAR a AS Int.
teste:
DO ON ERROR undo, RETRY:

MESSAGE "oi" VIEW-AS ALERT-BOX.
Update a.
Undo, Retry teste.
END.

Example 2:

DEFINE VAR a AS Int.
teste:
DO ON ERROR undo, RETRY:

MESSAGE "oi" VIEW-AS ALERT-BOX.
assign a = random (0, 100).
Undo, Retry teste.
END.

I use update in the first....and assign in the second... both changes the variable a... but with assign the block is not repeated.

Thanks,

Éllen

All Replies

Posted by TheMadDBA on 12-Dec-2014 11:44

Most likely because there is nothing seen as an action to retake and to prevent an infinite loop....

If you are going to use undo,retry.. always have something that checks the retry

DEFINE VAR a AS Int.

teste:

DO ON ERROR undo, RETRY:

if  RETRY then MESSAGE "oi" VIEW-AS ALERT-BOX.

assign a = random (0, 100).

Undo, Retry teste.

END.

Posted by ecsousa on 12-Dec-2014 12:04

Thank you =D

This thread is closed