get function for chart holding list of db objects

2013-09-26 Thread Olaf Hamann
wrote this yesterday night - but was too tired to spell the address right, so here it is again.

--
Hi,

Im getting stuck - any hints are appreciated!

While I finally found out how to connect a +Chart component to a form
so that values are shown (Chart Put Function),
I do not get the clue how to bring changed values back (Chart Get Function).

I think Im in trouble with differentiating between gui components connected
to vars/db objects and gui charts holding db objects and being connected to
gui components.

Ive looked up the code in @app/ord.l etc and I studied on and on the chapters
in the tutorial concerning gui Charts and E/R Field Prefix Classes,
but I was not able to bring that together.

(class +Foo +Entity)
(rel keyA (+Ref +Number) 2)
(rel keyB (+Ref +String))

(dm keyA () (: keyA) )
(dm keyB () (: keyB) )

(de getFooObjs ( Floor Ceil )
(solve ( @F Floor
@C Ceil
(db keyA (@F . @C) @FooObj) )
@FooObj) )

== ({234}{3224]{6342})

(app)
(action
(html 
(form NIL
(gui (+Init +Chart) (getFooObjs 5 100) 3
((FooObj) (list (keyA FooObj) (keyB FooObj) FooObj)) # put function
# no clue about get function
)
(table NIL NIL ((NIL KeyA)(NIL KeyB)(NIL FooObj))
(do 4
(row NIL
(gui 1 (+Lock +NumField) 10)
(gui 2 (+Lock +TextField) 10)
(gui 3 (+Lock +TextField) 8)
## (gui (+DelRowButton) DEL)
) ) ) # table closed
(gui (+UpButton) 1)
(gui (+DnButton) 1)
()
(submit Save)
) #form
) #html
) #action


This works for me, means: i can scroll through the records,
but want to change the values too.

1.) I wonder, if +Chart should be +E/R prefixed to the FooObjs
instead of using getFooObjs.
But how to do that?

2.) How could the Chart Get Function look like?
(sure +Locks will be deleted, when that function works)

3.) Or should the gui components be +E/R prefixed too,
but when is (: home obj) set and what arguments needs (gui +Chart then

4.) I only want to save 1 row at a time (or perhaps delete)
So I think, that submit will be thrown away (as it saves all records)
and a Save-Button will be added to the list of the row elements?

Or do I have to produce one form for each row?



Coding the insert form for one row at a time was done in a minute in the morning,

hack:
(form NIL
(gui a (+NumField) 10)
(gui b (+TextField) 20)
(gui (+Button) Insert Record
( (new! (+Foo)
keyA (val (: home a))
keyB (val (: home b)) ) )
]

but now I think, this is not picolispish (= does not benefit of the pl qualities)
and could also be done with +Chart and E/R Prefix Class?

As Regenaxer told this morning: as soon as there is activity needed, you need a form and then a +Chart .


With kind regards,
and thank you very much in advance,

Olaf






-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: get function for chart holding list of db objects

2013-09-26 Thread Alexander Burger
Hi Olaf,

you are quite close, I think.

The 'keyA' relation has a small problem

 (class +Foo +Entity)
 (rel keyA (+Ref +Number) 2)
 (rel keyB (+Ref +String))

'+Ref' takes an optional argument, and '2' should be for '+Number',
so correct would be

   (rel keyA (+Ref +Number) NIL 2)


Then, instead of using Pilog

 (solve '( @F Floor
 @C Ceil
 (db keyA (@F . @C) @FooObj) )
 @FooObj) )

you could also simply (collect 'keyA '+Foo) to get a list of
all objects.

Note, however, that both 'solve' and 'collect' are not so wise if the
database has many '+Foo' objects, because they return _all_ objects and
thus the chart may become huge.

For displaying a possibly infinite number of objects in a chart, it is
better to use '+QueryChart' which displays just the first page of hits
and then lets you scroll down as far as you like. Examples for
+QueryChart can be found in doc/family.l and app/gui.l.


Besides this, your approach

 (gui '(+Init +Chart) (getFooObjs 5 100) 3

is not bad or wrong at all. However, the '+Lock' prefixes in

   (gui 1 '(+Lock +NumField) 10)

make the fields non-editable.

Thus,I would try something like

   (gui '(+Init +Chart) (collect 'keyA '+Foo) 2
  '((This) (list (: keyA) (: keyB)))
  '((L D)
 (when D
(put! D 'keyA (car L))
(put! D 'keyB (cadr L))
D ) ) )
   (table NIL NIL
  '((NIL KeyA) (NIL KeyB))
 (do 8
(row NIL
   (gui 1 '(+NumField) 10)
   (gui 2 '(+TextField) 10) ) ) )
   (scroll 8 T)

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Some initial questions

2013-09-26 Thread Joe Bogner
Hi Luis,

I've built a proof of concept PicoLisp apk and ran it on a Droid X and my
kindle fire. I wrote about it here:
http://www.mail-archive.com/picolisp@software-lab.de/msg03114.html

I was able to build the entire apk using terminal ide on my android (no
android SDK).

I'm happy to answer any questions about it. I didn't take it any farther
than this.  I don't know if it would pass Play Store policy or not.

Joe






On Thu, Sep 26, 2013 at 7:15 PM, Luis P. Mendes luisl...@gmail.com wrote:

 Thank you all for your messages!

 Henrik:
 It's good to know that database speed is compared to major RDBMs.
 PicoLisp having an integrated database is a big plus for the language.

 Alex:
 Thank you for providing the community such a powerful language that
 for sure has many many hours of hard work.
 As you say, the ones that come to PicoLisp are the ones who do the
 effort to find a programming language.
 As everything else in life, either people are satisfied with
 propaganda that others try to push, or people choose to find their own
 ways. I'm glad I'm between people who have the latter attitude.

 Enough of philosophy, I'll just ask you something more, since my
 searches in google were not conclusive.
 I've seen this:
 http://picolisp.com/5000/!wiki?AndroidWebServer
 and
 http://www.mail-archive.com/picolisp@software-lab.de/msg03081.html [-]
 Will .apk android applications be supported by PicoLisp in the future?

 Olaf:
 Nice to hear that you're also starting with PicoLisp.
 As recommended in the PicoLisp Reference, I'll start reading the book
 Lisp by Winston/Horn.

 Thorsten and Joe:
 Thank you for the links!


 Now it's time to start learning!


 Luis
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe