Following on from a previous post last week where I talked about exporting data from a Listbox in Xojo / REALStudio, I decided to build a general purpose export routine with the extra features that were commented on and also some extra features that I believe make this routine even more useful.
Note: This is not the only way of programming a generic export function and no doubt it is not the best. It does however work and work well.
This export routine is a single simple function and is accessed by sending a string of parameters and having the results of the export request returned as an Integer containing different values depending on the success or what kind of failure occurred.
The parameters that are required by the function are:
- Delimiter (Comma, Tab (chr(9)), Full Stop etc.)
- Headings (YES or NO)
- Name of the Source Listbox
- Filename Extension (Tab, Csv etc.)
- Default Filename (Export.txt)
- Surround with Quotes (YES or NO)
A call to this export routine would therefore look something like this:
For ease of reading and maintainability this is better:
The actual export function itself looks like this:
Note: There is a small error in the picture of the export function above. This error has been fixed in the Text download. Thanks to Axel Schneider on the Xojo Forums for pointing this out.
To download the export function as text, please click here
- DataViewer SQL Components for Xojo / Realstudio Developers
- oneSQL SQLite and MySQL Query Tool for Windows and Mac