- Added continue and break labels to repeat type statements.


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3276 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
eccles 2003-12-14 00:25:22 +00:00
parent 46297fa6cd
commit d794979b2f
2 changed files with 40 additions and 22 deletions

View file

@ -87,6 +87,18 @@ Section
${loop} ${loop}
MessageBox MB_OK "loopR1: $R1$\nloop2: $R2" MessageBox MB_OK "loopR1: $R1$\nloop2: $R2"
; break..continue labels
StrCpy $R1 0
${do}
StrCpy $R2 0
${do}
IntOp $R2 $R2 + 1
MessageBox MB_YESNO "Do..Loop1: $R1.$\nDo..Loop2: $R2.$\n$\nDo you want to stop Loop2?" IDYES ${_Break} IDNO ${_Continue}
${loop}
IntOp $R1 $R1 + 1
MessageBox MB_YESNO "Do..Loop1: $R1.$\nDo..Loop2: $R2.$\n$\nDo you want to stop Loop1?" IDYES ${_Break} IDNO ${_Continue}
${loop}
; while..exitwhile..endwhile ; while..exitwhile..endwhile
StrCpy $R1 0 StrCpy $R1 0
${while} $R1 < 5 ;change to test while statement. ${while} $R1 < 5 ;change to test while statement.

View file

