|
|
(One intermediate revision by one other user not shown) |
Line 1: |
Line 1: |
| {|align=right
| | #REDIRECT [[StrTrimNewLines]] |
| |<small>Author: [[{{ns:2}}:sunjammer|sunjammer]] ([[{{ns:3}}:sunjammer|talk]], [[{{ns:-1}}:Contributions/sunjammer|contrib]])</small>
| |
| |}
| |
| <br style="clear:both;">
| |
| == Description ==
| |
| This function trims out the last "$\r$\n" characters of a string.
| |
| | |
| == The Function ==
| |
| <highlight-nsis>
| |
| ; TrimNewlines
| |
| ; input, top of stack (e.g. whatever$\r$\n)
| |
| ; output, top of stack (replaces, with e.g. whatever)
| |
| ; modifies no other variables.
| |
| | |
| Function TrimNewlines
| |
| Exch $R0
| |
| Push $R1
| |
| Push $R2
| |
| StrCpy $R1 0
| |
| | |
| loop:
| |
| IntOp $R1 $R1 - 1
| |
| StrCpy $R2 $R0 1 $R1
| |
| StrCmp $R2 "$\r" loop
| |
| StrCmp $R2 "$\n" loop
| |
|
| |
| IntOp $R1 $R1 + 1
| |
| IntCmp $R1 0 no_trim_needed
| |
| StrCpy $R0 $R0 $R1
| |
| | |
| no_trim_needed:
| |
| Pop $R2
| |
| Pop $R1
| |
| Exch $R0
| |
| FunctionEnd
| |
| </highlight-nsis>
| |
| | |
| [[{{ns:14}}:String Functions]]
| |