View Full Version : how can i do a loop from 000 to 666
i need to do a loop from 000 to 666 (example)
000 001 002 003 004 005 006 010 011 012 013 014 015 016 020 021 022 023 024 025 026 ..... 666
and put the number to text file.
i need help
Imagine Programming
06-05-2009, 09:08 AM
Use a for loop, the AMS helpfile gives you lots of info about loops. There's also the repeat and while loop.
for(i=1, 666)do
TextFile.WriteFromString(_SourceFolder.."\\loop.txt", tostring(i).."\r\n", true);
end
i dont wont the numbers 7,8 and 9 i need to write to a txt file all the numbers from 000 to 666 but not the numbers with 7,8 or 9 like the example.
000 001 002 003 004 005 006 010 011 012 013 014 015 016 020 021 022 023 024 025 026 ..... 666
and i need it in 3 numbes (example 0 is 000 and 1 is 001)
reteset
06-05-2009, 09:25 AM
for i=0, 666 do
if (i < 10) then
nTemp = "00"..i;
elseif (i < 100) then
nTemp = "0"..i;
else
nTemp = i;
end
TextFile.WriteFromString("C:\\Test.txt", nTemp.."\r\n", true);
end
i dont wont numbers like
108
109
599
619
i dont wont number who include the numbers 7,8 or 9;
thank you for the help
reteset
06-05-2009, 10:15 AM
did you try my sample code ..?
it does what exactly you wanted in your first post
but if you changed your mind or want a different thing
just tell us what is it
also i understood nothing from these words
you should elaborate more to get help
i dont wont numbers like
108
109
599
619
i dont wont number who include the numbers 7,8 or 9;
thank you for the help
holtgrewe
06-05-2009, 10:18 AM
i need to do a loop from 000 to 666 (example)
000 001 002 003 004 005 006 010 011 012 013 014 015 016 020 021 022 023 024 025 026 ..... 666
and put the number to text file.
i need help
googling we find: http://www.purplemath.com/modules/numbbase2.htm
Using the formula for converting decimal to base 7 numbers you should be able develop a function to write your text numbers...
hth
Imagine Programming
06-05-2009, 10:37 AM
for i=0, 666 do
local LastNum = tonumber(String.Right(tostring(i), 1));
local s = "";
if(LastNum~=7)and(LastNum~=8)and(LastNum~=9)then
if(i<10)then
s = "00"..i;
elseif(i<100)then
s = "0"..i;
else
s = tostring(i);
end
TextFile.WriteFromString(_SourceFolder.."\\numbers.txt", s.."\r\n", true);
end
end
for count1 = 0, 6 do
for count2 = 0, 6 do
for count3 = 0, 6 do
TextFile.WriteFromString("c:\\numbers.txt", count1 .. count2 .. count3 .. "\r\n", true);
end
end
end
thank you for the help :)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.