Re: Calculating age based on DOB
Thank you Alex. I cannot seem to find httpGate anywhere in the distribution 3.1.5. I know this is terribly noob-ish but where is httpGate located? On Mon, Jan 27, 2014 at 2:02 AM, Alexander Burger a...@software-lab.dewrote: Hi David, If I load the app by going to localhost:8080 I see the button and can click on it but nothing happens and the button becomes disabled. If I then refresh the page (it now has a long session string in the address bar) the button is enabled and I can click on it, the desired Alert dialog pops up working correctly. Indeed, this is a known problem. The reason lies with the same server orgigin policy of JavaScript's XMLHttpRequests. Because PicoLisp uses a separate HTTP port for each session, JavaScript (wrongly) believes this is a new server, and refuses to execute :( How can I get the button to work the first time without reloading the page? The right way to handle this is to run web applications in combination with 'httpGate'. The best way is to start (as user 'root') /usr/lib/picolisp/bin/httpGate 80 8080 and (if you like to use HTTPS) /usr/lib/picolisp/bin/httpGate 443 8080 path-to-PEM I have similar lines in my /etc/rc.local file. For a local installation, adjust the pathes to 'httpGate' accordingly. With httpGate you also have the advantage that you don't need to specify :8080 in the browser (and that you can use HTTPS, of course). ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Calculating age based on DOB
Hi David, Thank you Alex. I cannot seem to find httpGate anywhere in the distribution 3.1.5. I know this is terribly noob-ish but where is httpGate located? Not really your fault, because httpGate is not yet well documented. Only some fragments in this Mailing list and in the Wiki. The binary 'httpGate' is either in /usr/lib/picolisp/bin/httpGate (if you install the picolisp package with 'apt-get'), or in your bin/ directory (if you install it locally). The local executable is built if you make PicoLisp as described in the INSTALL file. Instead of /usr/lib/picolisp/bin/httpGate 80 8080 /usr/lib/picolisp/bin/httpGate 443 8080 path-to-PEM you call it as e.g. /path/to/picolisp/bin/httpGate 80 8080 /path/to/picolisp/bin/httpGate 443 8080 path-to-PEM As you see, no big thing. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Calculating age based on DOB
Correction, it's available when I install pico from my distribution but I'm then back on 3.1.2. How can I build the latest on x86-64 LMDE? On Mon, Jan 27, 2014 at 2:02 AM, Alexander Burger a...@software-lab.dewrote: Hi David, If I load the app by going to localhost:8080 I see the button and can click on it but nothing happens and the button becomes disabled. If I then refresh the page (it now has a long session string in the address bar) the button is enabled and I can click on it, the desired Alert dialog pops up working correctly. Indeed, this is a known problem. The reason lies with the same server orgigin policy of JavaScript's XMLHttpRequests. Because PicoLisp uses a separate HTTP port for each session, JavaScript (wrongly) believes this is a new server, and refuses to execute :( How can I get the button to work the first time without reloading the page? The right way to handle this is to run web applications in combination with 'httpGate'. The best way is to start (as user 'root') /usr/lib/picolisp/bin/httpGate 80 8080 and (if you like to use HTTPS) /usr/lib/picolisp/bin/httpGate 443 8080 path-to-PEM I have similar lines in my /etc/rc.local file. For a local installation, adjust the pathes to 'httpGate' accordingly. With httpGate you also have the advantage that you don't need to specify :8080 in the browser (and that you can use HTTPS, of course). ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Calculating age based on DOB
Hi, I think you need to run 'make all' or 'make gate' to build httpGate along with the interpreter. That should create a binary and place it in the 'bin' directory of the distribution. best wishes, Mattias On 2 February 2014 18:16, me yanosh...@gmail.com wrote: Thank you Alex. I cannot seem to find httpGate anywhere in the distribution 3.1.5. I know this is terribly noob-ish but where is httpGate located? On Mon, Jan 27, 2014 at 2:02 AM, Alexander Burger a...@software-lab.dewrote: Hi David, If I load the app by going to localhost:8080 I see the button and can click on it but nothing happens and the button becomes disabled. If I then refresh the page (it now has a long session string in the address bar) the button is enabled and I can click on it, the desired Alert dialog pops up working correctly. Indeed, this is a known problem. The reason lies with the same server orgigin policy of JavaScript's XMLHttpRequests. Because PicoLisp uses a separate HTTP port for each session, JavaScript (wrongly) believes this is a new server, and refuses to execute :( How can I get the button to work the first time without reloading the page? The right way to handle this is to run web applications in combination with 'httpGate'. The best way is to start (as user 'root') /usr/lib/picolisp/bin/httpGate 80 8080 and (if you like to use HTTPS) /usr/lib/picolisp/bin/httpGate 443 8080 path-to-PEM I have similar lines in my /etc/rc.local file. For a local installation, adjust the pathes to 'httpGate' accordingly. With httpGate you also have the advantage that you don't need to specify :8080 in the browser (and that you can use HTTPS, of course). ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Calculating age based on DOB
When I run make from src64 nothing happens. When I run make from src it compiles but no httpGate. Weird. I'll stick to packaged version for now as I may wind up testing it on PC-BSD 10 for fun. On Sun, Feb 2, 2014 at 1:27 PM, Alexander Burger a...@software-lab.dewrote: Hi David, Thank you Alex. I cannot seem to find httpGate anywhere in the distribution 3.1.5. I know this is terribly noob-ish but where is httpGate located? Not really your fault, because httpGate is not yet well documented. Only some fragments in this Mailing list and in the Wiki. The binary 'httpGate' is either in /usr/lib/picolisp/bin/httpGate (if you install the picolisp package with 'apt-get'), or in your bin/ directory (if you install it locally). The local executable is built if you make PicoLisp as described in the INSTALL file. Instead of /usr/lib/picolisp/bin/httpGate 80 8080 /usr/lib/picolisp/bin/httpGate 443 8080 path-to-PEM you call it as e.g. /path/to/picolisp/bin/httpGate 80 8080 /path/to/picolisp/bin/httpGate 443 8080 path-to-PEM As you see, no big thing. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Calculating age based on DOB
Thank you Mattias that's what I needed. On Sun, Feb 2, 2014 at 1:41 PM, Mattias Sundblad mattias@gmail.comwrote: Hi, I think you need to run 'make all' or 'make gate' to build httpGate along with the interpreter. That should create a binary and place it in the 'bin' directory of the distribution. best wishes, Mattias On 2 February 2014 18:16, me yanosh...@gmail.com wrote: Thank you Alex. I cannot seem to find httpGate anywhere in the distribution 3.1.5. I know this is terribly noob-ish but where is httpGate located? On Mon, Jan 27, 2014 at 2:02 AM, Alexander Burger a...@software-lab.dewrote: Hi David, If I load the app by going to localhost:8080 I see the button and can click on it but nothing happens and the button becomes disabled. If I then refresh the page (it now has a long session string in the address bar) the button is enabled and I can click on it, the desired Alert dialog pops up working correctly. Indeed, this is a known problem. The reason lies with the same server orgigin policy of JavaScript's XMLHttpRequests. Because PicoLisp uses a separate HTTP port for each session, JavaScript (wrongly) believes this is a new server, and refuses to execute :( How can I get the button to work the first time without reloading the page? The right way to handle this is to run web applications in combination with 'httpGate'. The best way is to start (as user 'root') /usr/lib/picolisp/bin/httpGate 80 8080 and (if you like to use HTTPS) /usr/lib/picolisp/bin/httpGate 443 8080 path-to-PEM I have similar lines in my /etc/rc.local file. For a local installation, adjust the pathes to 'httpGate' accordingly. With httpGate you also have the advantage that you don't need to specify :8080 in the browser (and that you can use HTTPS, of course). ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Calculating age based on DOB
Thanks Alex that worked perfectly! Now I can display age calculated on the fly without wasting space in the DB. This isn't related to calculating age based on DOB but if you could please help me understand why is it that when I have a form and a line like: (de testo () (app) (action (html 0 Test! @lib.css NIL (form NIL (gui '(+OnClick +Button) alert('OK') Alert) ... ) If I load the app by going to localhost:8080 I see the button and can click on it but nothing happens and the button becomes disabled. If I then refresh the page (it now has a long session string in the address bar) the button is enabled and I can click on it, the desired Alert dialog pops up working correctly. How can I get the button to work the first time without reloading the page? The reason I ask is because I'm trying to use a JS charting library and can include all the necessary files but the same thing happens with this button. I have to reload the page and then click the button which loads the chart. The chart then appears correctly in the div I made for it but then promptly disappears. I feel like this page reloading issue is related
Re: Calculating age based on DOB
Hi David, If I load the app by going to localhost:8080 I see the button and can click on it but nothing happens and the button becomes disabled. If I then refresh the page (it now has a long session string in the address bar) the button is enabled and I can click on it, the desired Alert dialog pops up working correctly. Indeed, this is a known problem. The reason lies with the same server orgigin policy of JavaScript's XMLHttpRequests. Because PicoLisp uses a separate HTTP port for each session, JavaScript (wrongly) believes this is a new server, and refuses to execute :( How can I get the button to work the first time without reloading the page? The right way to handle this is to run web applications in combination with 'httpGate'. The best way is to start (as user 'root') /usr/lib/picolisp/bin/httpGate 80 8080 and (if you like to use HTTPS) /usr/lib/picolisp/bin/httpGate 443 8080 path-to-PEM I have similar lines in my /etc/rc.local file. For a local installation, adjust the pathes to 'httpGate' accordingly. With httpGate you also have the advantage that you don't need to specify :8080 in the browser (and that you can use HTTPS, of course). ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Calculating age based on DOB
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:picolisp@software-lab.de?subject=Unsubscribe
Re: Calculating age based on DOB
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 a...@software-lab.dewrote: 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:picolisp@software-lab.de?subject=Unsubscribe
Re: Calculating age based on DOB
Hi David, 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 One more thought: Perhaps a better way to calculate the age is to avoid floating points, and do it directly in integer calculation: (de age (Birth) (setq Birth (date Birth)) (let (Dat (date (date)) Age (- (car Dat) (car Birth))) (when ( (cdr Birth) (cdr Dat)) (dec 'Age) ) Age ) ) Here, the calls (cdr Birth) and (cdr Dat) each return a list of the form (month day), so they can be directly compared. 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) Note: the '*DOB' at the end is notneeded. You might pass another label here, which is probably not what you want. I would use the '+View' prefix, for a read-only field. With the above 'age' function it gives: Age (gui '(+View +DateField) '(age (: home obj dob)) 10) Aditionally, how would I go about including a .css file to override certain bits of the built-in one? Instead of a single CSS file, you can also pass a list of files: (html ... '(@lib.css my/lib.css) ... As my/lib.css comes after @lib.css, it will override styles in @lib.css. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe