I'm not an expert programmer and I have a little problem.
I have a file each row it's a text string of two types:
name or <name>
I want to remove brackets (< and > signs). See pseudocode:
Input:
<LOWERLAYERS>
<PLATFORM>
<USM>
<LOADFILES>
Output I expect:
LOWERLAYERS
PLATFORM
USM
LOADFILES
------
Case 1.
------
Code Sample |
while (...) // end of file ... GetLine (nvFileHandle, svLine); // remove (if any) the "<" and ">" i = j = 0; while i < StrLength(svLine) if ((svLine[i] != '<') && (svLine[i] != '>')) then svLineBis[j] = svLine[i]; j++; endif; i++; endwhile; WriteLine (nvFileHandle, szLineBis); endwhile; |
Output:
LOWERLAYERS
LOWERLAYERSPLATFORM
LOWERLAYERSPLATFORMUSM
LOWERLAYERSPLATFORMUSMLOADFILES
My Comment:
svLineBis string was not cleaned up and it write at the end of the previous writing.
------
Case 2. (I try to init the string but...)
------
Code Sample |
while (...) // end of file ... svLineBis = ""; // INIT GetLine (nvFileHandle, svLine); // remove (if any) the "<" and ">" i = j = 0; while i < StrLength(svLine) if ((svLine[i] != '<') && (svLine[i] != '>')) then svLineBis[j] = svLine[i]; j++; endif; i++; endwhile; WriteLine (nvFileHandle, szLineBis); endwhile; |
Output:
LOWERLAYERS
My Comment:
Where are the other lines?
------
Case 3. another way...
------
Code Sample |
while (...) // end of file ... GetLine (nvFileHandle, svLine); // remove (if any) the "<" and ">", another way... CopyBytes (svLineBis, 0, svLine, 1, (StrLength(svLine)-2)); WriteLine (nvFileHandle, szLineBis); endwhile; |
Output:
LOWERLAYERS
PLATFORMERS
USMTFORMERS
LOADFILESRS
My Comment:
svLineBis string was not cleaned up
------
Case 4. another way with the same string initi
------
Code Sample |
while (...) // end of file ... svLineBis = ""; // INIT GetLine (nvFileHandle, svLine); // remove (if any) the "<" and ">", another way... CopyBytes (svLineBis, 0, svLine, 1, (StrLength(svLine)-2)); WriteLine (nvFileHandle, szLineBis); endwhile; |
Output:
LOWERLAYERS
PLATFORMERS
USMTFORMERS
LOADFILESRS
My Comment:
the same...
Conclusion
I guess all my problems are I'm not understand the right way to init a string.
Anyone can help me?
Thanks.
Ciao, Giuseppe