Archive: connecting variables ???


connecting variables ???
since i am working on my latest project i need an array for seperate languages which differs from NSIS-system for language

i do it like this:

!define g_active "bla"
!define e_active "blubb"
!define f_active "nonsense"

g e f are standing for the 3 languages and handle in this var $LANGSHORT

so the message goes like this:
messagebox mb_ok "${$LANGSHORT_active}"

but i only get "${g_active}" :cry:

is it possible or not ?


I'm not sure I understand exactly what you are asking. To my knowlege, NSIS does not support arrays.

But, the way I'm reading your question, it sounds like you simply want to concatenate all g, e, and f variables. If that the case, then use this:


strCpy $LANGSHORT_active "${g_active}${e_active}${f_active}"

NSIS dont support arrays - that i found out a longer time ago
some1 has written another solution for that...
search for "array" here...

but that was not my purpose...

>> strCpy $LANGSHORT_active "${g_active}${e_active}${f_active}"

$LANGSHORT is a standalone variable
it is possible to combine it with fixed values eg.
$LANGSHORTmenu01.ini (for IO)
but i didnt match it for 2 variables in a box

${$LANGSHORT_active}

red is the inner name and green the outer name
${g_active}

This is the result -> ${g_active}
but it is not handled as a variable any longer, just plain text.


OK, hopefully I've got this all sorted out. Let's see how I did...

You have a variable called $LANGSHORT, which can be either 'g', 'e', or 'f'. You want to take this value and append '_active' to come up with a variable name and then from that return the value of that variable?

Based on your example above, it sounds like $LANGSHORT has a value of 'g'. Therefore, you want to return the value of the variable $g_active, (which is 'bla'). But instead of getting 'bla', you are geting the text '${g_active}'. (Right so far?)

While I haven't been able to work out a formula quite on your line of thinking, I did manage to find an alternative that should acomplish the task. It uses a 5th variable and a string of StrCmp functions to return the proper variable by using a function. It's goes something like this:


Function GetValue
StrCmp $LANGSHORT "g" returnG findE
returnG:
StrCpy $0 ${g_active}
Return
findE:
StrCmp $LANGSHORT "e" returnE findF
returnE:
StrCpy $0 ${e_active}
Return
findF:
StrCmp $LANGSHORT "f" returnF findNothing
returnF:
StrCpy $0 ${f_active}
Return
findNothing:
strCopy $0 ""
FunctionEnd


(This is just a quick example--in practice, you might need to clean this code up a bit.)

If this doesn't give you want you want, perhaps there's a brighter bulb out there that might be able to offer some other advice.

Thanks!

>> It's goes something like this:

That is what i already had and i want away from.
It blows up my code and theses fragments are thrown all over my code.

I have to think about an (ini-) array :/