Question 1 of 2 related to looping files in a directory

One Star

Question 1 of 2 related to looping files in a directory

Since I'm supposed to separate questions into multiple threads, here's the first one:
I put a tFileList, followed by an iterate link to a tFilePositional. The obvious intention is to loop the files in a directory and then for each file do something.
I typed <<e:\>> (without << and >>) as the directory in the tFileList, but this caused havoc in the Perl code. So I put single quotes around it: <<'e:\'>>. Perl, like C and Java, uses the backslash as an escape character, so I doubled it: <<'e:\\'>>. Now I examine the code and see that it will append anyway the forward slash and give me for example <<e:\/order_20020901.txt>> instead of <<e:\order_20020901.txt>>. The question is then, does Talend expect only forward slashes in paths?
Michael
Tags (1)

Accepted Solutions
One Star

Re: Question 1 of 2 related to looping files in a directory

A suggestion for how to deal with the quoting issue is to have a 3-valued property as a checkbox for each node: checked, clear, or greyed where checked means advanced Perl allowed, clear means no advanced Perl allowed and greyed means use the default. Then add a default as a 2-state property in the global preferences. Have a Perl escape and unescape code written in the Java and callable from code generation. When passing from no advanced Perl to allowing advanced Perl, add escape characters to all the characters such as backspaces and quotes that can confuse the Perl code and put quotes around the string. When doing the inverse, try to reverse this operation and if not possible, allow the user to tab through those that pose problems by highlighting them in red or something.

All Replies
One Star

Re: Question 1 of 2 related to looping files in a directory

A suggestion for how to deal with the quoting issue is to have a 3-valued property as a checkbox for each node: checked, clear, or greyed where checked means advanced Perl allowed, clear means no advanced Perl allowed and greyed means use the default. Then add a default as a 2-state property in the global preferences. Have a Perl escape and unescape code written in the Java and callable from code generation. When passing from no advanced Perl to allowing advanced Perl, add escape characters to all the characters such as backspaces and quotes that can confuse the Perl code and put quotes around the string. When doing the inverse, try to reverse this operation and if not possible, allow the user to tab through those that pose problems by highlighting them in red or something.