Archive: Replace Goto by LogicLib


Replace Goto by LogicLib
Hi,

I would like to replace any Goto in my script by LogicLib macros.

There is one last label I can't remove because it is called by a MessageBox. Can you help me to find a way to get rid of this label:

Here is my code. This function detects if JAVA is installed on the computer. I would like to get rid of the label 'EndInit':

Function .onInit
ClearErrors
;Checking if JDK is installed
ReadRegStr $1 HKLM "SOFTWARE\JavaSoft\Java Development Kit" "CurrentVersion"
ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Development Kit\$1" "JavaHome"
StrCpy $1 "Java SDK"

${If} ${Errors}
ClearErrors
;JDK has not been found. Checking JRE
ReadRegStr $1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$1" "JavaHome"
StrCpy $1 "Java Runtime"
${If} ${Errors}
MessageBox MB_YESNO "Java has not been found.$\r$\nContinue anyway?" IDYES EndInit
Quit
${EndIf}
${EndIf}

DetailPrint "$1 has been found: $2"
Push "JAVA_HOME"
Push "$2"
Call WriteEnvStr

EndInit:
FunctionEnd

In that case I think it would be simpler to just use a Goto + label

-Stu


The LogicLib example shows how to do this:

${IfCmd} MessageBox MB_YESNO "Click Yes" IDYES ${||} StrCpy $R2 $R2A ${|}
${Unless} ${Cmd} `MessageBox MB_YESNO|MB_DEFBUTTON2 "Click No" IDYES`
StrCpy $R2 $R2B
${EndUnless}

I do not understand this code.
What does means this line:
${IfCmd} MessageBox MB_YESNO "Click Yes" IDYES ${||} StrCpy $R2 $R2A ${|}