![]() |
#1 |
Senior Member
Join Date: Aug 2002
Posts: 118
|
![]()
Hey, Here is another library to simplify the creation of your installs. This is the result of the previous post entitled "Select Statements". Thanks to eccles I have been able to completely rewrite it with improved functionality and speed.
Here is a list of the available statements: if..elseif..else..endif ifthen..|..| ifcmd..||..| select..case..case2..case3..case4..case5..case_else..endselect for..exitfor..next foreach..exitfor..next do..exitdo..loop dountil..exitdo..loop do..exitdo..loopuntil while..exitwhile..endwhile Have a look at the provided example.nsi for working examples of the library. Once I get some feed back on possible changes or improvements then I will post it in the archive. Don |
![]() |
![]() |
![]() |
#2 |
NSIS Dev
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
|
Hey Don, check your private messages...!
Dave. |
![]() |
![]() |
![]() |
#3 |
Senior Member
Join Date: Aug 2002
Posts: 118
|
Version 2.1 adds break and continue labels to repeat type statements. Useful for functions like MessageBox, here is an example:
code: Thanks to eccles for the idea. |
![]() |
![]() |
![]() |
#4 |
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
Damn, that's so cool!
![]() NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
![]() |
![]() |
![]() |
#5 |
NSIS Dev
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
|
Don, I've made a couple of changes for your perusal.
Anyway, looking good! Should help newcommers to NSIS no end ![]() -- Dave. |
![]() |
![]() |
![]() |
#6 |
Senior Member
Join Date: Aug 2002
Posts: 118
|
Good work on the consolidation and fixes. I especially love your solution for the operation comparison in the foreach statement. Very nice. What were the issues with the break and continue labels? For the if..then statments I had to add some extra lines to handle just an if..else..endif statements. When I had something like the foloowing:
code: Both messages would appear. It wasn't moving to the end. Here it is again with the updated file header. |
![]() |
![]() |
![]() |
#7 | |||
NSIS Dev
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
|
Quote:
Quote:
Quote:
![]() -- Dave. |
|||
![]() |
![]() |
![]() |
#8 |
Junior Member
Join Date: Mar 2003
Posts: 9
|
![]()
Hi eccles & dselkirk!
You are amazing - very nice job done ! This is going to save quite some lines of script... |
![]() |
![]() |
![]() |
#9 |
NSIS Dev
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
|
NSIS LogicLib Version 2.3
Enjoy! -- Dave. |
![]() |
![]() |
![]() |
#10 |
NSIS Dev
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
|
NSIS LogicLib Version 2.4
-- Dave. |
![]() |
![]() |
![]() |
#11 |
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
I love it!
![]() ![]() NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
![]() |
![]() |
![]() |
#12 |
Member
Join Date: Dec 2001
Posts: 89
|
![]()
Great stuff! Truly amazing! What dou you come up with next? A NSIS compiler written in NSIS?
![]() There's only one thing which should be improved: Get rid of the ${} around the commands. For example by adding a DeclareCommand function to NSIS or something similar. DeclareCommand ${If} If would make the If command available which then works like any of the built-in commands. Or another way: Add support for function parameters and get rid of call. And last but not least: Implicit inclusion of LogicLib.nsh to every script ![]() Keep up the good work! |
![]() |
![]() |
![]() |
#13 |
NSIS MUI Dev
Join Date: Nov 2001
Posts: 3,717
|
These things will become possible when NSIS supports compiler plug-ins.
|
![]() |
![]() |
![]() |
#14 |
Member
Join Date: Dec 2001
Posts: 89
|
Compiler plugins? Whoah, any ETA?
|
![]() |
![]() |
![]() |
#15 |
NSIS MUI Dev
Join Date: Nov 2001
Posts: 3,717
|
NSIS 2.1
![]() NSIS 2.0 has to be finished first. |
![]() |
![]() |
![]() |
#16 | |
NSIS Dev
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
|
Thanks all for the thanks
![]() ![]() LogicLib has now been added to CVS and is included in the nightly snapshots and forthcoming NSIS releases. I am open to ideas for other improvements and logic tests to encapsulate (such as the section flag tests added in the latest version). Quote:
![]() -- Dave. |
|
![]() |
![]() |
![]() |
#17 |
NSIS Dev
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
|
New in CVS: LogicLib v2.5
You can lead a man to knowledge, but you can't make him think! |
![]() |
![]() |
![]() |
#18 |
Senior Member
Join Date: Feb 2003
Location: Toronto, Canada
Posts: 227
|
eccles this logic library is amazing. I've converted some of my scripts to use it and have been able to eliminate huge chunks of script because of it. Thanks alot man!
|
![]() |
![]() |
![]() |
#19 |
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
small question... can you not use LogicLib inside of macros with passed variables ?
e.g. PHP Code:
|
![]() |
![]() |
![]() |
#20 |
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
nevermind... it's fine..
The problem is that I'm passing the macro an empty string: PHP Code:
Work-arounds? PHP Code:
PHP Code:
I'm a bit confused as to why an empty string becomes null if passed to a macro, though. In the latter bit, my string consisting of two quotation marks essentially becomes an empty string? ![]() |
![]() |
![]() |
![]() |
#21 |
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
Quoting in the ${If} line is the correct way to get around this. Why would it kill any integer checks?
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
![]() |
![]() |
![]() |
#22 |
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
because I'm making the gross assumption that you can't compare a string to an int :x
Thanks for the pointer ![]() |
![]() |
![]() |
![]() |
#23 |
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
But an integer is a string in NSIS. Commands that require integers automatically convert the string to an integer.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
![]() |
![]() |
![]() |
#24 |
Junior Member
Join Date: Nov 2006
Posts: 43
|
Hi,
i have a question how to use If in the new Logiclib. ${If} ${SectionIsSelected} ${CSEC} !insertmacro UnSelectSection ${ESEC} ${EndIf} i get an error: "macro "If" requires 3 parameter(s), passed 2!" I don't understand |
![]() |
![]() |
![]() |
#25 |
Senior Member
Join Date: Jul 2004
Location: Switzerland
Posts: 223
|
Hi mamilo!
Did you write this code below the Section Sec01 CSEC declaration? Cheers Bruno |
![]() |
![]() |
![]() |
#26 |
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
Shouldn't it be this?
code: |
![]() |
![]() |
![]() |
#27 |
Senior Member
Join Date: Jul 2004
Location: Switzerland
Posts: 223
|
I think the code is correct.
http://nsis.sourceforge.net/LogicLib#Expressions But I believe the define has not yet been created by the compiler and therefore the constant is empty. Put the code below the section declaration. |
![]() |
![]() |
![]() |
#28 |
Junior Member
Join Date: Jul 2005
Posts: 19
|
How do I use the OrUnless Statement correctly? I want to do something when one of two sections is selected. Here is my code that doesn't work:
code: |
![]() |
![]() |
![]() |
#29 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
only one "if" statement per line
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#30 |
Junior Member
Join Date: Jul 2005
Posts: 19
|
Is this correct?
code: |
![]() |
![]() |
![]() |
#31 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
You can just use the ${If} ${SectionIsSelected} ... ${OrIf} ${SectionIsSelected} ...
Stu |
![]() |
![]() |
![]() |
#32 |
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
besides what Afrow said - yes, that'd be correct
![]() 'd still go with what Afrow said, though ![]() |
![]() |
![]() |
![]() |
#33 | |
Junior Member
Join Date: Jul 2005
Posts: 19
|
Quote:
${Unless} $R0 <> $R1 ${OrUnless} $R2 <> $R3 Do Something ${EndUnless} This seems to work and is very short. |
|
![]() |
![]() |
![]() |
#34 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Why?
${If} ${SectionIsSelected} ${SEC02} ${OrIf} ${SectionIsSelected} ${SEC03} ... ${EndIf} Stu |
![]() |
![]() |
![]() |
#35 |
Junior Member
Join Date: Jul 2005
Posts: 19
|
That's right I didn't see that. But my code is also ok?
|
![]() |
![]() |
![]() |
#36 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
It may work but the proper logic is to check if ${SF_SELECTED} (1) is set:
SectionGetFlags ${SEC02} $R0 IntOp $R0 $R0 & ${SF_SELECTED} ${If} $R0 != 0 ... This is what ${If} ${SectionIsSelected} ${SEC02} would be doing internally. Stu |
![]() |
![]() |
![]() |
#37 |
Junior Member
Join Date: Jul 2005
Posts: 19
|
What does this line?
IntOp $R0 $R0 & ${SF_SELECTED} |
![]() |
![]() |
![]() |
#38 | |
Junior Member
Join Date: Mar 2002
Posts: 27
|
There's a replacement macro for ${FileExists} in the Wiki, but it doesn't work with ${IfNot} or ${Unless}.
http://nsis.sourceforge.net/LogicLib Quote:
${If} ${FileExists} <path> and it exists, it will perform. However, if I use: ${IfNot} ${FileExists} <path> and the file doesn't exist, it won't perform. I deleted the FileExists2 macro code from my script and returned to the one included in LogicLib.nsh and it works correctly again. |
|
![]() |
![]() |
![]() |
#39 |
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
There's no need for a new macro. You can simply use ${If} ${FileExists} $YourFile ${AndIfNot} ${FileExists} "$YourFile\*.*" .
|
![]() |
![]() |
![]() |
#40 |
Junior Member
Join Date: Mar 2002
Posts: 27
|
I know that but the code in the LogicLib Wiki (which is the official entry for LogicLib and makes the recommendation, actually - and links to this thread) doesn't work. It's weird that it doesn't work actually, FileExists2 is nearly identical to the old one, it looks like it should work the same except for returning false on directories.
Original: PHP Code:
PHP Code:
Wonder why it doesn't work? |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|