Position in ascii-file

ab
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.
MailText := RecOnderhoudsopdracht.Omschr;
LFil_Mail.WRITE(MailText);
I want Mailtext at pos 50 in the ascii-file.
0
Comments
-
How about
LFil_Mail.SEEK(50) ; LFil_Mail.WRITE(MailText);
(I'm assuming than LFil_Mail is of FILE type)
Regards,
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
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?0 -
I mean on the absolute position !0
-
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 300 -
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?0
-
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;0 -
ab wrote:I mean on the absolute position !ab wrote:write employee-num at pos 5, employee-name at pos 30, .... CRLF;
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 = 25PADSTR(txtemployeeno,maxstrlen(txtemployeeno),'[spacebar]');
0 -
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*0 -
It's not possible for you, to use a Dataport or xmlPort :?:Do you make it right, it works too!0
-
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 !0
-
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 money0 -
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.)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions