My Story + Small Request

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

My Story + Small Request

jimmy joe jack
Okay. So, I'm the father of two kids and I don't have a lot of time to sit on the computer and devote to programming. I do most of what I can, as far as dabbling in programming goes, with my Palm in bed (after the kids go down).

Basically, I have to pick up programming on my palm. It's not the most convenient method for sure, but I think Plua is the right language for it. I've worked previously on Pocket C, and made a little progress with it....but it was somewhat of a nightmare to use on a Palm.

So, I just wanted to know a few things to help me to start digging into the language. I've been trying to dig through texts and stuff but haven't got a clear answer on a few things, so I was wondering if you guys could do a very simple example source code for me. It doesn't have to be the most efficient/clever, better in fact to just be plain and simple.

A program that:

1. Has a graphical button that says "Surprise!" (through alert, whatever) when pressed.
2. Creates a database with, say, a few names in it: Mr. Jones, Mr. Smith, and Mr. Grey. Then have it call up those names or do something with them. Whatever.
3. A menu button/drop-down that exits the program.


This should be pretty easy for you Plua badasses, and would help me to get an idea about this simple stuff that I don't feel like digging through the limited (and mostly not so good) instructionals to learn. This small example would be greatly appreciated, and I promise I would leave you alone and work on it for a while before I bring up more stuff.  


Reply | Threaded
Open this post in threaded view
|

PLua Documentation

Gerbrand G
Hi,

The link at http://netpage.em.com.br/mmand/pluadoc.htm seams to be broken.

Getting "404 Not Found".

Kind Regards,

Lennie De Villiers


     

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

Reply | Threaded
Open this post in threaded view
|

Re: My Story + Small Request

Berkant Atay
In reply to this post by jimmy joe jack

I just don't have the time now to write down all the code you've wanted to see, but I guess this will help a little..
 
