How to write blankspace for n lenght in File

KisuKisu 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?
K.S.

Answers

  • KisuKisu Member Posts: 381
    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.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    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:
  • KisuKisu Member Posts: 381
    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.
  • vaprogvaprog Member Posts: 1,139
    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;
    
Sign In or Register to comment.