![]() |
problems inserting finish page
im encountering problems with insertng finish page.Im using this !insertmacro MUI_PAGE_FINISH macro code looks as below
;-------------------------------- ;Modern UI Configuration ; Show a warning when the user cancels the install !define MUI_ABORTWARNING ; I'm using some custom pages !define MUI_CUSTOMPAGECOMMANDS ; Show a finish page at the end of the installation !define MUI_FINISHPAGE ; Don't present the option to reboot the computer on the finish page !define MUI_FINISHPAGE_NOREBOOTSUPPORT ; The icon for the installer title bar and .exe file !define MUI_ICON "eclipse.ico" ; I've written a function that I want to be called when the user cancels the installation !define MUI_CUSTOMFUNCTION_ABORT myOnAbort ; Override the text on the Finish Page !define MUI_FINISHPAGE_TITLE "Installation Complete" !define MUI_FINISHPAGE_TEXT "Survey has been queued for installation on the selected Palm devices.\r\n\r\nClick 'Finish,' then HotSync each device to complete publishing." ;-------------------------------- ; Modern UI Pages (listed in order they will appear ; file installation page (preps needed files) !insertmacro MUI_PAGE_INSTFILES ; custom page for choosing the Palm user(s) to publish to Page custom ShowUserList LeaveCustom ;Page custom ShowUserList ; this will be called before the finish page is displayed to perform cleanup !define MUI_PAGE_CUSTOMFUNCTION_PRE myFinishPre ; finish page !insertmacro MUI_PAGE_FINISH ;-------------------------------- ;Languages ; English only for now !insertmacro MUI_LANGUAGE "English" ;-------------------------------- when i run the installer only window with close and button pops up.How do i solve this problem |
Why do you have !insertmacro MUI_PAGE_FINISH twice?
|
i have inserted only once which causes only the close window appear on the screen.
|
What is the close window?
Stu |
i meant to say that window pops up with close button in place of next button.How can i get the final finish page instead of this window?
|
That is the finish page. Maybe you mean !define MUI_FINISHPAGE_NOAUTOCLOSE.
Stu |
after publishing page with finish button should appear on the screen indicating user to perform hotsync.But this is not happening in my application
|
my script is as follows
; declare variables Var PalmUserList ; Used to dynamically populate dropdown on User Selection page Var UserChoice ; Selected Palm Username Var InstallStatus ; Defined when the installer is aborting Var SurveyName ; Survey full path from command line parameter Var StatPDB ; full path of EpiSurveyor_stat.pdb Var PublishDir Var count Var isSelectAll Var userLists Var UserSelection Var HWND Var ChildSurveyName Var Survey Name "Survey Publisher" ;Display name for installer ; declare macros !macro IndexOf Var Str Char Push "${Char}" Push "${Str}" Call IndexOf Pop "${Var}" !macroend !define IndexOf "!insertmacro IndexOf" !macro StrRep ResultVar String SubString RepString Push "${String}" Push "${SubString}" Push "${RepString}" Call StrRep Pop "${ResultVar}" !macroend !define StrRep "!insertmacro StrRep" !include "MUI.nsh" !include "LogicLib.nsh" !include "WinMessages.nsh" ;-------------------------------- ;Configuration ; Name of the resulting executable installer file OutFile "publish.exe" ; I don't intend to install any files permenantly on the PC, so ; use the system temporary directory InstallDir "$TEMP\EpiSurveyorSetup" ;-------------------------------- ;Modern UI Configuration ; Show a license agreement page !define MUI_LICENSEPAGE ; Show a warning when the user cancels the install !define MUI_ABORTWARNING ; I'm using some custom pages !define MUI_CUSTOMPAGECOMMANDS ; Show a finish page at the end of the installation !define MUI_FINISHPAGE ; Don't present the option to reboot the computer on the finish page !define MUI_FINISHPAGE_NOREBOOTSUPPORT ; The icon for the installer title bar and .exe file ;!define MUI_ICON "eclipse.ico" ; I've written a function that I want to be called when the user cancels the installation !define MUI_CUSTOMFUNCTION_ABORT myOnAbort ; Override the text on the Finish Page !define MUI_FINISHPAGE_TITLE "Installation Complete" !define MUI_FINISHPAGE_TEXT "Survey has been queued for installation on the selected Palm devices.\r\n\r\nClick 'Finish,' then HotSync each device to complete publishing." ;-------------------------------- ; Modern UI Pages (listed in order they will appearance ; file installation page (preps needed files) !insertmacro MUI_PAGE_INSTFILES ; custom page for choosing the Palm user(s) to publish to Page custom ShowUserList LeaveCustom !define MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT DisableBackButton ; this will be called before the finish page is displayed to perform cleanup !define MUI_PAGE_CUSTOMFUNCTION_PRE myFinishPre !insertmacro MUI_PAGE_FINISH ;-------------------------------- ;Languages ; English only for now !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ;Language Strings ;Description text that I want to appear while files are being copied LangString DESC_SecCopyUI ${LANG_ENGLISH} "Copying the Palm files to your computer so they can be installed to your device." ;Header text for all pages in the installer LangString TEXT_IO_TITLE ${LANG_ENGLISH} "EpiSurveyor" LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "Publish a survey to your devices" ;-------------------------------- ;Reserve Files ;Things that need to be extracted first (keep these lines before any File command!) ;Required for proper behavior when using BZIP2 compression ReserveFile "showUserList.ini" !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ;-------------------------------- ;Installer Sections Section "Prep for install" SecCopyUI ; get survey name from command line parameter Push $R0 Call GetParameters Pop $R0 ${StrRep} $R0 $R0 "/" "\" ; replace slashes StrCpy $SurveyName $R0 Loop: ; loop until we have the index of the last slash ${IndexOf} $R1 $R0 "\" IntOp $0 $R1 + 1 ;advance index past the slash StrCpy $R0 $R0 "" $0 ; $R0 now has first segment of path removed StrCmp $R1 -1 LastToken Next Next: IntOp $R2 $R2 + $R1 ; sum of segments we've traversed found so far IntOp $R2 $R2 + 1 ; add one for the slash GoTo Loop LastToken: IntOp $3 $3 + 1 StrCpy $Survey $R0 ; MessageBox MB_OK|MB_ICONINFORMATION "index = $R2" StrLen $1 $SurveyName ; MessageBox MB_OK|MB_ICONINFORMATION "path length = $1" IntOp $2 $R2 - $1 ; index minux length of string: negative to count back from end of string ;MessageBox MB_OK|MB_ICONINFORMATION "length of shortened path = $2" StrCpy $R3 $SurveyName $2 ; MessageBox MB_OK|MB_ICONINFORMATION "value of R3 IS $R3" StrCpy $PublishDir $R3 ;MessageBox MB_OK|MB_ICONINFORMATION "publish dir is $PublishDir" StrCpy $StatPDB "$R3EpiSurveyor_stat.pdb" SetOutPath "$INSTDIR" ; Copy the files that we will use File "UserData.dll" File "InstAide.dll" SectionEnd ;-------------------------------- ;Descriptions !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyUI} $(DESC_SecCopyUI) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Installer Functions Function .onInit ;Extract InstallOptions INI Files !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "showUserList.ini" "showUserList.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "showUserList.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "installfiles.ini" FunctionEnd ; displays our custom "Select Palm User" page Function ShowUserList Call GetPalmUserList ; Use this list to populate the list on our custom page !insertmacro MUI_INSTALLOPTIONS_WRITE "showUserList.ini" "Field 2" "ListItems" "$PalmUserList" !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)" !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "showUserList.ini" Pop $HWND GetDlgItem $1 $HWNDPARENT 1 EnableWindow $1 0 !insertmacro MUI_INSTALLOPTIONS_SHOW Pop $0 InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\showUserList.ini" Call LeaveCustom ; if we are aborting, do not check the value of UserChoice (if we do, then ; if the user cancels the install without selecting a user, it will insist ; that the user choose a user before exiting) StrCmp $InstallStatus "aborting_ir_install" End 0 !insertmacro MUI_INSTALLOPTIONS_READ $UserChoice "showUserList.ini" "Field 2" "State" StrCmp $isSelectAll "1" End StrCmp $isSelectAll "0" End ; Verify that the user chose a valid user. If not, display the ShowUserList ; screen again. ; Why not simply set MinLen of the dropdown to 1? This will prevent the user ; from continuing without selecting a user, but it will not present any ; messagebox or other dialog. That is confusing to the user! StrCmp $UserChoice "" 0 Continue MessageBox MB_OK|MB_ICONINFORMATION "You must choose at least one user to proceed." Call ShowUserList GoTo End Continue: ; MessageBox MB_OK|MB_ICONINFORMATION "About to call InstallFiles function." Call InstallFiles ; MessageBox MB_OK|MB_ICONINFORMATION "Just returned from InstallFiles function." End: FunctionEnd Function LeaveCustom ; At this point the user has either pressed Next or one of our custom buttons ; We find out which by reading from the INI file ReadINIStr $0 "$PLUGINSDIR\showUserList.ini" "Settings" "State" !insertmacro MUI_INSTALLOPTIONS_READ $UserSelection "showUserList.ini" "Field 2" "State" StrCmp $0 0 Done ; Next button? StrCmp $0 3 SelectAll ; select all users StrCmp $0 4 UnselectAll ; unselect all users ;added by shwetha on dec 07,2007 StrCmp $0 2 Selection Abort ; Return to the page SelectAll: StrCpy $isSelectAll "1" GetDlgItem $1 $HWNDPARENT 1 EnableWindow $1 1 GetDlgItem $1 $HWND 1203 EnableWindow $1 1 ;added on dec 04,2007 GetDlgItem $1 $HWND 1202 EnableWindow $1 0 GetDlgItem $1 $HWND 1201 SendMessage $1 ${LB_SELITEMRANGEEX} 0 $count StrCpy $userLists $PalmUserList Abort UnselectAll: GetDlgItem $0 $HWND 1201 SendMessage $1 ${LB_SETSEL} 0 -1 GetDlgItem $1 $HWNDPARENT 1 EnableWindow $1 0 StrCpy $isSelectAll "0" GetDlgItem $1 $HWND 1203 EnableWindow $1 0 ;added on dec 04,2007 GetDlgItem $1 $HWND 1202 EnableWindow $1 1 StrCpy $userLists "" Abort Selection: !insertmacro MUI_INSTALLOPTIONS_READ $UserSelection "showUserList.ini" "Field 2" "State" StrCmp $UserSelection "" Disable Disable: GetDlgItem $1 $HWNDPARENT 1 EnableWindow $1 0 StrCmp $UserSelection "" End Cont Cont: GetDlgItem $1 $HWNDPARENT 1 EnableWindow $1 1 call InstallFiles End: Abort Done: StrCmp $isSelectAll 1 installAll StrCmp $isSelectAll 0 next StrCmp $UserChoice "" msg ; check if no users have been selected installAll: call InstallAllFiles StrCpy $userLists "" StrCmp $userLists "" msg Abort next: StrCmp $UserChoice "" msg StrCmp $isSelectAll "" msg StrCmp $UserSelection "" msg msg: FunctionEnd Function InstallAllFiles ; MessageBox MB_OK|MB_ICONINFORMATION "Installing for all the users in progress...." ; ==================== INSTALL PRC/PDB FILES ========================== ; Set the PRC file to be installed to internal memory on next HotSync StrCpy $1 $UserChoice StrCpy $UserChoice $userLists ; Loop: ${IndexOf} $R0 $UserChoice "|" StrCpy $R3 $R0 ; if this was the last token $R3 will be -1 and we'll stop looping StrCmp $R3 -1 LastToken Moveon LastToken: StrCpy $1 $UserChoice Goto InstallSurveyPDB Moveon: StrCpy $1 $UserChoice $R0 ; $1 = first token IntOp $R0 $R0 + 1 StrCpy $R2 $UserChoice "" $R0 ; R2 = new $UserChoice StrCpy $UserChoice $R2 InstallSurveyPDB: StrCpy $2 "$SurveyName.pdb" ;MessageBox MB_OK|MB_ICONINFORMATION "Installing $2 for user $1" System::Call 'InstAide::PltInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "Attempting install of $2 for user $1 PltInstallFile returned value of $3" StrCmp $3 "-504" +1 +3 ;ERR_PILOT_COPY_FAILED ; MessageBox MB_OK|MB_ICONINFORMATION "Copy Failed" Goto InstallOtherPDBs StrCmp $3 "-512" +1 InstallOtherPDBs ;ERR_PILOT_FILE_ALREADY_EXISTS ;MessageBox MB_OK|MB_ICONINFORMATION "Uninstalling $2 for user $1" System::Call 'InstAide::PltRemoveInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "PltRemoveInstallFile returned value of $3" System::Call 'InstAide::PltInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "PltInstallFile returned value of $3" InstallOtherPDBs: StrCpy $2 "$StatPDB" ;MessageBox MB_OK|MB_ICONINFORMATION "Installing $2 for user $1" System::Call 'InstAide::PltInstallFile(t r1, t r2) i .r3' ; MessageBox MB_OK|MB_ICONINFORMATION "PltInstallFile returned value of $3" ; We don't care if there is one of these in the queue already, it'll do fine StrCpy $2 "$SurveyName_data.pdb" ; MessageBox MB_OK|MB_ICONINFORMATION "Installing $2 for user $1" System::Call 'InstAide::PltInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "PltInstallFile returned value of $3" ; We don't care if there is one of these in the queue already, it'll do fine Strcmp $count 0 End increment increment: IntOp $count $count - 1 Strcmp $count 0 End Loop StrCmp $R3 -1 End Loop ; StrCpy $userLists "" End: ; ==================== SHOW CUSTOM PAGE ========================== ; !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)" ;!insertmacro MUI_INSTALLOPTIONS_DISPLAY "installfiles.ini" FunctionEnd Function InstallFiles ; ==================== INSTALL PRC/PDB FILES ========================== ; Set the PRC file to be installed to internal memory on next HotSync StrCpy $1 $UserChoice StrCpy $UserSelection "$UserSelection|" Loop: ${IndexOf} $R0 $UserSelection "|" StrCpy $R3 $R0 ; if this was the last token $R3 will be -1 and we'll stop looping StrCmp $R3 -1 LastToken Moveon LastToken: StrCpy $1 $UserSelection Goto InstallSurveyPDB Moveon: StrCpy $1 $UserSelection $R0 ; MessageBox MB_OK|MB_ICONINFORMATION "first user is $1" IntOp $R0 $R0 + 1 ;StrCpy $R2 $UserChoice "" $R0 ; R2 = new $UserChoice StrCpy $R2 $UserSelection "" $R0 ; R2 = new $UserChoice ;MessageBox MB_OK|MB_ICONINFORMATION "next user is $R2" StrCpy $UserSelection $R2 InstallSurveyPDB: ; MessageBox MB_OK|MB_ICONINFORMATION " inside InstallSurveyPDB" StrCpy $2 "$SurveyName.pdb" ;MessageBox MB_OK|MB_ICONINFORMATION "Installing $2 for user $1" System::Call 'InstAide::PltInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "Attempting install of $2 for user $1 PltInstallFile returned value of $3" StrCmp $3 "-504" +1 +3 ;ERR_PILOT_COPY_FAILED ;MessageBox MB_OK|MB_ICONINFORMATION "Copy Failed" Goto InstallOtherPDBs StrCmp $3 "-512" +1 InstallOtherPDBs ;ERR_PILOT_FILE_ALREADY_EXISTS ; MessageBox MB_OK|MB_ICONINFORMATION "Uninstalling $2 for user $1" System::Call 'InstAide::PltRemoveInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "PltRemoveInstallFile returned value of $3" System::Call 'InstAide::PltInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "PltInstallFile returned value of $3" InstallOtherPDBs: ;MessageBox MB_OK|MB_ICONINFORMATION " inside InstallotherPDB" StrCpy $2 "$StatPDB" ; MessageBox MB_OK|MB_ICONINFORMATION "Installing $2 for user $1" System::Call 'InstAide::PltInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "PltInstallFile returned value of $3" ; We don't care if there is one of these in the queue already, it'll do fine StrCpy $2 "$SurveyName_data.pdb" ;MessageBox MB_OK|MB_ICONINFORMATION "Installing $2 for user $1" System::Call 'InstAide::PltInstallFile(t r1, t r2) i .r3' ; MessageBox MB_OK|MB_ICONINFORMATION "PltInstallFile returned value of $3" ; We don't care if there is one of these in the queue already, it'll do fine StrCmp $R3 -1 AbortLoop Loop AbortLoop: ; ==================== SHOW CUSTOM PAGE ========================== ;!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)" ;!insertmacro MUI_INSTALLOPTIONS_DISPLAY "installfiles.ini" FunctionEnd Function GetPalmUserList ; NSIS has to be using the directory containing the dll for it to find it SetOutPath "$INSTDIR" File "UserData.dll" ; copy dll there System::Call 'UserData::UmGetUserCount(v) i .r1' ;MessageBox MB_OK|MB_ICONINFORMATION "There seem to be $1 Palm users" ;added byy shwetha for retreiving the palm users count StrCpy $count $1 ;added by shwetha ends here IntCmp $1 0 0 0 foundInstaller ; if return value of PltGetUserCount is 0 or negative, then we can't continue MessageBox MB_OK|MB_ICONINFORMATION "No Palm Installer was found on your system. The installation cannot complete. Please ensure that the latest version of the Palm Desktop Software is installed on your computer before installing." Abort foundInstaller: ; Compile the list of Palm Users StrCpy $2 0 ; Initialize counter StrCpy $PalmUserList "" ; Initialize list Loop: StrCpy $4 ${NSIS_MAX_STRLEN} ; $4 will tell the function the buffer length of $3 ; $3 will be set to the username of the user indexed by $2 System::Call 'UserData::UmGetUserID(i r2, *i r6r6) i .r5' System::Call 'UserData::UmGetUserName(i r6, t .r3, *i r4) i .r5' ;MessageBox MB_OK|MB_ICONINFORMATION "User indexed at $2 has ID $6 and name $3" StrCpy $PalmUserList "$PalmUserList$3|" IntOp $2 $2 + 1 ; Incriment the counter IntCmp $2 $1 0 Loop 0 FunctionEnd Function RemoveFiles ; We need to Unload the dll so that it can be deleted System::Call 'InstAide::PltGetUserCount(v) i .r1 ?u' System::Call 'UserData::UmGetUserCount(v) i .r1 ?u' ; I read somewhere that you should do this. Don't know what it does SetPluginUnload manual System::Free 0 ; Remove all of the files SetOutPath $TEMP Delete "$INSTDIR\InstAide.dll" Delete "$INSTDIR\UserData.dll" SetOutPath $PublishDir Delete "$SurveyName.pdb" Delete "$SurveyName_data.pdb" Delete "$StatPDB" RMDir /r "$INSTDIR" FunctionEnd Function RemoveInstallFiles ; Un-schedule the files for installation to internal memory StrCpy $1 $UserChoice ; pipe-delimited string containing usernames Loop: ; Search string for pipe to get a token ${IndexOf} $R0 $UserChoice "|" StrCpy $R3 $R0 ; if this was the last token $R3 will be -1 and we'll stop looping StrCmp $R3 -1 LastToken Moveon LastToken: StrCpy $1 $UserChoice Goto UnInstall Moveon: StrCpy $1 $UserChoice $R0 ; $1 = first token IntOp $R0 $R0 + 1 StrCpy $R2 $UserChoice "" $R0 ; R2 = new $UserChoice StrCpy $UserChoice $R2 UnInstall: StrCpy $2 "$SurveyName.pdb" ;MessageBox MB_OK|MB_ICONINFORMATION "Uninstalling $2 for user $1" System::Call 'InstAide::PltRemoveInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "PltInstallFile returned value of $3" StrCpy $2 "$SurveyName_data.pdb" ;MessageBox MB_OK|MB_ICONINFORMATION "Installing $2 for user $1" System::Call 'InstAide::PltRemoveInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "PltInstallFile returned value of $3" StrCpy $2 "$StatPDB" ;MessageBox MB_OK|MB_ICONINFORMATION "Installing $2 for user $1" System::Call 'InstAide::PltRemoveInstallFile(t r1, t r2) i .r3' ;MessageBox MB_OK|MB_ICONINFORMATION "PltInstallFile returned value of $3" StrCmp $R3 -1 Continue Loop Continue: FunctionEnd Function DisableBackButton GetDlgItem $1 $HWNDPARENT 3 EnableWindow $1 0 FunctionEnd Function myFinishPre ;MessageBox MB_OK|MB_ICONINFORMATION "myFinishPre about to remove files" ; Before we exit the installer, clean up all of the files that we copied ; to the PC MessageBox MB_OK|MB_ICONINFORMATION "installation completed for $Survey" Call RemoveFiles FunctionEnd Function myOnAbort ;MessageBox MB_OK|MB_ICONINFORMATION "WE ARE ABORTING !!!" ; Let other parts of the installer know that we are aborting StrCpy $InstallStatus "aborting_ir_install" ; In case we've already scheduled files for installation on the next HotSync, ; we should un-schedule them Call RemoveInstallFiles ; Clean up all of the files that we copied to the PC Call RemoveFiles FunctionEnd Function IndexOf Exch $R0 Exch Exch $R1 Push $R2 Push $R3 StrCpy $R3 $R0 StrCpy $R0 -1 IntOp $R0 $R0 + 1 StrCpy $R2 $R3 1 $R0 StrCmp $R2 "" +2 StrCmp $R2 $R1 +2 -3 StrCpy $R0 -1 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd ; GetParameters ; input, none ; output, top of stack (replaces, with e.g. whatever) ; modifies no other variables. Function GetParameters Push $R0 ; MessageBox MB_OK|MB_ICONINFORMATION "survey $R0" Push $R1 Push $R2 Push $R3 StrCpy $R2 1 StrLen $R3 $CMDLINE ;Check for quote or space StrCpy $R0 $CMDLINE $R2 StrCmp $R0 '"' 0 +3 StrCpy $R1 '"' Goto loop StrCpy $R1 " " loop: IntOp $R2 $R2 + 1 StrCpy $R0 $CMDLINE 1 $R2 StrCmp $R0 $R1 get StrCmp $R2 $R3 get Goto loop get: IntOp $R2 $R2 + 1 StrCpy $R0 $CMDLINE 1 $R2 StrCmp $R0 " " get StrCpy $R0 $CMDLINE "" $R2 Pop $R3 Pop $R2 Pop $R1 Exch $R0 ;MessageBox MB_OK|MB_ICONINFORMATION "survey $R0" FunctionEnd Function StrRep /*After this point: ------------------------------------------ $R0 = RepString (input) $R1 = SubString (input) $R2 = String (input) $R3 = RepStrLen (temp) $R4 = SubStrLen (temp) $R5 = StrLen (temp) $R6 = StartCharPos (temp) $R7 = TempStrL (temp) $R8 = TempStrR (temp)*/ ;Get input from user Exch $R0 Exch Exch $R1 Exch Exch 2 Exch $R2 Push $R3 Push $R4 Push $R5 Push $R6 Push $R7 Push $R8 ;Return "String" if "SubString" is "" ${IfThen} $R1 == "" ${|} Goto Done ${|} ;Get "RepString", "String" and "SubString" length StrLen $R3 $R0 StrLen $R4 $R1 StrLen $R5 $R2 ;Start "StartCharPos" counter StrCpy $R6 0 ;Loop until "SubString" is found or "String" reaches its end ${Do} ;Remove everything before and after the searched part ("TempStrL") StrCpy $R7 $R2 $R4 $R6 ;Compare "TempStrL" with "SubString" ${If} $R7 == $R1 ;Split "String" to replace the string wanted StrCpy $R7 $R2 $R6 ;TempStrL ;Calc: "StartCharPos" + "SubStrLen" = EndCharPos IntOp $R8 $R6 + $R4 StrCpy $R8 $R2 "" $R8 ;TempStrR ;Insert the new string between the two separated parts of "String" StrCpy $R2 $R7$R0$R8 ;Now calculate the new "StrLen" and "StartCharPos" StrLen $R5 $R2 IntOp $R6 $R6 + $R3 ${Continue} ${EndIf} ;If not "SubString", this could be "String" end ${IfThen} $R6 >= $R5 ${|} ${ExitDo} ${|} ;If not, continue the loop IntOp $R6 $R6 + 1 ${Loop} Done: ;Return output to user StrCpy $R0 $R2 /*After this point: ------------------------------------------ $R0 = ResultVar (output)*/ Pop $R8 Pop $R7 Pop $R6 Pop $R5 Pop $R4 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd |
how about attaching such a long script next time, or use pastebin
|
| All times are GMT. The time now is 04:41. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.