Adding TAB Stops
Posted: Thu May 01, 2014 2:33 pm
Hi,
I have created a LiveCode program which sends the result of a search to a text file which is saved in a location of the users choice.
Is it possible to add TabStops to the data placed into the text file so it appears neatly in columns when the saved text file is opened up?
My code is below and the 3rd last line shows what I am attempting to do. The data displays ok in the Output2 field but I want the data neatly displayed in a text file using tabStops. Not too sure if this is possible but any help would be gratefully appreciated.
Many thanks,
Steven
Global OutputContents, MyText, ArrayCountry, ArrayCapital, ArrayPopulation, Position
on mouseUp
initialise
write_file OutputContents, MyText, ArrayCountry, ArrayCapital, ArrayPopulation, Position
end mouseUp
on initialise
// Initialise the variables to null
Put "" into OutputContents
Put "" into MyText
end initialise
on write_file @OutputContents, @MyText, ArrayCountry, ArrayCapital, ArrayPopulation, Position
// Ask the user to choose a where they want to save their file
Ask file "Please choose a where you want to save the file: "
IF the result is not "cancel" THEN
Put it into MyText
END IF
// Put the search result of the output field into a block variable called OutputContents
Put "Country" & TAB & "Capital City" & TAB & "Population" into line 1 of OutputContents
Put ArrayCountry[position] & TAB & ArrayCapital[position] & TAB & ArrayPopulation[position] into line 2 of OutputContents
// Put the contents of the variable into the file variable MyText
Put OutputContents into URL ("file:" & MyText)
Set the tabStops of ("file:" & MyText) to 240
Answer "File Saved"
end write_file
I have created a LiveCode program which sends the result of a search to a text file which is saved in a location of the users choice.
Is it possible to add TabStops to the data placed into the text file so it appears neatly in columns when the saved text file is opened up?
My code is below and the 3rd last line shows what I am attempting to do. The data displays ok in the Output2 field but I want the data neatly displayed in a text file using tabStops. Not too sure if this is possible but any help would be gratefully appreciated.
Many thanks,
Steven
Global OutputContents, MyText, ArrayCountry, ArrayCapital, ArrayPopulation, Position
on mouseUp
initialise
write_file OutputContents, MyText, ArrayCountry, ArrayCapital, ArrayPopulation, Position
end mouseUp
on initialise
// Initialise the variables to null
Put "" into OutputContents
Put "" into MyText
end initialise
on write_file @OutputContents, @MyText, ArrayCountry, ArrayCapital, ArrayPopulation, Position
// Ask the user to choose a where they want to save their file
Ask file "Please choose a where you want to save the file: "
IF the result is not "cancel" THEN
Put it into MyText
END IF
// Put the search result of the output field into a block variable called OutputContents
Put "Country" & TAB & "Capital City" & TAB & "Population" into line 1 of OutputContents
Put ArrayCountry[position] & TAB & ArrayCapital[position] & TAB & ArrayPopulation[position] into line 2 of OutputContents
// Put the contents of the variable into the file variable MyText
Put OutputContents into URL ("file:" & MyText)
Set the tabStops of ("file:" & MyText) to 240
Answer "File Saved"
end write_file