|
|
|
|
#1 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
How set the value of the attributes
First,excuse my english, my native language is french
I try to set a SYMBOL with !define inside a macro. The final target is: set the value of attribute at compile-time. I take Caption for this exemple. Later, if it work, I use ${If} ${Else}... for decide which value for each attributes... I don't understand why is so difficult to set the value of this attributes at compile-time for differents circumstances ??? -inside section...........No permit -inside function..........No permit -With variable............No permit How set the value of this attributes in a flexible way ? ############################### !macro test !define TITLE_TEXT "SimpleTest" !macroend outFile "Output.exe" Caption "${TITLE_TEXT}" section !insertmacro test sectionEnd ;Don't work ??? |
|
|
|
|
|
#2 | |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
Quote:
You can modify the !define values with compile time statements !if !else !endif !ifdef and all their cousins. Don |
|
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
Tanks Don,
I note that. But, in my Exemple i dont use ${If} or ${Else} and the !define inside the macro Don't work If we can't set a value of attributes(*) with a: macro section function variable Then How ? (*) AddBrandingImage AllowRootDirInstall AutoCloseWindow BGFont BGGradient BrandingText Caption ChangeUI CheckBitmap CompletedText ComponentText CRCCheck DetailsButtonText DirText DirVar DirVerify FileErrorText Icon InstallButtonText InstallColors InstallDir InstallDirRegKey InstProgressFlags InstType LicenseBkColor LicenseData LicenseForceSelection LicenseText MiscButtonText Name OutFile RequestExecutionLevel SetFont ShowInstDetails ShowUninstDetails SilentInstall SilentUnInstall SpaceTexts SubCaption UninstallButtonText UninstallCaption UninstallIcon UninstallSubCaption UninstallText WindowIcon XPStyle SylBou |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
You can use !define inside a !macro, and you can use !insertmacro in a Section or Function.
You cannot use a defined name ( ${TITLE_TEXT} ) before the !define is compiled. Because you put the !define in a macro, the name does not get its value until or unless the macro is inserted. The error occurred in your script because the macro was inserted after (below the line where) the defined name ${TITLE_TEXT} was used. Don |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
Ok, Merci Beaucoup !
My error is very stupid... But for the moment is not very useful. If i want my Caption = "YesYes" if ${GoodTest} = "yes" and "NoNo" if ${GoodTest} <> "yes" How do that ! ########################### !define GoodTest "yes" !macro test !define TITLE_LABEL "WorkWithCaptionInMacro" !macroend section !insertmacro test sectionEnd OutFile "OutPut.exe" Caption ${TITLE_LABEL} ;?????????????????????????? |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
code: |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
!!! WONDERFUL !!!
WithOut LogicLib !!! FANTASTIK !!! Tanks,Tanks,Tanks I need time for test that with ReadINIStr and comeback with news. Why ? Because i want config the NSIS script with a external .ini file. exactly like another software... I am a Lingo programmer (Adobe Director) and i want "automatized" the process of the my screensavers SetUp build. Tanks a another time... SylBou PS: The programmation language of NSIS is very crazy. Lingo ActionScript Javascript is for the baby... Last edited by LingoSag; 25th March 2009 at 05:47. |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
;Don, Try this (For the Moment: Full path name for the ini file)
outfile "OutPut.exe" Caption '$0' BrandingText '$1' CompletedText '$2' ShowInstDetails show function .onInit ReadINIStr '$0' "F:\Data\040-WinXp-Bureau\MyConfig.ini" Main Cap ReadINIStr '$1' "F:\Data\040-WinXp-Bureau\MyConfig.ini" Main Brand ReadINIStr '$2' "F:\Data\040-WinXp-Bureau\MyConfig.ini" Main CompTxt functionend section DetailPrint "Hello World" sectionend ############ ;Don't work with outfile. I dont know because Hooups ini file ini file... [Main] Cap=MyCaption Brand=MyBrand CompTxt=MyCompletedTxt |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
You can't change the Outfile parameter because the .onInit Function is called during runtime and contains runtime statements but Outfile needs a file name during compile time.
You can pass defined values into the NSIS compiler from the command line with the /D switch. Maybe that will allow you the configuration changes you are looking for. In the script you will use this define like this:code: code: (Edit: script name should be after the /D switches) Don |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
Ok,Three things,
After excitement, I finaly dont trust the usage of the '$0','$1','$2'... for set the attributes values. NSIS Crash many times and i loose confidence. (he do, but he dont like it...) NSIS Official Doc: "Note that these attributes can be set anywhere in the file except in a Section or Function" -- Tanks for command line usage for set OutFile, But the script must work also in standard way (context menu) (I dont test if overwrite) The real basic question is: Simple exemple, for ??? Very simple thing ??? How set (!define) the value of the PRODUCT_NAME with a external ini file (ReadINIStr) ? ############################################### !define PRODUCT_NAME "MyApplicationName" OutFile "${PRODUCT_NAME}.exe" section ; sectionEnd ############################################### ini file [Main] PRODUCT_NAME=MyApplicationName
|
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
You cannot use ReadIniStr during the compile time because it is a runtime command.
I think you should consider using the !SYSTEM and !EXECUTE commands to read your ini file and create a nsh header file that contains !defines for the ini values. The nsh header file can then be !included before the defined names are needed. You will have to create a batch file, script file (pl or vbs, perhaps), or separate exe to convert the ini values for the nsh file. I do something like that to define a build version number and the year (for the copyright data). BuildNum.nsh :code: code: Don |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
Is not simple, but also very interesting.
Thank you I work on that, and come back with news... SylBou |
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
Ok Don, use nsh file is a good strategy.
Edit this file with Lingo is very very easy. Directly or via an ini file, no problem. But, please one more step with your pass answer/exemple. If ${GoodTest} = "yes" I want set ${TITLE_LABEL} with the value of ${GoodTestDataOne} And If ${GoodTest} <> "yes" I want set ${TITLE_LABEL} with the value of ${GoodTestDataTwo} Possible ? !define GoodTest "yes" !define GoodTestDataOne "Dog" !define GoodTestDataTwo "Cat" !macro test !ifndef TITLE_LABEL !define TITLE_LABEL "" !endif !macroend !if ${GoodTest} = "yes" !define TITLE_LABEL "yesyes" !else !define TITLE_LABEL "nono" !endif OutFile "OutPut.exe" Caption ${TITLE_LABEL} section !insertmacro test sectionEnd SylBou |
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
code: You may be making it overly complicated with TITLE_LABEL derived from GoodTestDataOne or GoodTestDataTwo. Unless you are using GoodTestDataOne and GoodTestDataTwo other places, you can eliminate them and write code: |
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
Ok Don,
Its simple and work well, Thank you ! My Last Question (Sorry) What's wrong with this script: I Know is not logic, Because !insertmacro test is after the Conditional but how do Otherwise ? ###################################### Outfile "outfile.exe" !define FRENCH_CAPTION "MyFrenchCaption" !define ENGLISH_CAPTION "MyEnglishCaption" !define LOCALE_SNATIVELANGNAME '0x4' !macro test System::Call 'kernel32::GetLocaleInfoA(i 1024, i ${LOCALE_SNATIVELANGNAME}, t .r1, i ${NSIS_MAX_STRLEN}) i r0' ;MessageBox MB_OK $1 !macroend !if $1 = "français" Caption ${FRENCH_CAPTION} !else Caption ${ENGLISH_CAPTION} !endif section !insertmacro test sectionend ###################################### |
|
|
|
|
|
#16 | |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
Quote:
|
|
|
|
|
|
|
#17 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
Is not the only problem with this Stategy
Even if work, at compile time is set the value of my system language and not the user system language. Then, the true question now is: How set the values of attributes(*) at run time ? Forget the solution with '$0','$1','$2'...is not BugProof I take one day for write the script of my screensaver installer. And i have no idea for set a simples variables in a conditional environnement. I musk think Tank you, Don, for your Great Help. SylBou (*) Caption MiscButtonText InstallButtonText BrandingText CompletedText For automatic language GUI PS:I like my lingo, is simple and very powerfull Last edited by LingoSag; 26th March 2009 at 00:28. |
|
|
|
|
|
#18 |
|
Junior Member
Join Date: Mar 2009
Posts: 15
|
That is the true limitation of the NSIS
NSIS Official Doc: "Note that these attributes can be set anywhere in the file except in a Section or Function" They forget: ...or macro...or...variables NSIS can run, but he can't walk... ###################################################### !include LogicLib.nsh outFile "installer.exe" !define LANGUAGE_DETECT_SIMULATION "français" !define FRENCH_CAPTION "MyFrenchCaption" !define ENGLISH_CAPTION "MyEnglishCaption" Caption "TEMP" !macro test ${If} ${LANGUAGE_DETECT_SIMULATION} == "français" Caption ${FRENCH_CAPTION} ${Else} Caption ${ENGLISH_CAPTION} ${EndIf} !macroend section ; sectionEnd Function .onInit !insertmacro test FunctionEnd ###################################################### Obviously Don't Work Bye My GUI with a automatic language detect ![]() PS: At .onInit event the dialog windows is not draw, this limitation have no sens for me... The other solution, Dynamically change the contents of the GUI with GetDlgItem,SendMessage,ect...it not easy beause the .onGUIInit event overwrite our settings, Ok with a little timer for the first page but we have no events for the next pages SylBou |
|
|
|
|
|
#19 |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
LingoSag,
I think before you go too much further, you should take some time to read the documentation and look at the numerous sample scripts to get a good feel for NSIS before going full bore trying to create your own scripts. Also, posting several posts back to back usually just annoys people. There are several resources available to help you--this forum, the wiki, and even your NSIS installation directory. There's also a French support site that might be of some help. For your issues below, here's one article that might be of help:http://nsis.sourceforge.net/Language...ws_UI_Language. There's also a sample file named 'languages.nsi' in ${NSISDIR}\examples that you might want to look it. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|