Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 21st August 2008, 13:50   #2
Ilitirit
Junior Member
 
Join Date: Nov 2001
Posts: 27
This seems to do the trick...

PHP Code:
push "Data Source=server;Initial Catalog=database;User ID=user;Password=password"
pop $0
  
${WordFind} $"Data Source=" "-1" $R0
${WordFind$R0 ";" "+1" $DataSource

${WordFind} $"Initial Catalog=" "-1" $R0
${WordFind$R0 ";" "+1" $InitialCatalog

${WordFind} $"User ID=" "-1" $R0
${WordFind$R0 ";" "+1" $UserId
  
${WordFind} $"Password=" "-1" $R0
${WordFind$R0 ";" "+1" $Password
  
MessageBox MB_OK 
"[$DataSource|$InitialCatalog|$UserId|$Password]" 

Edit:
I put it into a function. It seems to work, but am I doing it correctly?

PHP Code:
!define ParseConnectionString "!insertmacro ParseConnectionString"
!macro ParseConnectionString ConnectionString Server Database UserId Password
    Push 
"${ConnectionString}"

    
Call ParseConnectionString

    Pop 
"${Password}"
    
Pop "${UserId}"
    
Pop "${Database}"
    
Pop "${Server}"
!macroend

Function ParseConnectionString
     Exch 
$0     Connection string

     push 
$1     Temp variable
     push $R0    
Server
     push $R1    
Database
     push $R2    
User Id
     push $R3    
Password

     
${WordFind} $"Data Source=" "E-1" $1
     IfErrors 
++3
     StrCpy $R0 
""
     
Goto GetDatabase
     
${WordFind} $";" "+1" $R0

     GetDatabase
:
     ${
WordFind} $"Initial Catalog=" "E-1" $1
     IfErrors 
++3
     StrCpy $R1 
""
     
Goto GetUserId
     
${WordFind} $";" "+1" $R1

     GetUserId
:
     ${
WordFind} $"User ID=" "E-1" $1
     IfErrors 
++3
     StrCpy $R2 
""
     
Goto GetPassword
     
${WordFind} $";" "+1" $R2

     GetPassword
:
     ${
WordFind} $"Password=" "E-1" $1
     IfErrors 
++3
     StrCpy $R3 
""
     
Goto End
     
${WordFind} $";" "+1" $R3

     End
:
     
Exch 5      Move the previous value of $0 to the top of the stack
     Pop 
$0      Restore $0 variable

     Exch 4      
Move the previous value of $1 to the top of the stack
     Pop 
$1      Restore $1 variable

     Exch $R1    
Restore $R2 and put the database at the top of the stack
     Exch        
Swap the database with the server output variable


     Exch $R0    
Restore $R0 and put the server at the top of the stack
     Exch 2      
Swap the server with the user id output variable

     
     Exch $R2    
Restore $R2 and put the user id at the top of the stack
     Exch 3      
Swap the user id with the password output variable

     
     Exch $R3    
;  Restore $R3 and put the password at the top of the stack

     
Stack looks like this (bottom to top):
     ; 
Password|Database|Server|User Id
     
     Exch 3      
User Id|Password|Database|Server
     Exch 2      
Password|User Id|Database|Server
     Exch 3      
Server|User Id|Database|Password
     Exch        
User Id|Server|Database|Password
     Exch 2      
Database|Server|User Id|Password
     Exch        
Server|Database|User Id|Password
     
FunctionEnd 

Last edited by Ilitirit; 21st August 2008 at 15:49.
Ilitirit is offline   Reply With Quote
 
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