View Full Version : text to table
aramos
04-18-2006, 11:08 PM
hello. how can i make a string eg
128;129;258;685;
into a table
i am trying to make APMS reat a txt file generated by PHP but i am getting the follwing caracters when APMS downloads the file from my server 㔲㘲㔲㔲㔲㔲㔲㔲 instead of the numbers that i see whern i open the same txt file via the explorer. can someone tell me why this is happening. i made the download mode in APMS binary_mode and text_mode and it happends on both. can someone tell me why this is happening
aramos
04-18-2006, 11:15 PM
a foot note. the caracters show when the text file is created via php. if i create it with front page or manually everything works fine..
azmanar
04-19-2006, 12:38 AM
hello. how can i make a string eg
128;129;258;685;
into a table
Aramos,
Make your table and assign values like below:
tMyTable = {128,129,258,685};
or like this below:
tMyTable = {};
tMyTable[1] = 128;
tMyTable[2] = 129;
tMyTable[3] = 258;
tMyTable[4] = 685;
In the above, the table is named tMyTable. The small "t" indicates it is a table and differentiates with other variables.
So if you want to insert values into a table like that from anywhere such as a Text File, you use this : tMyTable = Text.ReadToTable ();
This example takes a Text File that has several lines of data, and each line ONE data only. Then it will assign each line to a ListBox.
-- Read the contents of a text file to a table.
tContents = TextFile.ReadToTable("AutoPlay\\Docs\\test1.txt");
nRow =Table.Count(tContents);
-- Add item to ListBox
if tContents then
for i,sValue in tContents do
sText = sValue;
sData = sValue;
ListBox.AddItem("ListBox1", sText, sData);
end
else
Dialog.Message("Notice", "NOTHING IN TEXT FILE", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
As you can see in the above, each readable variable value in sValue can be assigned to any new variables for use for any objects in your AMS page.
Try it. Hope this is useful.
azmanar
04-19-2006, 02:46 AM
Sorry missed something in the function. Should be:
tMyTable = TextFile.ReadToTable();
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.