![]() |
#1 |
Member
Join Date: Nov 2015
Posts: 96
|
![]()
Hi everyone
![]() ive been experimenting with blank/break line control, the goal is to parse a file prior to editing to assure consistent spacing between data blocks, the data blocks are just some text instructions in segments separated by a line break or sometimes two or more, i want create a unified 2 line break between each block, i thought a simple search and replace for "$\r$\n" replacing with "$\r$\n$\r$\n" and than passing again replacing "$\r$\n$\r$\n$\r$\n" with "$\r$\n$\r$\n" should do the trick; but as i found out i was wrong ![]() any suggestion how i should go about it? TIA Chris |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,181
|
Are you editing in-place or from one file to another?
I would do it in one pass, add if needed and ignore if too many when writing to the other file. IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#3 |
Member
Join Date: Nov 2015
Posts: 96
|
Thank you Anders <3
yes i am appending in place, im currently having a hard time capturing the pattern of two line breaks, atm my attempts only add never subtract ![]() ATB Chris |
![]() |
![]() |
![]() |
#4 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,181
|
I would recommend that you write to a temp file instead, in-place editing is much harder.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#5 |
Member
Join Date: Nov 2015
Posts: 96
|
![]()
Thank you Anders <3
ATB Chris |
![]() |
![]() |
![]() |
#6 |
Member
Join Date: Nov 2015
Posts: 96
|
even from one file to another still no go
![]() i can only replace a single line but not two, as soon as the second line comes to play the it cant be found, when only capturing a single line; this basically closes all gaps, any advice? TIA Chris |
![]() |
![]() |
![]() |
#7 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,181
|
Are you keeping a count of empty lines in your loop? And reset the count when you hit a non-empty line?
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#8 |
Member
Join Date: Nov 2015
Posts: 96
|
![]()
i am not; this is my last attempt which delete all spaces,
PHP Code:
ATB Chris |
![]() |
![]() |
![]() |
#9 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,181
|
PHP Code:
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#10 |
Member
Join Date: Nov 2015
Posts: 96
|
Thank you Anders <3
it doesn't seem to like the first loop ${If}, i changed to !If and it moved on to not liking the next ${AndIf} Edit: adding !include LogicLib.nsh fixed the stop above, trying to figure out why its now stopping here ExecShellWait "" "test.txt" ATB Chris |
![]() |
![]() |
![]() |
#11 |
Member
Join Date: Nov 2015
Posts: 96
|
![]()
YaY \ o / its working
i bow to your expertise Master <3 TIA Chris Last edited by MyPC8MyBrain; 4th August 2018 at 00:00. |
![]() |
![]() |
![]() |
#12 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,181
|
This only works in recent NSIS v3.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#13 |
Member
Join Date: Nov 2015
Posts: 96
|
![]()
adding both
PHP Code:
PHP Code:
PHP Code:
i ended with commenting out last two lines as the last deletes our file and the one before kept giving me error, something about "this file has no handle" or something, PHP Code:
Chris |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|