Position in ascii-file

abab Member Posts: 37
How can you specify that a string (definied as a code of 10 positions) will always be at position 50 when writing to a ascii-file ? Thanks


MailText := RecOnderhoudsopdracht.Omschr;
LFil_Mail.WRITE(MailText);

I want Mailtext at pos 50 in the ascii-file.

Comments

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    How about
    LFil_Mail.SEEK(50) ;
    LFil_Mail.WRITE(MailText); 
    
    (I'm assuming than LFil_Mail is of FILE type)

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • kinekine Member Posts: 12,562
    ab wrote:
    How can you specify that a string (definied as a code of 10 positions) will always be at position 50 when writing to a ascii-file ? Thanks


    MailText := RecOnderhoudsopdracht.Omschr;
    LFil_Mail.WRITE(MailText);

    I want Mailtext at pos 50 in the ascii-file.

    Do you mean on the line or on the absolute position?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • abab Member Posts: 37
    I mean on the absolute position !
  • abab Member Posts: 37
    SEEK works fine ! But how do you do that with several fields at a different position on the same line in an ascii-file ?

    text1 at pos 5
    text2 at pos 20
    text3 at pos 30
  • XypherXypher Member Posts: 297
    Perhaps there is a better solution to accomplish what you would like to do... what is the situation you are currently having where you require to write/read text at an exact location in a file?
  • abab Member Posts: 37
    I have some data that I want to write to an ascii-file !


    LFil_Mail.TEXTMODE := TRUE;
    LFil_Mail.WRITEMODE := TRUE;
    LFil_Mail.CREATE(file);
    if employee.find('-') then begin
    repeat

    write employee-num at pos 5, employee-name at pos 30, .... CRLF;

    until employee.next = 0;
    end;
    LFil_Mail.CLOSE;
  • BeliasBelias Member Posts: 2,998
    edited 2008-05-20
    ab wrote:
    I mean on the absolute position !
    ab wrote:
    write employee-num at pos 5, employee-name at pos 30, .... CRLF;
    in this case you only need the in line position...

    BTW, you can use a dataport with fixed format fields or you can also use padstr function with blank spaces and text variables as long as you need
    e.g. employee no. with maxlen = 25
    PADSTR(txtemployeeno,maxstrlen(txtemployeeno),'[spacebar]');
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • XypherXypher Member Posts: 297
    ab wrote:
    I have some data that I want to write to an ascii-file !

    I understand you have something you would write to a file. I was just curious as to why.

    You need the correct spacing because of a strict program import policy or just for the visual effect?

    If the latter then why not use CSV format, open the resultant document in Excel, and cut your time consumption in half by formatting it there?

    *shrug* :|
  • garakgarak Member Posts: 3,263
    It's not possible for you, to use a Dataport or xmlPort :?:
    Do you make it right, it works too!
  • abab Member Posts: 37
    No, it's not possible. I need to make an ascii-file that I want to put into the pickup-directory of the exchange-server !!! I think it is the most easy way to sent an email within Navision !
  • colingbradleycolingbradley Member Posts: 162
    This snip example shows how to add any number of fields into a text record with all fields starting in the desired place.


    BlanketText := 'H1 ' +
    rFormatText("No.",18) + ///PO_No
    PADSTR(' ',2) +
    rFormatText('R1',4) + ///PO_No_Ex
    PADSTR(' ',2) +
    FORMAT("Order Date",0,'<Day,2>/<Month,2>/<Year,2>') + ///PO_Date
    PADSTR(' ',2) +
    rFormatText("No.",24) + ///Ref_no
    PADSTR(' ',2) +
    rFormatText("Ship-to Name",30) + ///USE_Name

    rFormatText(TxtString : Text[100];TxtLen : Integer) PadText : Text[100]
    TxtLen1 := STRLEN(TxtString);
    TxtVal1 := TxtLen - TxtLen1;
    IF TxtVal1 < 0 THEN TxtVal1 := 0;
    PadText := TxtString + PADSTR(' ',TxtVal1);
    Experience is what you get when you hoped to get money
  • XypherXypher Member Posts: 297
    ab wrote:
    ... into the pickup-directory of the exchange-server !!! ...

    That's some information we could've used to help you with your situation.

    You are aware Pickup Directory message files can be of MIME content right? Which would allow you to use HTML to create tables (and make all the data in the message(s) aligned and pretty like you want.) :D
Sign In or Register to comment.