Does anyone have an example of how to build a checkbook like table? I want to create a budget & checkbook app (I created one using MS Access for my PC but want to create something on my iPad) but when I look up ‘table’ in Codea or Lua I get information on data variables instead. Do I have to draw a rectangle and add lines to acheive this?
Yes, in the draw function
Then you could always just use Excel…
Some time ago I wrote something like that as an addon to the Cider UI, I am not sure it made it to the final version, aciolino mightknow. If you lookup the Cider discussion you will find it.
Sorry to have to ask - can you shoot me a simple sample of building out my checkbook form?
Date Check# Desc Amount
There is a free app, “iSpreadsheet free” that works pretty good. It would work for what you want. Maybe you can use that and see what it does as an example of what you can write.
It’s here
http://twolivesleft.com/Codea/Talk/discussion/1693/cider-interface-builder-code-generator/p2
.@consultdavidw If you want an example of building a grid, I think the built-in example Spritely does that. Have you checked it out? I’m building a grid-based app too, and I’m planning to use Spritely’s code as a reference.
Here’s an example if you want a start. You can change the cell width and height. You can change the number of cell rows and columns. You can scroll the grid up, down, left, or right, but you can’t scroll left of the 1st column or higher than the top row. You can double tap a cell to select it. I’ll leave the rest up to you. The screen orientation is in portrait, so the green lines mark the left column and the top row.
displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)
function setup()
w=100 --cell width
h=50 --cell height
cw=14 --number of cell columns
ch=28 --number of cell rows
xm=0
ym=HEIGHT-ch*h
selected=false
end
function draw()
background(40, 40, 50)
createGrid()
end
function touched(t)
if t.state==BEGAN and t.tapCount==2 then
cx=math.ceil((t.x-xm)/w)
cy=math.ceil((ch*h-t.y+ym)/h)
rx=(cx-1)*w
ry=ch*h-cy*h
selected=true
elseif t.state==MOVING then
xm=xm+t.deltaX
if xm>0 then
xm=0
end
ym=ym+t.deltaY
if ym<HEIGHT-ch*h then
ym=HEIGHT-ch*h
end
end
end
function createGrid()
translate(xm,ym)
strokeWidth(2)
for x=0,cw do
stroke(255)
if x==0 then
stroke(0,255,0)
end
line(x*w,0,x*w,ch*h)
end
for y=0,ch do
stroke(255)
if y==ch then
stroke(0,255,0)
end
line(0,y*h,cw*w,y*h)
end
if selected then
fill(150,150,150)
stroke(255)
rect(rx,ry,w,h)
end
end
Just to give an idea of how a checkbook in Cider might start out…
-- Generated by Cider
--
-- Add CiderControls as a dependency
--
displayMode(FULLSCREEN)
function setup()
control1001 = Control('', 20, 660, 740, 960, test_Clicked)
control1001.background = color(135, 202, 147, 255)
label1003 = Label('Check', -20, 900, 100, 930, test_Clicked) label1003.fontSize = 24
txtPayee = TextBox('Text Box', 40, 820, 560, 850, test_Clicked)
txtAmount = TextBox('Text Box', 580, 820, 710, 850, test_Clicked)
label1006 = Label('To', -20, 840, 100, 870, test_Clicked)
label1007 = Label('Amount', 520, 840, 640, 870, test_Clicked)
lblTextAmount = Label('Amount', -20, 760, 100, 790, test_Clicked)
txtCheckNumber = TextBox('Number', 580, 900, 710, 930, test_Clicked)
button1011 = TextButton('< Previous', 440, 720, 570, 760, test_Clicked)
button1012 = TextButton('Next >', 580, 720, 710, 760, test_Clicked)
end
function draw()
background(194, 194, 194, 255)
control1001:draw()
label1003:draw()
txtPayee:draw()
txtAmount:draw()
label1006:draw()
label1007:draw()
lblTextAmount:draw()
txtCheckNumber:draw()
button1011:draw()
button1012:draw()
end
function touched(touch)
control1001:touched(touch)
label1003:touched(touch)
txtPayee:touched(touch)
txtAmount:touched(touch)
label1006:touched(touch)
label1007:touched(touch)
lblTextAmount:touched(touch)
txtCheckNumber:touched(touch)
button1011:touched(touch)
button1012:touched(touch)
end
function keyboard(key)
if CCActiveTextBox then
CCActiveTextBox:acceptKey(key)
end
end
Thanks!
I’ve written some code in Codea to login with OAuth to google docs and read/write data to a spreadsheet. Tell me if you need it and I will find it for you.