@ -1,5 +1,5 @@
; NSIS LOGIC LIBRARY - logiclib.nsh ; NSIS LOGIC LIBRARY - logiclib.nsh
; Version 2.0 - 10/03/2003 ; Version 2.1 - 10/05/2003
; Questions/Comments - dselkirk@hotmail.com ; Questions/Comments - dselkirk@hotmail.com
; Special thanks to eccles for Push/Pop Logic! ; Special thanks to eccles for Push/Pop Logic!
; ;
@ -21,15 +21,15 @@
; - Executes one of several groups of statements, depending on the value of an expression. ; - Executes one of several groups of statements, depending on the value of an expression.
; for..exitfor..next ; for..exitfor..next
; - Repeats a group of statements a specified number of times. ; - Repeats a group of statements a specified number of times.
; foreach..exitfor..next ; foreach..exitfor..continue..break..next
; - Repeats a group of statements a specified number of times stepping in order specified. ; - Repeats a group of statements a specified number of times stepping in order specified.
; do..exitdo..loop ; do..exitdo..continue..break..loop
; - Repeats a block of statements until stopped. ; - Repeats a block of statements until stopped.
; dountil..exitdo..loop ; dountil..exitdo..continue..break..loop
; - Repeats a block of statements until a condition is True. ; - Repeats a block of statements until a condition is True.
; do..exitdo..loopuntil ; do..exitdo..continue..break..loopuntil
; - Repeats a block of statements until a condition is True. ; - Repeats a block of statements until a condition is True.
; while..exitwhile..endwhile ; while..exitwhile..continue..break..endwhile
; - Executes a series of statements as long as a given condition is True. ; - Executes a series of statements as long as a given condition is True.
; ;
; Usage: ; Usage:
@ -44,7 +44,8 @@
; 1.3 - 09/22/2003 - Fixed maximum allow statements. ; 1.3 - 09/22/2003 - Fixed maximum allow statements.
; - Now allows 10 statement depth. ; - Now allows 10 statement depth.
; - Condensed code. ; - Condensed code.
; 2.0 - 10/03/2003 - Inital release 2, see notes. ; 2.0 - 10/03/2003 - Inital release 2, see notes.
; 2.1 - 10/05/2003 - Added continue and break labels to repeat type statements.
!verbose 3 !verbose 3
@ -77,15 +78,15 @@
!endif !endif
!macroend !macroend
!macro _PushCustom Type endlabel !macro _PushCustom Type label
!ifdef _${Type} ; If we already have a statement !ifdef _${Type} ; If we already have a statement
!define _Cur${Type} ${_${Type}} !define _Cur${Type} ${_${Type}}
!undef _${Type} !undef _${Type}
!define _${Type} ${endlabel} !define _${Type} ${label}
!define ${_${Type}}Prev${Type} ${_Cur${Type}} ; Save the current logic !define ${_${Type}}Prev${Type} ${_Cur${Type}} ; Save the current logic
!undef _Cur${Type} !undef _Cur${Type}
!else !else
!define _${Type} ${endlabel} ; Initialise for first statement !define _${Type} ${label} ; Initialise for first statement
!endif !endif
!macroend !macroend
@ -251,6 +252,8 @@
!define ${_Logic}For2 _${__LINE__} ; Get a label for the start of the loop !define ${_Logic}For2 _${__LINE__} ; Get a label for the start of the loop
!define ${_Logic}Next _${__LINE__} ; Get a label for the end of the loop !define ${_Logic}Next _${__LINE__} ; Get a label for the end of the loop
!insertmacro _PushCustom "ExitFor" ${${_Logic}Next} !insertmacro _PushCustom "ExitFor" ${${_Logic}Next}
!insertmacro _PushCustom "Break" ${${_Logic}Next}
!insertmacro _PushCustom "Continue" ${${_Logic}For}
Goto ${${_Logic}For2} Goto ${${_Logic}For2}
${${_Logic}For}: ; Insert the loop condition ${${_Logic}For}: ; Insert the loop condition
IntOp ${_v} ${_v} ${_o} ${_s} IntOp ${_v} ${_v} ${_o} ${_s}
@ -261,10 +264,7 @@
!macroend !macroend
!define ForEach "!insertmacro ForEach" !define ForEach "!insertmacro ForEach"
!macro ExitFor !define ExitFor "Goto ${_ExitFor}"
Goto ${_ExitFor}
!macroend
!define ExitFor "!insertmacro ExitFor"
!macro Next !macro Next
!verbose 3 !verbose 3
@ -277,6 +277,8 @@
!undef ${_Logic}Next !undef ${_Logic}Next
!insertmacro _PopLogic !insertmacro _PopLogic
!insertmacro _PopCustom "ExitFor" !insertmacro _PopCustom "ExitFor"
!insertmacro _PushCustom "Break" ${${_Logic}Next}
!insertmacro _PushCustom "Continue" ${${_Logic}For}
!verbose 4 !verbose 4
!macroend !macroend
!define Next "!insertmacro Next" !define Next "!insertmacro Next"
@ -287,16 +289,15 @@
!define ${_Logic}While _${__LINE__} ; Get a label for the start of the loop !define ${_Logic}While _${__LINE__} ; Get a label for the start of the loop
!define ${_Logic}EndWhile _${__LINE__} ; Get a label for the end of the loop !define ${_Logic}EndWhile _${__LINE__} ; Get a label for the end of the loop
!insertmacro _PushCustom "ExitWhile" ${${_Logic}EndWhile} !insertmacro _PushCustom "ExitWhile" ${${_Logic}EndWhile}
!insertmacro _PushCustom "Break" ${${_Logic}EndWhile}
!insertmacro _PushCustom "Continue" ${${_Logic}While}
${${_Logic}While}: ; Insert the loop condition ${${_Logic}While}: ; Insert the loop condition
!insertmacro _${_o} "${_a}" "${_b}" "" ${${_Logic}EndWhile} !insertmacro _${_o} "${_a}" "${_b}" "" ${${_Logic}EndWhile}
!verbose 4 !verbose 4
!macroend !macroend
!define While "!insertmacro While" !define While "!insertmacro While"
!macro ExitWhile !define ExitWhile "Goto ${_ExitWhile}"
Goto ${_ExitWhile}
!macroend
!define ExitWhile "!insertmacro ExitWhile"
!macro EndWhile !macro EndWhile
!verbose 3 !verbose 3
@ -309,6 +310,8 @@
!undef ${_Logic}EndWhile !undef ${_Logic}EndWhile
!insertmacro _PopLogic !insertmacro _PopLogic
!insertmacro _PopCustom "ExitWhile" !insertmacro _PopCustom "ExitWhile"
!insertmacro _PushCustom "Break" ${${_Logic}ExitWhile}
!insertmacro _PushCustom "Continue" ${${_Logic}While}
!verbose 4 !verbose 4
!macroend !macroend
!define EndWhile "!insertmacro EndWhile" !define EndWhile "!insertmacro EndWhile"
@ -319,6 +322,8 @@
!define ${_Logic}Do _${__LINE__} ; Get a label for the start of the loop !define ${_Logic}Do _${__LINE__} ; Get a label for the start of the loop
!define ${_Logic}Loop _${__LINE__} ; Get a label for the end of the loop !define ${_Logic}Loop _${__LINE__} ; Get a label for the end of the loop
!insertmacro _PushCustom "ExitDo" ${${_Logic}Loop} !insertmacro _PushCustom "ExitDo" ${${_Logic}Loop}
!insertmacro _PushCustom "Break" ${${_Logic}Loop}
!insertmacro _PushCustom "Continue" ${${_Logic}Do}
${${_Logic}Do}: ; Insert the loop condition ${${_Logic}Do}: ; Insert the loop condition
!verbose 4 !verbose 4
!macroend !macroend
@ -332,10 +337,7 @@
!macroend !macroend
!define DoUntil "!insertmacro DoUntil" !define DoUntil "!insertmacro DoUntil"
!macro ExitDo !define ExitDo "Goto ${_ExitDo}"
Goto ${_ExitDo}
!macroend
!define ExitDo "!insertmacro ExitDo"
!macro Loop !macro Loop
!verbose 3 !verbose 3
@ -348,6 +350,8 @@
!undef ${_Logic}Loop !undef ${_Logic}Loop
!insertmacro _PopLogic !insertmacro _PopLogic
!insertmacro _PopCustom "ExitDo" !insertmacro _PopCustom "ExitDo"
!insertmacro _PopCustom "Break"
!insertmacro _PopCustom "Continue"
!verbose 4 !verbose 4
!macroend !macroend
!define Loop "!insertmacro Loop" !define Loop "!insertmacro Loop"
@ -363,6 +367,8 @@
!undef ${_Logic}Loop !undef ${_Logic}Loop
!insertmacro _PopLogic !insertmacro _PopLogic
!insertmacro _PopCustom "ExitDo" !insertmacro _PopCustom "ExitDo"
!insertmacro _PopCustom "Break"
!insertmacro _PopCustom "Continue"
!verbose 4 !verbose 4
!macroend !macroend
!define LoopUntil "!insertmacro LoopUntil" !define LoopUntil "!insertmacro LoopUntil"