Thank you for your prompt and helpful reply Alex.  The *JS trick worked
great and the proper date calculation will be most helpful.  If I may ask a
few more questions:

You're right, storing the age is silly when already storing DOB.  How might
I just calculate age on the fly and display it in the following (gui ...)
or similar?

(<grid> 6
   ...
   "Birthdate" (gui '(+E/R +DateField) '(dob : home obj) 10 *DOB)
   "Age" (gui ...)
   ...)


Aditionally, how would I go about including a .css file to override certain
bits of the built-in one?

Thanks again for all the help, I'm taking the plunge and using PicoLisp for
my second non-trivial application (first one is in Common Lisp) and
absolutely thrilled about it so far.  The learning curve is indeed steep
but the control and expressiveness gained once a better command of the
language is obtained is nothing short of breathtaking.

Warm regards,
David Bloom


On Sun, Jan 19, 2014 at 1:12 PM, Alexander Burger <[email protected]>wrote:

> Hi David,
>
> > Essentially I can calculate age based off of DOB with a (dm T ...) line
> 18
> > but then that record won't show in the search dialog. When lines 13-20
> are
>
> You are quite close :)
>
>
> The problem is the way your 'T' method is defined:
>
>    (dm T (name NAME prefname PREFNAME sex SEX dob DOB email EMAIL txt TXT)
>       (=: name NAME)
>       ...
>
> This is not how it works. You could either define it as
>
>    (dm T (NAME PREFNAME SEX DOB EMAIL TXT)
>       (=: name NAME)
>       ...
>
> and then call 'new!' (which is implied in the 'newButton' function):
>
>    (new! '(+Person) *Name *PrefName ...)
>
> OR (and this is how I would do it), use the fact that the 'new' and
> 'new!' functions, and also the 'T' method of the '+Entity' parent class,
> accepts arguments as alternating keys and values:
>
>    (dm T (DOB . @)
>       (pass super)  # Pass remaining arguments to the parent class
>       (=: age (/ (- (date) DOB) 365)) )
>
> or, directly,
>
>    (dm T (DOB . @)
>       (pass super  'age (/ (- (date) DOB) 365)) )
>
> and then call it as
>
>    (new! '(+Person) DOB 'name *Name 'prefname *PrefName ...)
>
> or
>
>    (newButton T Dst '(+Person) DOB 'name *Name 'prefname *PrefName ...)
>
>
>
> BTW, a year has more than 365 days. A somewhat more accurate calculation
> might be
>
>    (*/ (- (date) DOB) 100 36525))
>
> Besides the fact, of course, that storing the _age_ in the database
> doesn't make sense, It is soon out of date ;-)
>
>
>
> > Also, what is the idomatic way to include an outside .js file in
> > <head>...</head>?
>
> The best is to push the file name into the global '*JS' variable
> before program start:
>
>    (push1 '*JS (allow "myFile.js"))
>
> Examples for that are in "lib/form.l" or "lib/canvas.l".
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe
>

Reply via email to