Here’s some programs I have that might help with coding or just look at code. The first one lists the names of classes and the tabs they’re in. It also shows the instance name used with a class. The second one lists variable names and other things used in a program and gives a count of how many times they were found. For starters, both programs read the project Cargo-Bot which contains a lot of tabs and classes and variables. Just change the project name for what you want to look at.
Show class names and instances.
Code removed. See modified code farther down.
Show names and the count.
function setup()
font("Courier")
textMode(CORNER)
project="Examples:Cargo-Bot"
tab={}
tab1={}
dy=0
process()
end
function process()
output.clear()
tab={}
tab1={}
dy=0
local str=""
local lp=listProjectTabs(project)
if #lp==0 then
print("Project not found.")
return
end
print("Reading the project list.")
for a,b in pairs(lp) do
print(b)
local rp=readProjectTab(project..":"..b)
str=str..rp
end
local str1=""
for z=1,string.len(str) do
local v=string.sub(str,z,z)
if v>="a" and v<="z" or v>="A" and v<="Z" then
per=0
str1=str1..v
elseif str1~="" and v=="_" then
per=0
str1=str1..v
elseif str1~="" and v=="." then
per=per+1
if per==2 then
per=0
str1=string.sub(str1,1,string.len(str1)-1)
if tab[str1]==nil then
tab[str1]=1
else
tab[str1]=tab[str1]+1
end
str1=""
else
str1=str1..v
end
elseif v>="0" and v<="9" then
per=0
str1=str1..v
elseif str1~="" and v=="'" then
per=0
str1=str1..v
elseif str1~="" then
per=0
local len=string.len(str1)
if string.sub(str1,len,len)=="." then
str1=string.sub(str1,1,len-1)
end
if string.sub(str1,len,len)=="'" then
str1=string.sub(str1,1,len-1)
end
if tab[str1]==nil then
tab[str1]=1
else
tab[str1]=tab[str1]+1
end
str1=""
else
str1=""
end
end
for a,b in pairs(tab) do
table.insert(tab1,a)
end
table.sort(tab1)
showKeyboard()
hideKeyboard()
end
function draw()
background(40,40,50)
fill(255)
text("Count Names "..#tab1,50,HEIGHT-50)
if #tab1>0 then
local st=math.floor(dy/20)+1
if st+45>=#tab1 then
st=#tab1-45
end
local en=st+45
for z=st,en do
local c=tab1[z]
text(string.format("%5d %-s",tab[c],c),50,dy+HEIGHT-70-z*20)
end
end
end
function touched(t)
if t.state==MOVING then
dy=dy+t.deltaY
if dy<0 then
dy=0
end
if dy/20>#tab1 then
dy=#tab1*20
end
end
end