![]() |
#1 |
Member
Join Date: Sep 2005
Location: Martinsicuro -Teramo- Italy
Posts: 76
|
![]()
Hello,
I have a 1500 lines text file with 300 lines with only the string "[n]" where n is a number that change from 0 to 299. Currently in the file there are 252 lines from [0] to [251] and now I would change the range from '[21]' to '[251]' into the range from '[69]' to '[299]', then to shift the numbers, within the line, by 48. I have written the following code but it does not work: ... Section ${LineFind} "input.txt" "output.txt" "1:-1" "Replace" SectionEnd Function Replace StrCpy $R0 251 ; begin item StrCpy $R1 21 ; end item StrCpy $R2 48 ; replacement offset ${ForEach} $R3 $R0 $R1 - 1 IntOp $1 $R3 + $R2 ${WordReplace} "$R9" $R3 $1 "" $R9 ${Next} Push $0 FunctionEnd ... Can you give me the right code (I think for the 'Replace' function') ? Massimo |
![]() |
![]() |
![]() |
#2 |
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
Could you describe exactly what doesn't work with your code and provide an example file showing the structure?
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
![]() |
![]() |
![]() |
#3 |
Member
Join Date: Sep 2005
Location: Martinsicuro -Teramo- Italy
Posts: 76
|
Hello, thanks for the reply
in the while I have found by myself the working code. It has simply a better definition for WordReplace; it is: ... Section ${LineFind} "input.txt" "output.txt" "1:-1" "Replace" SectionEnd Function Replace StrCpy $R0 251 ; begin item StrCpy $R1 21 ; end item StrCpy $R2 48 ; replacement offset ${ForEach} $R3 $R0 $R1 - 1 IntOp $1 $R3 + $R2 ${WordReplace} "$R9" "[$R3]" "[$1]" "+1" $R9 ${Next} Push $0 FunctionEnd Massimo |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|