Old 26th September 2016, 04:52   #1
ivaldes1
Junior Member
 
Join Date: Dec 2009
Posts: 12
ReadRegStr syntax?

I have the following code that works that queries the user for an IP then stores the IP as a session variable:

WriteRegExpandStr ${env_hklm} ASTRO_SSH_HOST "$VISTA_HOST"

I want to detect the presence of a pre-existing entry so that it will fill in the default IP on re-install so the user does not have to re-enter it. This gives a compiler error:

ReadRegSt ${VISTA_HOST} ${env_hklm} "" "ASTRO_SSH_HOST"

What might the proper syntax be for this?

Thanks!

-- IV
ivaldes1 is offline   Reply With Quote
Old 26th September 2016, 05:01   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
You are trying to store something in a define. Defines are replaced by its text content at compile-time, you need to use a variable to store things at run-time...

When asking questions, always include the compiler error message!

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th September 2016, 15:53   #3
ivaldes1
Junior Member
 
Join Date: Dec 2009
Posts: 12
Thank you for the reply. Compiler output is:

Invalid Command: ReadRegStr

${VISTA_HOST} is devined as var VISTA_HOST? What am I missing here?
ivaldes1 is offline   Reply With Quote
Old 26th September 2016, 17:26   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
Defining a variable like that is usually pointless.

Just do
Quote:
Var VISTA_HOST
Section
!define env_hklm HKLM ;?
ReadRegSt $VISTA_HOST ${env_hklm} "" "ASTRO_SSH_HOST" ; Pretty sure you don't want "" as the path, you probably want "Software\Something"
SectionEnd

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th September 2016, 14:18   #5
ivaldes1
Junior Member
 
Join Date: Dec 2009
Posts: 12
So I want to set $VISTA_HOST to 'Enter IP here.' on first time install then upgrades will pre-fill the IP address. How is null string comparison done in NSIS? The below does not seem to work:
ReadRegStr $VISTA_HOST ${env_hklm} "ASTRO_SSH_HOST"
${If} $VISTA_HOST == ""
StrCpy $VISTA_HOST "$HOST"
${EndIf}
ivaldes1 is offline   Reply With Quote
Old 27th September 2016, 14:36   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
Since you don't show us what ${env_hklm} is we cannot exactly test but yes, checking for a empty string can be done with == "". Maybe you should just try MessageBox mb_ok "|$VISTA_HOST|" so you can see what you read.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump