Format a text line witch CR/LF

RogerRoger Member Posts: 57
I've got a dataport in order to export contact information. One of the export fields are a text field witch a length of 250

I put the complete contact information in this field, formatted by the FormatAddr.ContactAddr - Funktion.

No, I want to separate each element (name, address, city and so on) by a new line in order to put this field in a word mergefile as an addressblock. The address should be there in the right form.

I'm not able to use Interaction templates.

Is anybody here who can help me?

Many thanks
Roger
Many thanks, Roger

Comments

  • krikikriki Member, Moderator Posts: 9,115
    You can also use a codeunit, report,... for exporting this info, use type FILE.
    With this you can write line by line and they are automatically with CR/LF
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • RogerRoger Member Posts: 57
    Thank you for your answer, kriki

    But my problem is, that I have one line for each contact witch several export fields like amounts, description and so on.

    And the last field for a line is the contact information which is written in one field (text 250)

    I want to format the last field like this
    "name <newline> address <newline> city" and so on.

    Later, if the export file is merged by word, my textfield should be showed in word like this:

    name
    address
    city

    The new line after a complete line works well
    Many thanks, Roger
  • ta5ta5 Member Posts: 1,164
    Hi Roger
    Try this

    // CR and LF are of type character
    CR := 13;
    LF := 10;

    element := contact.name + Format(CR) + Format(LF)

    Regards
    Thomas
  • krikikriki Member, Moderator Posts: 9,115
    <newline> is used to divide the different records created in a dataport.
    Now you want also to use it internally in a field, so you will have something like:
    amount ; some other amount ; description ; yet another amount ; name <CRLF> adress <CRLF> <CRLF(created by the dataport because next record starts after this)>
    amount ; some other amount ; description ; yet another amount ; name <CRLF> adress <CRLF> <CRLF(created by the dataport because next record starts after this)>

    and so on.
    So the output will be (seen by Notepad)
    amount ; some other amount ; description ; yet another amount ; name
    adress

    amount ; some other amount ; description ; yet another amount ; name
    adress

    and so on.

    I think this creates some confusion for mailmerge.
    So I still think that the best method is still writing a file with the FILE-type, and this is what you get:
    amount
    some other amount
    description
    yet another amount
    name
    adress
    amount
    some other amount
    description
    yet another amount
    name
    adress
    and so on.
    Can't you put the address-fields together for merging?

    or you can check if merging uses a special character (Navision uses for exemple the backslash (=\) ) that it interpretes for a CRLF. In this case you can use that character in your big address-string.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • RogerRoger Member Posts: 57
    Hi Thomas

    Thank you for your help.

    But I tried this before I have posted my problme in forum.

    Word is not able to process an ascii-file with this characters in a datafield
    Many thanks, Roger
  • RogerRoger Member Posts: 57
    Thanks for all help

    It seems, there is no way to handle it.

    So, I have decided to use different fields, that works properly
    Many thanks, Roger
  • florynxflorynx Member Posts: 81
    but how can you build a file path for example 'c:\test.txt'?
  • krikikriki Member, Moderator Posts: 9,115
    florynx wrote:
    but how can you build a file path for example 'c:\test.txt'?
    What do you mean?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • florynxflorynx Member Posts: 81
    I have 2 text variables:
    Path := 'C:\';
    Filename := 'test.txt'

    When I try to concatenate'em I get:
    C:
    test.txt

    instead of C:\test.txt
    What I want is to avoid the "new line" meaning of the \ character.
  • SavatageSavatage Member Posts: 7,142
    I have a dataport I export with - and the Filename is a variable that can be entered in the Request Form

    For example

    OnPreDataport()
    CurrDataport.FILENAME('C:\'+YourFileName+'.txt.');

    Variable name is YourFileName type TEXT size 30

    That's if you don't want it set in stone.

    ----
    Also as I re-read this post - I am wondering..
    Are just simply trying to create a file that word can use to create merged documents?
  • krikikriki Member, Moderator Posts: 9,115
    florynx wrote:
    I have 2 text variables:
    Path := 'C:\';
    Filename := 'test.txt'

    When I try to concatenate'em I get:
    C:
    test.txt

    instead of C:\test.txt
    What I want is to avoid the "new line" meaning of the \ character.
    I suppose you see that if you do a MESSAGE(Path + Filename);
    If you do a MESSAGE('%1',Path + Filename); you will see "C:\test.txt".
    So the filename will be correct.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.