Hi all,
I have a field that I have set -up with "tabstops" to align the text in the field into columns. Works very well both on the screen and for appearance and when printing the field (named: printerschedule) contents they print in columns just as desired.
My problem is that when I save the contents of the field to a text file the columns do not stay aligned as viewed and printed.
[ask file "Save File:"
put the text of fld "printerschedule" into URL ("file:"&it) ][/code]
Any suggestions as to what is happening would be most appreciated.
Thanks, Ron
Saving the contents of field to a file?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 13
- Joined: Fri Oct 05, 2007 12:45 am
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
It's very simple: the text file contains the 'tab' characters, but not the width of the columns, and most text processors have heir own idea of how wide a column should be and where they're located.
The only way around this limitation, is to use a text format which has support for tables, so you should look into HTML or RTF. As a quick example for you to extend upon:
This isn't the end of the story, of course: you'll have to convert the 'tabStops' property into a row of table headers, setting the width attribute of each column.
The main advantage of html is that it's easy to learn the format (one good resource is W3Schools) and you can also export style information as well as unicode characters.
HTH,
Jan Schenkel.
The only way around this limitation, is to use a text format which has support for tables, so you should look into HTML or RTF. As a quick example for you to extend upon:
Code: Select all
on mouseUp
local theFilePath, theText
ask file "Save File as HTML:"
if the result is "Cancel" then exit mouseUp
put it into theFilePath
put the text of field "printerschedule" into theText
-- now let's convert theText into html before export to file
-- step 1: convert tab characters to end+start of a column
replace tab with "</td><td>" in theText
-- step 2: convert return characters to end+start of column and row
replace return with "</td></tr><tr><td>" in theText
-- step 3: put the necessary html tags around our table content
put "<html><body><table><tr><td>" before theText
put "</td></tr></table></body></html>" after theText
-- now export to file
put theText into URL ("file:" & theFilePath)
end mouseUp
The main advantage of html is that it's easy to learn the format (one good resource is W3Schools) and you can also export style information as well as unicode characters.
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com