From d794979b2fcd9d0e2773b44b53e1118fc1625918 Mon Sep 17 00:00:00 2001 From: eccles Date: Sun, 14 Dec 2003 00:25:22 +0000 Subject: [PATCH] 2.1: - 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 --- Examples/LogicLib.nsi | 12 +++++++++++ Include/LogicLib.nsh | 50 ++++++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/Examples/LogicLib.nsi b/Examples/LogicLib.nsi index 8f34705d..bd65a75c 100644 --- a/Examples/LogicLib.nsi +++ b/Examples/LogicLib.nsi @@ -87,6 +87,18 @@ Section ${loop} 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 StrCpy $R1 0 ${while} $R1 < 5 ;change to test while statement. diff --git a/Include/LogicLib.nsh b/Include/LogicLib.nsh index e1a4f49f..74347db0 100644 --- a/Include/LogicLib.nsh +++ b/Include/LogicLib.nsh @@ -1,5 +1,5 @@ ; NSIS LOGIC LIBRARY - logiclib.nsh -; Version 2.0 - 10/03/2003 +; Version 2.1 - 10/05/2003 ; Questions/Comments - dselkirk@hotmail.com ; 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. ; for..exitfor..next ; - 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. -; do..exitdo..loop +; do..exitdo..continue..break..loop ; - 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. -; do..exitdo..loopuntil +; do..exitdo..continue..break..loopuntil ; - 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. ; ; Usage: @@ -44,7 +44,8 @@ ; 1.3 - 09/22/2003 - Fixed maximum allow statements. ; - Now allows 10 statement depth. ; - 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 @@ -77,15 +78,15 @@ !endif !macroend - !macro _PushCustom Type endlabel + !macro _PushCustom Type label !ifdef _${Type} ; If we already have a statement !define _Cur${Type} ${_${Type}} !undef _${Type} - !define _${Type} ${endlabel} + !define _${Type} ${label} !define ${_${Type}}Prev${Type} ${_Cur${Type}} ; Save the current logic !undef _Cur${Type} !else - !define _${Type} ${endlabel} ; Initialise for first statement + !define _${Type} ${label} ; Initialise for first statement !endif !macroend @@ -251,6 +252,8 @@ !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 !insertmacro _PushCustom "ExitFor" ${${_Logic}Next} + !insertmacro _PushCustom "Break" ${${_Logic}Next} + !insertmacro _PushCustom "Continue" ${${_Logic}For} Goto ${${_Logic}For2} ${${_Logic}For}: ; Insert the loop condition IntOp ${_v} ${_v} ${_o} ${_s} @@ -261,10 +264,7 @@ !macroend !define ForEach "!insertmacro ForEach" - !macro ExitFor - Goto ${_ExitFor} - !macroend - !define ExitFor "!insertmacro ExitFor" + !define ExitFor "Goto ${_ExitFor}" !macro Next !verbose 3 @@ -277,6 +277,8 @@ !undef ${_Logic}Next !insertmacro _PopLogic !insertmacro _PopCustom "ExitFor" + !insertmacro _PushCustom "Break" ${${_Logic}Next} + !insertmacro _PushCustom "Continue" ${${_Logic}For} !verbose 4 !macroend !define Next "!insertmacro Next" @@ -287,16 +289,15 @@ !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 !insertmacro _PushCustom "ExitWhile" ${${_Logic}EndWhile} + !insertmacro _PushCustom "Break" ${${_Logic}EndWhile} + !insertmacro _PushCustom "Continue" ${${_Logic}While} ${${_Logic}While}: ; Insert the loop condition !insertmacro _${_o} "${_a}" "${_b}" "" ${${_Logic}EndWhile} !verbose 4 !macroend !define While "!insertmacro While" - !macro ExitWhile - Goto ${_ExitWhile} - !macroend - !define ExitWhile "!insertmacro ExitWhile" + !define ExitWhile "Goto ${_ExitWhile}" !macro EndWhile !verbose 3 @@ -309,6 +310,8 @@ !undef ${_Logic}EndWhile !insertmacro _PopLogic !insertmacro _PopCustom "ExitWhile" + !insertmacro _PushCustom "Break" ${${_Logic}ExitWhile} + !insertmacro _PushCustom "Continue" ${${_Logic}While} !verbose 4 !macroend !define EndWhile "!insertmacro EndWhile" @@ -319,6 +322,8 @@ !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 !insertmacro _PushCustom "ExitDo" ${${_Logic}Loop} + !insertmacro _PushCustom "Break" ${${_Logic}Loop} + !insertmacro _PushCustom "Continue" ${${_Logic}Do} ${${_Logic}Do}: ; Insert the loop condition !verbose 4 !macroend @@ -332,10 +337,7 @@ !macroend !define DoUntil "!insertmacro DoUntil" - !macro ExitDo - Goto ${_ExitDo} - !macroend - !define ExitDo "!insertmacro ExitDo" + !define ExitDo "Goto ${_ExitDo}" !macro Loop !verbose 3 @@ -348,6 +350,8 @@ !undef ${_Logic}Loop !insertmacro _PopLogic !insertmacro _PopCustom "ExitDo" + !insertmacro _PopCustom "Break" + !insertmacro _PopCustom "Continue" !verbose 4 !macroend !define Loop "!insertmacro Loop" @@ -363,6 +367,8 @@ !undef ${_Logic}Loop !insertmacro _PopLogic !insertmacro _PopCustom "ExitDo" + !insertmacro _PopCustom "Break" + !insertmacro _PopCustom "Continue" !verbose 4 !macroend !define LoopUntil "!insertmacro LoopUntil"