Xojo Generic Listbox Export: Tab, CSV and JSON

The following piece of code is written in the Xojo language (highly recommended by the way) and is a method that takes two Parameters, a List Object, and a Descriptive Type which is a String that can only be one of the following values:

  1. “,” – Comma, Standard Comma Separated CSV
  2. “;” – Semicolon, AlternativeĀ CSV
  3. chr(9) – Tab Character, Tab Delimited
  4. “JSON” – JSON Structure

Click Here to Download Code

GenericListBoxExport

The contents of your specified ListBox will the be output in your chosen format šŸ™‚

Xojo Building Blocks from chol.technologyLooking for an App creating for your Windows or Mac Computer? What about an App for your iOS or Android Tablet or Phone, or A Web App? Bespoke, Custom, High Quality Applications.Ā ContactĀ Us

Listbox Exporting: Take 2

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:

  1. Delimiter (Comma, Tab (chr(9)), Full Stop etc.)
  2. Headings (YES or NO)
  3. Name of the Source Listbox
  4. Filename Extension (Tab, Csv etc.)
  5. Default Filename (Export.txt)
  6. Surround with Quotes (YES or NO)

A call to this export routine would therefore look something like this:

www.stevencholerton.com

For ease of reading and maintainability this is better:

www.stevencholerton.com

The actual export function itself looks like this:

www.stevencholerton.com

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

blog_footer.png

Products
Affiliate Links