Old 16th October 2006, 22:36   #1
Maxim30
Member
 
Maxim30's Avatar
 
Join Date: Sep 2005
Location: Martinsicuro -Teramo- Italy
Posts: 76
Question Line replacement with number shifting

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
Maxim30 is offline   Reply With Quote
Old 24th October 2006, 20:58   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
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
kichik is offline   Reply With Quote
Old 25th October 2006, 21:57   #3
Maxim30
Member
 
Maxim30's Avatar
 
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
Maxim30 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