To increase the readability of your scripts, assign button values to script variables when using Show Custom Dialog. I usually use the dialog’s message calculation for this, but the title works just as well, or now that FileMaker 13 allows the use of calculations for button text, you could place the calculations there.
With such variables in place, your testing code can reference the button names instead of those impersonal numbers.
If[Get( LastMessageChoice ) = $ok_button]
# Do OK stuff.
Else If[Get( LastMessageChoice ) = $cancel_button]
# Do Cancel stuff.