Thursday, June 5, 2014

Read a Text File

// Read a Text File

static void ReadDateFromTxtFile(Args _args)
{
    #File
    TextIo                  io;
    container               c;
    str               itm, name;
    ;
    io = new TextIo("U:\\Test.txt", #io_read);
    if (!io)
    {
        throw error("Error reading file");
    }
    io.inFieldDelimiter(','); //This can be any delimiter, I'm just using Semicolon as an example
    io.inRecordDelimiter(#delimiterCRLF); //CRLF = Carriage Return Line Feed
    ttsbegin;
    while (io.status() == IO_Status::Ok)
    {
        c = io.read();
        if (io.status() != IO_Status::Ok)
        {
            break;
        }
        itm = conpeek(c, 1);
        name=  conpeek(c, 2);
        info(itm + '-->' + name);
    }
    ttscommit;
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...