Export window to .TXT file?

Is there a simple way to export the contents in a window to a basic .TXT file? For example, I have a window with 3 listboxes in it, which contain data. I want to just “dump” the data into a basic .TXT file when the user clicks a button. Any way to do this quickly and easily, with code or with a plugin?

Or if the data can be dumped to a .CSV, that would be ok too.

You can quickly get the contents of a listbox via Listbox1.Cell(-1,-1). That produces a string where the cells are separated by tabs and the rows are separated by end of line.

I was just about to psuedo code a much more awful solution. Neat tip! :slight_smile:

The reverse works as well to quickly load a listbox from a tab-delimited string.

Very neat, Tim! So how would I do this, popping up a box to enable a user to enter a file name and save it where they like (note that this will be a Windows app only)? A ‘Save As’ dialog box basically.


You can save the window name, title, location (l,r,w,h), data for all Control(s) in teh window, etc. in a text file.

Before doing that, you have to define the “text” file format (so when you will be at read time, you will be able to write the correct code).

You can use the return key (EndOfLine) character as object delimiter and use the Tab key as “field” (properties) delimiter and save the whole in a .txt file (TextOutputStream),
You can also use a BinaryStream and save the data in their native format (text as text, numbers as integer or so) etc.
Using a custom file extension,

At last, you can save the data as XML.

Feel free to ask for more hints, but do not forget to be more specific in what you do.

Afraid of sharing erroneous code ? Don’t be shy everybody makes mistakes ! I am not the last one (far from that).