Zinthose
8th November 2010 17:59 UTC
Nop... Silliness or Diamond in the Ruff?
I did a search and was unable to locate any real-world examples for the use of the "Nop" command.
As far as I can tell it's only purpose is to take the place of commented line...
macro _IsEqual _MyVar _MyVal
StrCmp`${_MyVal}` `${_MyVar}` +3
; DetailPrint "They are not Equal!"
Nop ; Added to allow for Jump operation when previous line was commeted out
StrCpy${_MyVar} `${_MyVal}`
!macroend
Section
StrCpy$0 "cake"
!insertmacro _IsEqual $0 "pie"
DetailPrint "Done! $$0=$0"
>SectionEnd
>
Even more unlikely would be to use Nop to space macros so jumps will land on the interned targets.
macro _MakeBrainHurtCode _Mode
## TODO Very complex Stuff
Goto +10
!if `${_Mode}` == "Simple"
Nop
Nop
Nop
Nop
Nop
Nop
DetailPrint "Do Stuff"
Nop
DetailPrint "Do Stuff"
!else
DetailPrint "Do Stuff"
DetailPrint "Do Stuff"
DetailPrint "Do Stuff"
Nop
DetailPrint "Do Stuff"
DetailPrint "Do Stuff"
DetailPrint "Do Stuff"
Nop
DetailPrint "Do Stuff"
!endif
DetailPrint "Done"
>!macroend
>
According to
WikiPedia's article on NOP, it would appear to be very useful in assembler but I'm having trouble justifying it's existence in NSIS.
Whats everyone's take on this? I'd like to know as I'm struggling to find practical things to do with this command.
Animaether
8th November 2010 18:42 UTC
Well I wouldn't say 'diamond in the ruff'.. I've not used it beyond exploring the scripting language way early on.. nor have I seen it used (and the only example file using it has the comment "for fun").
That said.. the documentation on it isn't entirely all-encompassing. It says it 'does nothing'.. but while indeed it doesn't -do- anything itself, it does still count as an instruction for things like progress calculation.
No idea in what situation you'd use it, though... perhaps if the author still isn't using LogicLib and using relative offsets, as you mentioned, thus being able to replace existing commands with a Nop for testing (deleting the line entirely would mess up the offset).
Zinthose
8th November 2010 19:08 UTC
I suppose a nice syntax for disabling a line would be:
"
SectionEnd
>
Animaether
8th November 2010 19:33 UTC
Abusing a comment/line-continuance quirk with a seemingly useless command to do something that's useful but entirely overengineered? Songs of praise shall be sung of this.
Afrow UK
8th November 2010 19:46 UTC
You don't need Nop for that to work; i.e. `#\` will do. However I suppose that would be useful to retain the number of instructions when using relative jumps.
Stu
{_trueparuex^}
8th November 2010 21:24 UTC
You can use Nop to to somewhat control the progressbar when installing. Progressbar moves by the executed commans in sections and you can use Nop to space the progress so that commands that take longer will also move the progress forward more that other commands.
For example, let's say you have two files to install one is 1 MB and the other is 4 MB:
Section ""
File "smallerfile.dat"
File "largerfile.dat"
Nop
Nop
Nop
SectionEnd
>
PaR
Zinthose
8th November 2010 22:08 UTC
Originally posted by {_trueparuex^}
You can use Nop to to somewhat control the progressbar when installing.
You would think that NSIS would already know the file sizes and automatically calculate the progress jumps.
I think Nop is the answer to "Why is a raven like a writing desk?" It's purpose is to be given purpose... nothing more.
MSG
9th November 2010 06:09 UTC
Originally posted by Zinthose
You would think that NSIS would already know the file sizes and automatically calculate the progress jumps.
Filesize is no measure for installer progress: Some files don't get extracted, while others are. Some loops can take much longer than single file extractions. Not to mention the use of execwait to launch external apps...