Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Problem with Trim Function (http://forums.winamp.com/showthread.php?t=210495)

Jnuw 15th March 2005 18:18

Problem with Trim Function
 
Hello all.

I'm trying to trim a variable call $Output, that contains a string, that ends with a bunch of \r\n commands like this: "Bla bla bla \r\n \r\n \r\n \r\n \r\n "

Depending on the conditions, there may be lots of these \r\n commands. The $Output variable is being sent into a Text box control within a custom page, that’s why I have to use the \r\n instead of $\r$\n.

I have tried adding the below lines (;added) to the Trim function (both TrimRight and TrimLeft parts) from the archive, but it did not help.

Loop2:
StrCpy $R2 "$R1" 1 -1
StrCmp "$R2" " " TrimRight
StrCmp "$R2" "$\r" TrimRight
StrCmp "$R2" "$\n" TrimRight
StrCmp "$R2" "\r" TrimRight ;added
StrCmp "$R2" "\n" TrimRight ;added
StrCmp "$R2" " " TrimRight ; this is a tab
GoTo Done

Any thoughts would be appreciated. Thanks!

kichik 15th March 2005 18:43

The trimming functions you've tried to modify check one character at a time. You can use StrIOToNSIS to convert to a normal NSIS string and then use TrimNewLines, or you can use StrRep. Both functions are available in StrFunc.nsh. See Examples\StrFunc.nsi for examples.

Jnuw 15th March 2005 19:19

Thanks much kichik. I added the following, and i'm all set.

${StrRep} $0 "$Output" "\r\n" "$\r$\n"
Push $0
Call Trim
Pop $0
${StrRep} $1 $0 "$\r$\n" "\r\n"
StrCpy $Output $1


All times are GMT. The time now is 05:06.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.