Label의 경우 조건문에 의해서 실행되는 흐름을 바꿀때 Label이 붙어 있는 곳으로 보낼 수 있다. 주로 IfErrors, IfFileExists, StrCmp 등의 명령어를 사용할때 많이 사용한다. Label의 경우 지역적으로만 인식되므로 같은 function이나 section 내부에서만 사용할 수 있다. 또한 Label은 -, +, !, $ 또는 0-9 로 시작할 수는 없다. Label 을 사용하는 것은 다음과 같이 한다.
[code type=nsis]
MyLabel:
[/code]
Label의 이름으로 시작할때 만약 '.'으로 시작하면 전역적으로 볼 수 있는 Label이다. 즉 function/section 내부에서 외부로 흐름을 바꿀 수 있다.
2. Relative Jump
Relative Jump는 이름이 말하는 것처럼 현재 위치를 기준으로 몇번째 instruction으로 갈 건지를 결정하는 것이다. +1 은 바로 다음 instruction(일반적인 경우)을 실행하는 것이며, +2는 두 번째 instruction 즉 첫 번째 instruction은 건너 띄고 두 번째 instruction을 실행하는 것이다. 여기서 말하는 instruction 이라는 것은 인스톨러가 실제로 실행될때 실행되는 모든 명령어를 말하는 것이다. MessageBox, Goto, GetDLLVersion, FileRead, SetShellVarContext 등이 예이다. AddSize, Section, SectionGroup, Name, LangString 등은 인스톨러를 컴파일 할 때 실행되기 때문에 instruction이 아니다.
[code type=nsis]
Goto +2
MessageBox MB_OK "You will never ever see this message box"
MessageBox MB_OK "The last message was skipped, this one should be shown."
[/code]
위의 경우 두 번째 MessageBox만 실행이 된다. +2 이므로 첫 번째 instruction(첫 번째에 있는 MessageBox)이 skip되고 두 번째 instruction 인 두 번째에 있는 MessageBox 가 실행이 된다.
[code type=nsis]
# set the name of the installer
outfile "label_jump.exe"
# create a default section.
section
Goto +4
MessageBox MB_OK "The following message will be skipped"
Goto +3
MessageBox MB_OK "You will never ever see this message box"
Goto -3
MessageBox MB_OK "Done"
sectionEnd
[/code]
위의 예제를 실행하면 어떤 메시지가 들어 있는 MessageBox가 나올까...


[code type=nsis]
!macro relative_jump_test
MessageBox MB_OK "first macro line"
MessageBox MB_OK "second macro line"
!macroend
Goto +2
!insertmacro relative_jump_test
[/code]



글
댓글을 달아 주세요
댓글 RSS 주소 : http://www.cipher.pe.kr/tt/cipher/rss/comment/103댓글 ATOM 주소 : http://www.cipher.pe.kr/tt/cipher/atom/comment/103