How can I erase CRLF characters and export to .TXT

ILMEILME Member Posts: 23
Hello, I've been trying to export some fields through a dataport to a .TXT file.
On the OnBeforeExportRecord trigger of the Dataport I want to clean
my text fields from CR & LF characters that are attached to the end of the Code fields.

So I have tried all these:
c --> char = 13

1) "Dimension Value".Code:= DELCHR("Dimension Value".Code, '=', FORMAT(c));

2) Adding two Backspace [char=8] characters to the end of the "Dimension Value".Code

3) "Dimension Value".Code:=COPYSTR("Dimension Value".Code, 1, STRLEN("Dimension Value".Code)-2);

When I run the Dataport to export data in a .TXT file, the green processing bar gets stuck permanently and does not finally export the data.

Has anybody managed to export data cleaned from CRLF characters?

Any help would be highly appreciated.
* IF NOT done THEN REPEAT UNTIL done *

Answers

  • BernardJBernardJ Member Posts: 57
    Try the OnAfterFormatField trigger (hit F9 on a dataport field in the Field designer)
  • ufukufuk Member Posts: 514
    Following code should work:
    cr := 13 ;
    lf := 10 ;
    FieldToClean := DELCHR(FieldToClean,'=',FORMAT(cr)) ;
    FieldToClean:= DELCHR(FieldToClean,'=',FORMAT(lf)) ;
    

    IF not, there may be another problems and you may require debugging.
    Ufuk Asci
    Pargesoft
  • ILMEILME Member Posts: 23
    @BernardJ:
    unfortunately, putting the altering DELCHR code in the OnAfterFormatField doesn't do the job, because it exports the data unchanged (with CRLF characters in it)

    @ufuk:
    Yes, that's what I was doing but it couldn't export the file.

    ************
    Finally I solved it!
    For a mysterious reason that I cannot understand,
    I've put a VARIABLE instead of the field and IT WORKED!

    So, I put:
    variable_code:= DELCHR("Dimension Value".Code, '=', FORMAT(c));

    and exported THE VARIABLE instead of the "Dimension Value".Code FIELD

    If anyone has any idea why it works properly with a variable and not with the field
    I'd be glad to know!

    Thanx
    * IF NOT done THEN REPEAT UNTIL done *
  • ufukufuk Member Posts: 514
    It also works with fields not only variables. If you want to modify a value in primary key fields you should use Rename function. This may be the reason.
    Ufuk Asci
    Pargesoft
  • ILMEILME Member Posts: 23
    ufuk wrote:
    It also works with fields not only variables. If you want to modify a value in primary key fields you should use Rename function. This may be the reason.

    what you said was so correct and helpful!
    Thank you very much
    * IF NOT done THEN REPEAT UNTIL done *
Sign In or Register to comment.