While using the installer code from Toucan for one of my latest apps in beta, BonkEnc Portable I'm trying to change the way the installer writes the language of the actual application to it's settings depending on the language chosen from the installer, I'm having trouble, and would appreciate some help.
This is the code from Toucan I'm changing
;=== Set Language
StrCmp $LANGUAGE "1031" 0 +3 ;German
WriteINIStr $INSTDIR\Data\Settings.ini "General" "Language" "wxLANGUAGE_GERMAN"
Goto RefreshPortableAppsMenu
StrCmp $LANGUAGE "1036" 0 +3 ;French
WriteINIStr $INSTDIR\Data\Settings.ini "General" "Language" "wxLANGUAGE_FRENCH"
Goto RefreshPortableAppsMenu
WriteINIStr $INSTDIR\Data\Settings.ini "General" "Language" "wxLANGUAGE_ENGLISH" ;=== Fallback to English
And this is what I changed the above code to for my app, since my app uses an XML file to store settings, not an INI. I decided just to have the installer replace the language string in the default settings instead of adding in some code that would require XML plugins.
;=== Set Language
StrCmp $LANGUAGE "1031" 0 +3 ;German
${ReplaceInFile} "$INSTDIR\App\DefaultData\settings\config.xml" "internal" "bonkenc_de.xml"
Delete "$INSTDIR\App\DefaultData\settings\config.xml.old"
Goto RefreshPortableAppsMenu
StrCmp $LANGUAGE "1036" 0 +3 ;French
${ReplaceInFile} "$INSTDIR\App\DefaultData\settings\config.xml" "internal" "bonkenc_fr.xml"
Delete "$INSTDIR\App\DefaultData\settings\config.xml.old"
Goto RefreshPortableAppsMenu
${ReplaceInFile} "$INSTDIR\App\DefaultData\settings\config.xml" "internal" "internal"
Delete "$INSTDIR\App\DefaultData\settings\config.xml.old" ;=== Fallback to English
Now, I understand from other parts of the installer that the numbers are variables for languages. So if it's using 1031 language, it will use the lines below it. Does the installer skip the any code that is not the variable of the language it's using and then just default to English? I think it does. The problem I have is when I compile, it compiles fine, but then I get an error saying 'Installer Corrupter: Invalid opcode'. So I'm wondering what I have to change, and what the 0 +3 thing means.
I tried reading into this, but I just can't figure it out. I know this is mainly a question for Johns since he wrote it, and I'd love some quick help.
I know it's probably something with the fact that it's StrCmp and I'm using ReplaceInFile, but I don't know what.
Thanks.
The +3 means to skip ahead 3 lines (if not equal). That takes program flow to the next StrCmp. (Careful how you count. You're going to the third line, not skipping over three intervening lines.)
It might be clearer to use a label instead.
You probably want it to skip ahead a different number of lines (like +5 to get to the next StrCmp) ... or put in a label and have it jump to the label instead.
The 0 means to go to the next line. So if the things are equal, you go to the next line; if they are not equal, you skip to a different section.
MC
I'll try that.
I hope John's emailed you about becoming an official dev, although he is really opening to outside dev's now. As I've noticed you know a lot about NSIS.
Why thank you.
So far I haven't found something to work on; the obvious ones seem to be taken.
MC
I tried it. I changed it to 4 at first, because the lines above are wrapped, and it all stayed english, so I changed just the first one to 5 and the german and english worked, then I change both to 5 and nothing worked, so I'll just use labels.
Edit: Labels work fine, thanks.
Thanks.
This also would have worked:
Macro lines and defined lines count as lines of code within sections and functions
What's a signature?
It's more readable to use labels anyway.
"If you're not part of the solution, you're part of the precipitate."
How about Halite?
It has been mentioned a few times, but I don't think anyone has done it.
Just a thought...
~Lurk~
*steals*
"If you're not part of the solution, you're part of the precipitate."