Quote: "An excellent observation. DBPro must pump messages to monitor the ESC key. However, I made a test and it seems users can simply close the window or escape their way out of FOR loops as well. It seems that in regard to message pumping the three loops are even.
"
It'll happily exit as message polling occurs in a number of places not just loop constructs. It's mostly called in commands like Sync though.
Sync on
// infinite/stuck loop
For lp =1 to 10
lp =5
next lp
The above creates an infinite loop. The ESC key and close gadgets [X] are of no help here.
Quote: "I also made a test with two rounds, one with the escape key enabled and one disabled. There was no performance difference between the rounds."
yep, won't make any difference as the code is generated with the message polls at compile time. It's still calling them even when break key is disabled.
The following would normally be an unbreakable loop, but in Dbpro the user can escape it to fight another day.
Sync on
// infinite/stuck loop.. nope press esc or close gadget
repeat
until lp=45
The code bellow is actually what the compiler produces.
0 PUSH REGISTERS ; PUSH REGISTERS
0 MOV MEM4 ESP @$_ESP_ ; STORE STACK IN MEM
1 LINE :
2 LINE :
3 LINE : Sync on
3 MOV EBX IMM4 [1
3 CALL EBX ; CALL [dbprocore.dll ,?SyncOn@@YAXXZ
3 MOV MEM IMM4 @$_SLN_, 3
3 MOV EAX MEM4 @$_ERR_
3 CMP EAX4 0
3 JNE $labelend ; CALL Normal Runtime Error Hook
4 LINE :
5 LINE : :`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`:`
6 LINE : repeat
6 MOV EBX IMM4 [2
6 CALL EBX ; CALL [dbprocore.dll ,?ProcessMessages@@YAKXZ <<<<<<< HERE IS THE CALL
6 CMP EAX4 1 ; CONDITION COMPARE
6 JE $labelend ; JUMP IF EQUAL
10 MOV EAX IMM4 , 45
10 PUSH EAX
10 MOV EAX MEM4 @lp
10 MOV EBX EAX4
10 POP EDX
10 MOV EAX IMM4 0
10 CMP EDX EBX4
10 SETE EAX
10 MOV MEM4 EAX @$L0 ; EQUAL
10 MOV EAX MEM4 @$L0
10 CMP EAX4 0 ; CONDITION COMPARE
10 JE $label0[6] ; JUMP IF EQUAL
6 MOV MEM IMM4 @$_SLN_, 6
6 MOV EAX MEM4 @$_ERR_
6 CMP EAX4 0
6 JNE $labelend ; CALL Normal Runtime Error Hook
7 LINE :
8 LINE :
9 LINE :
10 LINE : until lp=45
10 MOV EAX MEM4 @$_REK_
10 CMP EAX4 0
10 JNE LEAP
10 MOV EBX IMM4 [3
10 CALL EBX ; CALL [dbprocore.dll ,?Quit@@YAKXZ
10 MOV ESP MEM4 @$_ESP_ ; RESTORE STACK FROM MEM
10 POP REGISTERS ; POP REGISTERS
10 RET ; RETURN
There is a compiler switch to turn safe code generations off somewhere but I don't recall it now.