Roboblue
11-27-2006, 10:53 AM
Could someone please tell me why there is a space in the list box?
The table is being created from a folder of text files.
The pipe(|) is required as a separator in Xdialog popup list box.
Here is a pic of the list box. Note that there is a space between entries. These will cause an error when selected as there is no data there.
I have been fooling with this for hours, so I think I am just too close to it and am missing something simple.
tItems = File.Find("AutoPlay\\Docs\\txt\\recipes", "*", false, false, nil);
tText = {};
--do the following for each file:
for j,file_path in tItems do
tSplit = String.SplitPath(file_path);
sSplit = String.Concat(tSplit.Filename, "|");
Table.Insert(tText, Table.Count(tText) + 1, sSplit);
end
sItems = Table.Concat(tText, "|", 1, TABLE_ALL)
-- Show the listbox and pass it the list of items to display
Item = xDialog.Show_ListBox("Please choose an item", sItems, 325, 375)
-- If an item was selected, then add it to the input field.
if Item ~= "CANCEL" then
Input.SetText("Input1", Item)
tFile = File.Find(_SourceFolder.. "\\AutoPlay\\Docs\\txt\\recipes", ""..Item..".txt", false, false, nil, nil);
sFile = TextFile.ReadToString(tFile[1]);
Paragraph.SetText("Paragraph1", sFile);
end
The table is being created from a folder of text files.
The pipe(|) is required as a separator in Xdialog popup list box.
Here is a pic of the list box. Note that there is a space between entries. These will cause an error when selected as there is no data there.
I have been fooling with this for hours, so I think I am just too close to it and am missing something simple.
tItems = File.Find("AutoPlay\\Docs\\txt\\recipes", "*", false, false, nil);
tText = {};
--do the following for each file:
for j,file_path in tItems do
tSplit = String.SplitPath(file_path);
sSplit = String.Concat(tSplit.Filename, "|");
Table.Insert(tText, Table.Count(tText) + 1, sSplit);
end
sItems = Table.Concat(tText, "|", 1, TABLE_ALL)
-- Show the listbox and pass it the list of items to display
Item = xDialog.Show_ListBox("Please choose an item", sItems, 325, 375)
-- If an item was selected, then add it to the input field.
if Item ~= "CANCEL" then
Input.SetText("Input1", Item)
tFile = File.Find(_SourceFolder.. "\\AutoPlay\\Docs\\txt\\recipes", ""..Item..".txt", false, false, nil, nil);
sFile = TextFile.ReadToString(tFile[1]);
Paragraph.SetText("Paragraph1", sFile);
end