I had an issue to process a csv file with TAB delimited text lines. The existing code expected text lines with ; as delimiter.
Character TAB has ASCII Code 9.
So i wrote following code:
ConvertTabString(line : Text[250]) : Text[250]ch := 9; // of type Charline := CONVERTSTR(line,FORMAT(ch),';');exit(line);
test code:
// set a line value or load the line from a text file using file.openline := 'ab cd ef cd'; line := ConvertTabString(line);MESSAGE(line);result: 'ab;cd;ef;cd'
an interesting thing is, that this code does not work for older nav 2009 builds. maybe a problem with the encoding. for that case i developed a second version.
// text file test.txt contains 1 text line 'ab cd ef cd'. with TAB as delimiter.// file : FILE// instr : InStreamfile.OPEN('c:\temp\test.txt');file.CREATEINSTREAM(instr);instr.readtext(line,maxstrlen(line));line := CONVERTSTR(line,FORMAT(ch),';');message(line);file.close;
This can also be used to export the converted lines to a new text file, which can then be imported via dataport/xmlport.
cheers