Page 1 of 1
File Class, XML?
Posted: Fri Aug 07, 2009 2:35 pm
by ConvertFromOldNGs
by desmond >> Mon, 10 Dec 2001 2:37:30 GMT
I've dowloaded the JADEInterfaces.pdf recently, according to this document, you can use the File class to export data in any standard flat file format: e.g CSV, XML, and so on. Then I check out the File class in the help file, but I can not find any word about this. Does any one knows how to do it?
BTW, I've wrote some methods similar to that, but I am wondering how's Jade going to do that, so I don't need to write my lengthy coding.
Thanks in advance
Desmond Shen
DotShell Japan
Re: File Class, XML?
Posted: Fri Aug 07, 2009 2:35 pm
by ConvertFromOldNGs
by pillick >> Sun, 3 Feb 2002 23:16:08 GMT
Ummm, what do you need to know? All you do is treat it as if you are writing to an ordinary text file, except you use a different extension and you use the usual conventions for that type of file.
For example, a csv file is like a table where each row is a seperate line, and each column is seperated by commas. So all you do to create a csv file is create a file with ".csv" on the end of it and start writing data into it a line at a time.
Heres a method I wrote that outputs the contents of a table into a csv file:
saveTable(table:Table ; caption:String);
vars
table2 : Table ;
saveDialog : CMDFileSave ;
fileName, line: String ;
file : File ;
pos : Integer ;
rows, columns : Integer ;
begin
table2 := table ;
create saveDialog ;
saveDialog.dialogTitle := caption ;
saveDialog.filter := "CSV File|*.csv|" ;
if saveDialog.open = 0 then
fileName := saveDialog.fileName ;
pos := 1 ;
fileName.scanUntil(".", pos) ;
if pos = 0 then
fileName := fileName & ".csv" ;
endif ;
create file ;
file.openOutput(fileName) ;
rows := 0 ;
while rows < table.rows do
rows := rows + 1 ;
columns := 0 ;
line := null ;
while columns < table.columns do
columns := columns + 1 ;
line := line & table2.accessCell(rows, columns).text & "," ;
endwhile ;
file.writeLine(line) ;
endwhile
file.close ;
endif ;
end;
Re: File Class, XML?
Posted: Fri Aug 07, 2009 2:35 pm
by ConvertFromOldNGs
by CarlRanson >> Mon, 4 Feb 2002 1:35:13 GMT
Sounds like you've gotten the idea that Jade provides specific support for those file types.
It doesn't. That doesn't stop you from writing them yourself of course.
eg.
vars
file : File;begin
create file;
file.openOutput('c:\myFile.xml');
file.writeln('<xml>This is valid xml</xml>');
delete file;
end;
If you're looking for a tool that helps you deal with xml easily, we have some products that may be of interest.
Carl Ranson
Unify Limited.