Fixed File Format

dohertyk
dohertyk Member Posts: 94
I've got all the data I need now to great my Trade File and it's all in there, but I am supposed to be writting the file usings a fixed field format.

So...
at Position 3 Cust Num
at Position 21 Cust Name
at Position 50 Cust Phone
at Position 100 Past Due Balances

certainly I have several things between, all of these fields. And I am sure it would probably have been easier has a DataPort.. (which it was), And I am sure it's easier as a tab delimited file, or a comma seperated file.

But Alas, those would all be too easy.. and thus too easy to allow me to write it out that way. Instead I need to put everything into columns.

StartPos & Width are used for DataPorts.
and I couldn't find a way of maybe placing text at specific points into a different text variable and then writing that to the file.

If you have any tips or tricks.. Let me know, it would be very much appreciated.

Thanks in advance,

Kevin

Answers

  • Savatage
    Savatage Member Posts: 7,142
    Next time you should specify all your requirments right from the start.

    First it was about getting to current/30/60/90
    then it was about a dataport
    then about using the aging report
    to outstreaming to a txt file and now
    fixed lengths.
    :D:D:D

    Look at PADSTR in the c/side help
    PADSTR

    Use this function to change the length of a string to a length you define. The system does this by either truncating the string or adding filler characters at the end of the string.

    NewString := PADSTR(String, Length [, FillCharacter])

    Good Luck!
  • dohertyk
    dohertyk Member Posts: 94
    Savatage wrote:
    Next time you should specify all your requirments right from the start.

    First it was about getting to current/30/60/90
    then it was about a dataport
    then about using the aging report
    to outstreaming to a txt file and now
    fixed lengths.
    :D:D:D

    Look at PADSTR in the c/side help
    PADSTR

    Use this function to change the length of a string to a length you define. The system does this by either truncating the string or adding filler characters at the end of the string.

    NewString := PADSTR(String, Length [, FillCharacter])

    Good Luck!

    Thanks Savatage, but is there not an easier way? I had looked at PadStr, it's what I used to put the zero's infront of the numbers. I was kind of hoping for something that would look a little cleaner.

    Is there a way of specifying a " " (space) character as the FillCharacter?
  • Savatage
    Savatage Member Posts: 7,142
    I did a little test & it works

    desc := PADSTR(Description, 30 ,' ');
    desc2 := PADSTR("Description 2", 30 ,' ');
    desc3 := desc+' '+desc2;

    Then I printed out desc3 on a report and it was 61 characters

    30 + 30 + the space = 61

    use the:single quote-space-single quote