Codeunit 8021 Text Management

Subscription Billing, Microsoft.SubscriptionBilling

src/Apps/W1/Subscription Billing/App/Base/Codeunits/TextManagement.Codeunit.al80 lines, Copyright (c) Microsoft Corporation. MIT

namespace Microsoft.SubscriptionBilling;using System.Reflection;using System.Utilities;codeunit 8021 "Text Management"{    var        ProcessingAbortedErr: Label 'Processing aborted.';    internal procedure GetProcessingAbortedErr(): Text    begin        exit(ProcessingAbortedErr);    end;    procedure AppendText(var ExistingText: Text; NewText: Text; Separator: Text)    begin        if NewText = '' then            exit;        if ExistingText = '' then            ExistingText := CopyStr(NewText, 1, MaxStrLen(ExistingText))        else            ExistingText += CopyStr(Separator + NewText, 1, MaxStrLen(ExistingText) - StrLen(ExistingText));    end;    procedure ReplaceInvalidFilterChar(var BaseText: Text)    begin        BaseText := ConvertStr(BaseText, '()<>=', '?????');    end;    procedure ShowFieldText(var RRef: RecordRef; FieldNo: Integer)    var        FRef: FieldRef;        BlobText: Text;        PageCaption: Text;    begin        PageCaption := RRef.Caption();        FRef := RRef.Field(FieldNo);        BlobText := ReadBlobText(RRef, FieldNo);        ShowTextViewer(BlobText, PageCaption);    end;    local procedure ShowTextViewer(Content: Text; PageCaption: Text): Boolean    var        TextEditor: Page "Text Viewer";    begin        TextEditor.SetPageCaption(PageCaption);        TextEditor.SetReadOnly(true);        TextEditor.SetContent(Content);        TextEditor.SetSize(100, 100);        TextEditor.SetAutoResize(true);        TextEditor.RunModal();    end;    internal procedure ReadBlobText(RecRef: RecordRef; FieldNo: Integer): Text    var        TempBlob: Codeunit "Temp Blob";        TypeHelper: Codeunit "Type Helper";        InStream: InStream;    begin        TempBlob.FromRecordRef(RecRef, FieldNo);        if not TempBlob.HasValue() then            exit;        TempBlob.CreateInStream(InStream, TextEncoding::UTF8);        exit(TypeHelper.ReadAsTextWithSeparator(InStream, TypeHelper.LFSeparator()));    end;    internal procedure WriteBlobText(var RRef: RecordRef; FieldNo: Integer; BlobText: Text)    var        TempBlob: Codeunit "Temp Blob";        OutStream: OutStream;    begin        TempBlob.CreateOutStream(OutStream, TextEncoding::UTF8);        OutStream.WriteText(BlobText);        TempBlob.ToRecordRef(RRef, FieldNo);    end;}