Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Newbie question about string replace (http://forums.winamp.com/showthread.php?t=287179)

oliverbob 19th February 2008 04:43

Newbie question about string replace
 
Hello world,

I wanted to replace the back slashes with forward slashes of this string:

H:\dir1\dir2\dir3\myProgram\index.html

So that the output should look like this:

H:/dir1/dir2/dir3/myProgram/index.html

How do I do this? Can somebody share their experties in this? I would appreciate some example code.

oliverbob 19th February 2008 06:33

Here is the code I have as a follow up of the previous post.

___________________________________

; Java Launcher
;--------------

Name "Java Launcher"
Caption "Java Launcher"
Icon "modern-install.ico"
OutFile "Java Launcher.exe"

SilentInstall silent
AutoCloseWindow true
ShowInstDetails nevershow

!define CLASSPATH ".;lib;lib\HyperLink.jar"
!define CLASS "demo.Demo"

Section ""
Call GetJRE
Pop $R0

; change for your purpose (-jar etc.)
StrCpy $0 '"$R0" -classpath "${CLASSPATH}" ${CLASS}'

SetOutPath $EXEDIR
Exec $0
SectionEnd

Function GetJRE
;
; Find JRE (javaw.exe)
; 1 - in .\jre directory (JRE Installed with application)
; 2 - in JAVA_HOME environment variable
; 3 - in the registry
; 4 - assume javaw.exe in current dir or PATH

Push $R0
Push $R1

ClearErrors
StrCpy $R0 "$EXEDIR\jre\bin\javaw.exe"
IfFileExists $R0 JreFound
StrCpy $R0 ""

ClearErrors
ReadEnvStr $R0 "JAVA_HOME"
StrCpy $R0 "$R0\bin\javaw.exe"
IfErrors 0 JreFound

ClearErrors
ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1" "JavaHome"
StrCpy $R0 "$R0\bin\javaw.exe"

IfErrors 0 JreFound
StrCpy $R0 "javaw.exe"

JreFound:
Pop $R1
Exch $R0

FileOpen $9 Init.properties w ;Opens a Empty File and fills it
FileWrite $9 "$EXEDIR/index.html" ;--what I wanted to replace by changing the "\" occurences with "/"
; current output is: H:\dir\dir\dir/index.html

FileClose $9 ;Closes the filled file

FunctionEnd
_______________________________________


Please help me.

Mr Inches 19th February 2008 08:03

Hi

Here is an example script using the StrFunc header (included as part of an NSIS install):

code:

Name "Replace String Test"

ShowInstDetails Show

OutFile 'ReplaceTest.exe'

!include "StrFunc.nsh"

; 'Declare' functions used in StrFunc.nsh
${StrRep}

Section "-Main"

StrCpy $R0 "C:\TEMP\FOLDER"
${StrRep} $R1 $R0 "\" "/"
DetailPrint "$R0 -> $R1"

SectionEnd




Duncan

oliverbob 19th February 2008 08:58

That was so helpful Duncan

Thanks a lot for your kindness to help.

I have tried the code, and it is so helpful and I just discover the benifit of using HM NIS Edit.

This evening I will explore and study about NSIS with it.
This two tools are entirely useful with my Java Projects.

Once again thank you very much.


Bob


All times are GMT. The time now is 17:55.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.