Archive: convertion from string to defined constant


convertion from string to defined constant
I'm wondering if there is any way to convert a string to a defined constant. I've made some definitions like this (the number of defined constants could vary):

!define DEF1 "help"
!define DEF2 "me"
!define DEF3 "please"

And I want to create a loop where I increment the number in the defined name. I've tried something like this (without the loop, and without success...):

StrCpy $R0 1

StrCpy $R1 "DEF$R0" # $R1 is now "DEF1"

;Now I try to refer to $DEF1 without success
WriteRegStr HKLM "Path" "Name" "${$R1}"

Is there any way to solve this? Alternatively another way to do this operation?

Thanks...


You can't do that with StrCpy and friends because that's mixing runtime and build time. StrCpy is executed at runtime on the user's computer while the processing of defines is done at build time.

You can use an external application to calculate the sum of your variables and have it save the result in a .nsh file you can later !include.


I need some help I was trying to do the same thing with defines but since its compile time its not gonna work, Im trying to ,at run time set the custom nsdialogs page that is shown
based on info gathered in Function .onInit so i have


so like i have
Function .onInit
!insertmacro MULTIUSER_INIT
;---misc code to check if $=ok or not here
${If} $1 != 'ok'
!define PAGETOSHOW NsdialogsErrorPage
${EndIf}

${If} $1 == "ok"
!define PAGETOSHOW NsdialogsEverythingGoodPage
${EndIf}
FunctionEnd



then for the pages section I have
Page custom "${PAGETOSHOW}"

soo this will dot work since defines are compile time Ive tryed it as a Var instead but then the page custom throws a error

Use GetFuncAddress instead and put the result in a global variable. Then, in the custom page function, use Call on that variable. Or simply add an ${If} in the custom page on the value of some variable and call the appropriate function.