Success at last....getting my feet wet with Plua, with special thanks to Berkant

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Success at last....getting my feet wet with Plua, with special thanks to Berkant

jimmy joe jack
I think I mentioned in my first post that as a busy father of two who can't just jaunt away to the computer for hours, my only option to dabble in programming is generally at night, in bed, with my palm.

I'd tried other palm languages before (mainly PocketC, some izibasic), but as a guy starting from square one the going was tedious and I felt like I could do examples and stuff but I couldn't really just dream up a program (even a simple one) to do what I wanted to do. It was too complicated, I didn't have the patience, time...etc.

With Plua, and Berkant Atay's examples to get me started, I've actually made MY very first program that can actually do stuff. Even with the scant lua/plua documentation out there for total beginners, I made a tiny program: a checklist for college tasks that--get this--stores the status of where I placed checks on the list in a database and remembers where I placed the checks when I re-enter.

Revolutionary, I know. But I'm starting from absolutely nil, and with other languages it would have taken tons more code and patience on my part. For a guy in my weird situation this is about as good as at gets, and I just wanted to say thanks for the help and thanks to the Plua gods wherever they are.



Reply | Threaded
Open this post in threaded view
|

Re: Success at last....getting my feet wet with Plua, with special thanks to Berkant

Dado Sutter-2-2
Welcome to the never ending show of pLua :)
   Please share your code if you can.
   I might be able to offer to host a User's Wiki for pLua if you all think
this can be useful. It would be driven by
Sputnik<http://sputnik.freewisdom.org/>(100% Lua) and it might help to
concentrate pLua resources, code examples
and free aplications.
   I cannot guarantee to much time to maintain it though but the very nature
of a wiki should be the answer for this, if enough folks help.
   What is the best/main source of information, code examples and repo for
pLua today ?

Best of all
Dado Sutter



On Thu, Jul 2, 2009 at 18:41, jimmy joe jack <[hidden email]>wrote:

>
>
> I think I mentioned in my first post that as a busy father of two who can't
> just jaunt away to the computer for hours, my only option to dabble in
> programming is generally at night, in bed, with my palm.
>
> I'd tried other palm languages before (mainly PocketC, some izibasic), but
> as a guy starting from square one the going was tedious and I felt like I
> could do examples and stuff but I couldn't really just dream up a program
> (even a simple one) to do what I wanted to do. It was too complicated, I
> didn't have the patience, time...etc.
>
> With Plua, and Berkant Atay's examples to get me started, I've actually
> made MY very first program that can actually do stuff. Even with the scant
> lua/plua documentation out there for total beginners, I made a tiny program:
> a checklist for college tasks that--get this--stores the status of where I
> placed checks on the list in a database and remembers where I placed the
> checks when I re-enter.
>
> Revolutionary, I know. But I'm starting from absolutely nil, and with other
> languages it would have taken tons more code and patience on my part. For a
> guy in my weird situation this is about as good as at gets, and I just
> wanted to say thanks for the help and thanks to the Plua gods wherever they
> are.
>
>  
>


[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|

Re: Success at last....getting my feet wet with Plua, with special thanks to Berkant

jimmy joe jack
--- In [hidden email], Dado Sutter <dadosutter@...> wrote:

>
> Welcome to the never ending show of pLua :)
>    Please share your code if you can.
>    I might be able to offer to host a User's Wiki for pLua if you all think
> this can be useful. It would be driven by
> Sputnik<http://sputnik.freewisdom.org/>(100% Lua) and it might help to
> concentrate pLua resources, code examples
> and free aplications.
>    I cannot guarantee to much time to maintain it though but the very nature
> of a wiki should be the answer for this, if enough folks help.
>    What is the best/main source of information, code examples and repo for
> pLua today ?
>
> Best of all
> Dado Sutter
>
>
>
Below is the code, brutish though it is. Still has Berkant's comments in places, I just converted his example to palmdoc and tweaked it to make it do what I wanted. A user wiki would be great. There really isn't much out there for this language beyond the basic documentation...of nothing else a nice repository of examples would be nice.

-- **Retrieves previously written files **

savState={}
f,recs =io.open("db:/savState", "r")

-- note that arrays are indexed starting from 1!!!
-- but file recs index starts with 0 !


for i=0,recs-1 do
f:openrec(i)
data = f:read("*a")
table=bin.unpack("SBBB", data)
savState[1]=table[1]
savState[2]=table[2]
savState[3]=table[3]
savState[4]=table[4]
f:close()
end


screen.clear()
gui.title("College Checklist")
screen.moveto(0,40)
faCheck = gui.checkbox( "Financial Aid" )
screen.moveto(0,80)
claCheck=gui.checkbox("Classes Scheduled")
screen.moveto(0,120)
boCheck=gui.checkbox("Books Purchased")
screen.moveto(0,160)
woCheck=gui.checkbox("Work Schedule Fixed")
screen.moveto(150,280)
doneBut=gui.button("Done?")

gui.setstate(faCheck,savState[1])
gui.setstate(claCheck,savState[2])
gui.setstate(boCheck,savState[3])
gui.setstate(woCheck,savState[4])


function saveEnd()

faState=1
claState=2
boState=3
woState=4


savState = {}
savState[1]=gui.getstate(faCheck)
savState[2]=gui.getstate(claCheck)
savState[3]=gui.getstate(boCheck)
savState[4]=gui.getstate(woCheck)


os.remove("savState")

-- check for packing string format in Plua.doc

-- write to file in RAM

f=io.open("db:/savState", "r+")
data = bin.pack("SBBB", savState)
index = f:createrec(string.len(data))
f:openrec(index)
f:write(data)
f:close()
os.exit()
end

while true do
ev,id=gui.event()
if ev==appStop then break end
if ev==ctlSelect and id==doneBut then saveEnd()
end
end