Dotnet class to remove a tab character

jwilderjwilder Member Posts: 263
I can remove tab characters with normal NAV code by searching each character in a string. But I was thinking there might be a dotnet class to make this easier and faster. Can anyone point me in the right direction?

Answers

  • krikikriki Member, Moderator Posts: 9,115
    With Which:
    Which := 'X';
    Which[1] := 9;
    
    This should be fast enough
    NewString := DELCHR(String[, Where][, Which])
    
    No need for dotnet in this case.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • kylehardinkylehardin Member Posts: 257
    This snip of code uses DotNet to strip null characters - should be easy enough to change. It also has file handling, which may not be applicable.

    StripNulls(PassedFile : Text)
    IF NOT FSOFile.Exists(PassedFile) THEN
    ERROR(Text002, PassedFile);

    Null := 0;
    Space := 32;

    StreamReader := FSOFile.OpenRead(PassedFile);
    StringArray := FSOFile.ReadAllLines(PassedFile);
    StreamReader.Close();

    FOR X := 0 TO StringArray.Length() - 1 DO BEGIN
    DotNetString := StringArray.GetValue(X);
    DotNetString := DotNetString.Replace(Null, Space);
    StringArray.SetValue(DotNetString, X);
    END;

    FSOFile.WriteAllLines(PassedFile, StringArray);
    StreamReader.Close();
    StreamReader.Dispose();
    CLEAR(FSOFile);
    CLEAR(StringArray);

    Variables
    Name DataType Subtype Length
    FSOFile DotNet System.IO.File.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    DotNetString DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    StringArray DotNet System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    StreamReader DotNet System.IO.StreamReader.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    Null Char
    Space Char
    X Integer
    Kyle Hardin - ArcherPoint
Sign In or Register to comment.