LiveCode LessonsHow To - Step-By-Step Guides To Tasks In LiveCode TextHow do I Display Tab Delimited Text in a Table Field?

How do I Display Tab Delimited Text in a Table Field?

This lesson will show you how to display tab delimited text in a Revolution table field.

What We Will Work With

What We Will Work With

On the left is a stack window with a button for selecting a text file (1) and a field for displaying the text file (2).

On the right is a file (3) containing two columns of data. The left column is the name of a cheese (4) and the right column is a year (5). The two columns are separated by the TAB character (6).

The Button Script

The Button Script

The button script is pretty straight forward. It simply prompts the user for a file, loads the file contents into a variable and then assigns the variable to the text property of the field.

==========

Copy & Paste

==========

on mouseUp

answer file "Select text file"

if the result is not "cancel" then

put it into theFilePath

put URL ("file:" & theFilePath) into theTabDelimitedText

set the text of field "MyText" to theTabDelimitedText

end if

end mouseUp

The Result

The Result

Selecting a file displays the text as seen above. Notice that both columns of data are displayed but the data is not separated into separate columns visually.

The tabStops Property

The tabStops Property

In a field table columns are defined by the presence of the TAB character in the text. You can control the spacing of columns by adjusting the tabStops property. Select the field (1) and open the Table pane of the property inspector (2). Notice that the Tab stops field is empty (3).

Enter 200 into the Tab stops field and press the Return or Enter key. Now the 2nd column is indented 200 pixels from the left of the field.

0 Comments

Add your comment

E-Mail me when someone replies to this comment