PDA

View Full Version : Need Help -.-


mustafa06
06-08-2009, 11:38 AM
tbData = TextFile.ReadToTable("C:\\1.txt");---İn Text File > Line 1 : "255 255 255"
strData = String.Replace(tbData[1], " ", ",", false);
RGB = Math.RGBToNumber(strData); -- [ X,X,X But how i can edit tbData for convert the string X,X,X and working normaly ]

Help please... :o

ShadowUK
06-08-2009, 02:16 PM
tbData = TextFile.ReadToTable("C:\\1.txt");---İn Text File > Line 1 : "255 255 255"
strData = String.Replace(tbData[1], " ", ",", false);
RGB = Math.RGBToNumber(strData); -- [ X,X,X But how i can edit tbData for convert the string X,X,X and working normaly ]

Help please... :o

Not tested, Wrote it in here.

local InputString = TextFile.ReadToString("C:\\1.txt");
local Seperator = " ";

local DelimitedTable = {};
local Position = 0;

while (true) do
CurrentPosition = string.find(InputString, Seperator, Position, true);

if (CurrentPosition ~= nil) then
table.insert(DelimitedTable, string.sub(InputString, Position, CurrentPosition - 1));
Position = CurrentPosition + 1;
else
table.insert(DelimitedTable, string.sub(InputString, Position));
break;
end
end

R = DelimitedTable[1];
G = DelimitedTable[2];
B = DelimitedTable[3];

Math.RGBToNumber(R, G, B);

mustafa06
06-09-2009, 02:37 AM
thx working ;) :yes