How to write blankspace for n lenght in File

Kisu
Member Posts: 381
Which is the best way to insert n amount of blank space in text file
ex: 1234_____________5678 (where _ equals the blank space)
I tryed to make a simple loop that takes character and lenght as param and loops the file adding space
FOR i := 1 TO lenght DO BEGIN
Tiedosto.WRITE(char);
Tiedosto.SEEK(Tiedosto.POS-2); // so there will not be new line
END;
The textmode is TRUE..
The loop works fine like with character 0 zero but not with space.
Any help?
ex: 1234_____________5678 (where _ equals the blank space)
I tryed to make a simple loop that takes character and lenght as param and loops the file adding space
FOR i := 1 TO lenght DO BEGIN
Tiedosto.WRITE(char);
Tiedosto.SEEK(Tiedosto.POS-2); // so there will not be new line
END;
The textmode is TRUE..
The loop works fine like with character 0 zero but not with space.
Any help?
K.S.
0
Answers
-
Did you try PADSTR ?0
-
mohana_cse06 wrote:Did you try PADSTR ?
File datatype does not have padstr function?
And if I'd use it on text/code datatype it would not be good either, the space I'd need is around 200 to 400 characters and max variable size on nav was 250?K.S.0 -
Kisu wrote:And if I'd use it on text/code datatype it would not be good either, the space I'd need is around 200 to 400 characters and max variable size on nav was 250?
You can create a text with length 1024 also and while writing the text file, you can use PADSTR function for 200 to 400 characters also..
as per me, this is the best way to do.. :thumbsup:0 -
mohana_cse06 wrote:Kisu wrote:And if I'd use it on text/code datatype it would not be good either, the space I'd need is around 200 to 400 characters and max variable size on nav was 250?
You can create a text with length 1024 also and while writing the text file, you can use PADSTR function for 200 to 400 characters also..
as per me, this is the best way to do.. :thumbsup:
aaah, hmm that'd solve it then. I somehow recalled the text lenght gap was 250 #-o
cheers bud :thumbsup:K.S.0 -
If you create an outstream from your file and use it to write your text, a line ending is not written automatically after each text part. Instead you can write it on demand calling outstream.WRITETEXT() with an empty parameter list.
The length limit of a field in a table ist 250 CHARs, in old versions (e.g. 2.60) the limit for a variable of type text is 260 CHARs. In newer versions it is 1024 CHARs.
By concatenating text strings in the parameter of WRITE you can write more than 1024 characters at once, but limited by stack space, so I would not stretch this to the limit as in the sample code below. The following works in the RUN trigger of a codeunit in NAV2009: (By the way: here you see an alternative to the PADSTR approach... using FORMAT)f.TEXTMODE := TRUE; f.WRITEMODE := TRUE; f.QUERYREPLACE := FALSE; f.CREATE('C:\TEMP\Test.nav'); f.WRITE(FORMAT(' ',1024)+FORMAT(' ',1019)); f.CLOSE;
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