screen.moveto(5,100)
buttonhello=gui.button("Press me!)
 
while true do
ev,id=gui.event()
if ev==appStop then break end
if ev==ctlSelect and id==buttonhello then screen.clear() screen moveto(150,150) print ("Surprise...!!") end
 
end
 

--- On Wed, 6/10/09, jimmy joe jack <[hidden email]> wrote:


From: jimmy joe jack <[hidden email]>
Subject: [plua] My Story + Small Request
To: [hidden email]
Date: Wednesday, June 10, 2009, 6:08 AM








Okay. So, I'm the father of two kids and I don't have a lot of time to sit on the computer and devote to programming. I do most of what I can, as far as dabbling in programming goes, with my Palm in bed (after the kids go down).

Basically, I have to pick up programming on my palm. It's not the most convenient method for sure, but I think Plua is the right language for it. I've worked previously on Pocket C, and made a little progress with it....but it was somewhat of a nightmare to use on a Palm.

So, I just wanted to know a few things to help me to start digging into the language. I've been trying to dig through texts and stuff but haven't got a clear answer on a few things, so I was wondering if you guys could do a very simple example source code for me. It doesn't have to be the most efficient/clever, better in fact to just be plain and simple.

A program that:

1. Has a graphical button that says "Surprise!" (through
 alert, whatever) when pressed.
2. Creates a database with, say, a few names in it: Mr. Jones, Mr. Smith, and Mr. Grey. Then have it call up those names or do something with them. Whatever.
3. A menu button/drop- down that exits the program.

This should be pretty easy for you Plua badasses, and would help me to get an idea about this simple stuff that I don't feel like digging through the limited (and mostly not so good) instructionals to learn. This small example would be greatly appreciated, and I promise I would leave you alone and work on it for a while before I bring up more stuff.















Reply | Threaded
Open this post in threaded view
|

Re: PLua Documentation

Berkant Atay
In reply to this post by Gerbrand G
You can find detailed information on Plua and Lua in various formats in the Files\Documentation folder of this yahoo group.




From: Gerbrand G <[hidden email]>
Subject: [plua] PLua Documentation
To: [hidden email]
Date: Wednesday, June 10, 2009, 10:31 AM








Hi,

The link at http://netpage. em.com.br/ mmand/pluadoc. htm seams to be broken.

Getting "404 Not Found".

Kind Regards,

Lennie De Villiers

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
















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

Reply | Threaded
Open this post in threaded view
|

Re: PLua Documentation

Helton Eduardo Ritter
if you want plua 2.0 docs is here

http://meusite.uai.com.br/~mmand/plua/plua.htm




2009/6/10 Berkant Atay <[hidden email]>

>
>
> You can find detailed information on Plua and Lua in various formats in the
> Files\Documentation folder of this yahoo group.
>
> From: Gerbrand G <[hidden email] <ggerbrand%40yahoo.com>>
> Subject: [plua] PLua Documentation
> To: [hidden email] <plua%40yahoogroups.com>
> Date: Wednesday, June 10, 2009, 10:31 AM
>
>
> Hi,
>
> The link at http://netpage. em.com.br/ mmand/pluadoc. htm seams to be
> broken.
>
> Getting "404 Not Found".
>
> Kind Regards,
>
> Lennie De Villiers
>
> [Non-text portions of this message have been removed]
>
> [Non-text portions of this message have been removed]
>
>  
>



--
--
Helton Eduardo Ritter
www.sourcedreams.com.br
www.phpmagazine.org.br
livehelton.blogspot.com
vonluawelt.blogspot.com
includec.blogspot.com
foojava.blogspot.com
www.setrem.com.br,

"If you want to make your dreams come true, the first thing you have to do
is wake up."(J. M. Power)

"Die Grenzen meiner Sprache bedeuten die Grenzen meiner Welt"(Ludwig
Wittgenstein)


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

Reply | Threaded
Open this post in threaded view
|

Re: My Story + Small Request

jimmy joe jack
In reply to this post by Berkant Atay
--- In [hidden email], berkant_atay@... wrote:

>
>
> I just don't have the time now to write down all the code you've wanted to see, but I guess this will help a little..
>  
> screen.moveto(5,100)
> buttonhello=gui.button("Press me!)
>  
> while true do
> ev,id=gui.event()
> if ev==appStop then break end
> if ev==ctlSelect and id==buttonhello then screen.clear() screen moveto(150,150) print ("Surprise...!!") end
>  
> end
>  
>
> --- On Wed, 6/10/09, jimmy joe jack <wildcard_seven@...> wrote:
>
>
> From: jimmy joe jack <wildcard_seven@...>
> Subject: [plua] My Story + Small Request
> To: [hidden email]
> Date: Wednesday, June 10, 2009, 6:08 AM
>
>
>
Thanks a lot for that. That saves me time trying to mine answers out of documentation sorely lacking in beginner Plua examples. (the little beginner tutorial pdf has a similar example, but it's not 2.0 and it goes about it in a slightly different way...so I just wanted to be sure).

If you or anyone else can do that little database example I requested in my original post, that'd be awesome, too. Thanks again.

Reply | Threaded
Open this post in threaded view
|

Re: My Story + Small Request

Berkant Atay
In reply to this post by Berkant Atay
Now I have the time to help you more.

In these examples, I first demonstrate the exit button. The second one shows how to create and write something on an SD card file, then read it, and then create a stream file (Palm internal memory file), and writing records on it, kind of database demo... The second program chunk retrieves what the first program has put in the stream file. However, you have to refer to Plua.doc for details about files, records, and tables.

1. FIRST THE EXIT BUTTON:  **********************

screen.moveto(100,100)
buttonexit=gui.button("Quit")
while true do
ev,id=gui.event()
if ev==appStop then break end
if ev==ctlSelect and id==buttonexit then os.exit() end
end

*************************************************

2. NOW SOME FILE OPERATIONS: ********************

-- ** Writes to VFS and stream files  **
-- First, you can save items in a VFS file. Remember your SD card is vfs0, ie "vfs zero"..!


print() print() print("Writing and reading to a VFS file")
os.remove("vfs0:/PALM/Launcher/myfile.who")
f=io.open("vfs0:/PALM/Launcher/myfile.who", "w")
a=math.p --just a numeric example..
f:write("pencil","ruler")
f:write("compass",a)
f:close()
f=io.open("vfs0:/PALM/Launcher/myfile.who","r")
s=f:read()
print(s)
f:close()
os.remove("vfs0:/PALM/Launcher/myfile.who") --we don't need this file anymore..
print() print("Press any key...")
gui.event() --this makes the OS wait for any event

-- Creating and putting records in a stream file

print("...now writing records to a RAM file...")
name=1 age=2 gender=3 value=4
person={}
for n=1,3 do person[n]={} end  -- we defined a matrix with two dimensions

person[1][name]="BERKANT"
person[1][age]=41
person[1][gender]=1
person[1][value]=100

person[2][name]="TUBA"
person[2][age]=36
person[2][gender]=0
person[2][value]=90

person[3][name]="YIGIT"
person[3][age]=9
person[3][gender]=1
person[3][value]=80  -- you can find other ways to enter these data..

-- first remove the existing file

os.remove("person")

-- check for packing string format in Plua.doc

-- write to file in RAM

f=io.open("db:/person", "r+")
for i=1,3 do
data = bin.pack("SBBB", person[i])
index = f:createrec(string.len(data))
f:openrec(index)
f:write(data)
end
f:close()

print("Finished writing to file.")
print("Press Home key to quit...")
gui.main() -- this waits for the "home" key


*************************************************************

3. NOW, THIS FILE READS WHAT THE ABOVE CODE HAS WRITTEN: ****


-- **Retrieves previously written files **

person={}
f,recs =io.open("db:/person", "r")
for i=1,recs do
person[i]={}
end

name=1
age=2
gender=3
value=4

-- 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)
person[i+1][name]=table[1]
person[i+1][age]=table[2]
person[i+1][gender]=table[3]
person[i+1][value]=table[4]
end
f:close()

for i=1,recs do
print(person[i][name])
print(person[i][age])
print(person[i][gender])
print(person[i][value])
end

gui.main()

*********************************************************************

Hope you are progressing fast...

Reply | Threaded
Open this post in threaded view
|

Re: My Story + Small Request

jimmy joe jack
--- In [hidden email], "Berkant Atay" <berkant_atay@...> wrote:

>
> Now I have the time to help you more.
>
> In these examples, I first demonstrate the exit button. The second one shows how to create and write something on an SD card file, then read it, and then create a stream file (Palm internal memory file), and writing records on it, kind of database demo... The second program chunk retrieves what the first program has put in the stream file. However, you have to refer to Plua.doc for details about files, records, and tables.
>
> 1. FIRST THE EXIT BUTTON:  **********************
>
> screen.moveto(100,100)
> buttonexit=gui.button("Quit")
> while true do
> ev,id=gui.event()
> if ev==appStop then break end
> if ev==ctlSelect and id==buttonexit then os.exit() end
> end
>
> *************************************************
>
> 2. NOW SOME FILE OPERATIONS: ********************
>
> -- ** Writes to VFS and stream files  **
> -- First, you can save items in a VFS file. Remember your SD card is vfs0, ie "vfs zero"..!
>
>
> print() print() print("Writing and reading to a VFS file")
> os.remove("vfs0:/PALM/Launcher/myfile.who")
> f=io.open("vfs0:/PALM/Launcher/myfile.who", "w")
> a=math.p --just a numeric example..
> f:write("pencil","ruler")
> f:write("compass",a)
> f:close()
> f=io.open("vfs0:/PALM/Launcher/myfile.who","r")
> s=f:read()
> print(s)
> f:close()
> os.remove("vfs0:/PALM/Launcher/myfile.who") --we don't need this file anymore..
> print() print("Press any key...")
> gui.event() --this makes the OS wait for any event
>
> -- Creating and putting records in a stream file
>
> print("...now writing records to a RAM file...")
> name=1 age=2 gender=3 value=4
> person={}
> for n=1,3 do person[n]={} end  -- we defined a matrix with two dimensions
>
> person[1][name]="BERKANT"
> person[1][age]=41
> person[1][gender]=1
> person[1][value]=100
>
> person[2][name]="TUBA"
> person[2][age]=36
> person[2][gender]=0
> person[2][value]=90
>
> person[3][name]="YIGIT"
> person[3][age]=9
> person[3][gender]=1
> person[3][value]=80  -- you can find other ways to enter these data..
>
> -- first remove the existing file
>
> os.remove("person")
>
> -- check for packing string format in Plua.doc
>
> -- write to file in RAM
>
> f=io.open("db:/person", "r+")
> for i=1,3 do
> data = bin.pack("SBBB", person[i])
> index = f:createrec(string.len(data))
> f:openrec(index)
> f:write(data)
> end
> f:close()
>
> print("Finished writing to file.")
> print("Press Home key to quit...")
> gui.main() -- this waits for the "home" key
>
>
> *************************************************************
>
> 3. NOW, THIS FILE READS WHAT THE ABOVE CODE HAS WRITTEN: ****
>
>
> -- **Retrieves previously written files **
>
> person={}
> f,recs =io.open("db:/person", "r")
> for i=1,recs do
> person[i]={}
> end
>
> name=1
> age=2
> gender=3
> value=4
>
> -- 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)
> person[i+1][name]=table[1]
> person[i+1][age]=table[2]
> person[i+1][gender]=table[3]
> person[i+1][value]=table[4]
> end
> f:close()
>
> for i=1,recs do
> print(person[i][name])
> print(person[i][age])
> print(person[i][gender])
> print(person[i][value])
> end
>
> gui.main()
>
> *********************************************************************
>
> Hope you are progressing fast...
>

Thanks one more time for this. It really helps to look at stuff that has ONLY the stuff I'm trying to work on and not a bunch of extra clutter I don't need. Straight and to the point. Much appreciated.