Thanks Alex, Could you also comment on the problem with step 8 please - I believe, its independent of the setup issue.
8. I open another browser tab and hit localhost:3000 and find that the record that I had entered does not show up - I believe it should have showed up. Regards, Kashyap On Fri, Aug 30, 2019 at 6:18 AM Alexander Burger <a...@software-lab.de> wrote: > Hi Kashyap, > > > 1. Run the sample (attached) as follows - > > pil guest.l + > > : (setup) (go) (wait) > > 2. I hit localhost:3000 (since I have httpGate 3000 8080 running > > 3. I enter the details in the form and hit send followed by confirmation > > 4. I notice that I get -- addM -- Bad message > > I see. The problem is the *Gbk global. It is NIL if the file is loaded > the first time and 'setup' has not been called yet. > > "guest.l" first does > > (pool "gb.db") > > (setq > *Gbk (car (collect 'nm '+Gbk)) # decide which guestbook we'll serve > ) > > but the DB is still empty. > > It works if you do > > $ pil guest.l -setup -bye # Create the DB > $ pil guest.l -go + > or $ pil guest.l -go -wait > > > I would not do the 'pool' and the initialization of *Gbk on top of the > file, but > in a separate 'main' function (or here in 'go'): > > (de go () > (pool "gb.db") > (unless (seq *DB) > (new! '(+Gbk) 'nm "Your guestbook name here") ) > (setq *Gbk (car (collect 'nm '+Gbk) ) ) # decide which guestbook > we'll serve > (server 8080 "!work") ) > > Note that 'collect' is not wise here, as it collects the *whole* DB into a > list > just to get the first element :) > > > BTW, there is another minor glitch: The > > (commit 'upd) > > at the end of 'addM>' is superfluous, as both 'new!' and 'put!>' already > did an > implied commit. > > ☺/ A!ex > > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >