Re: A Minimal PicoLisp DB/GUI Application, Importing

2015-01-15 Thread Alexander Burger
Hi Jon,

 (de importAddr (F)
(let (Cnt 0  L NIL)
   (in F
  (while (setq L (split (line) ^I))
 (dbSync)
 (let Obj (request '(+Prs) 'nm (pack (car L)))
(put Obj 'adr (pack (cadr L)))
(put Obj 'em (pack (caddr L)))
(put Obj 'tel (pack (cadddr L)))
(put Obj 'dob (format (pack (get L 5 )
 (commit 'upd)
 (inc 'Cnt) ) )
 (prinl Lines read:  Cnt) ) )

OK, fine. Looks good :)


 If I do the import twice from the same file, then I get duplicates of
 each address in the DB.

This is strange, and should not be the case. Are you sure? The 'request'
prevents that, as long as the names 'nm' are different.


 One of the addresses in my DB is Veien 1,  Byen”. If I search for
 1 in Address, I get no match, but if I search for 9 in Address, I
 get a match. Why this difference?

I tried to explain that in a previous mail. Only substrings of a minimal
length of 3 characters make sense to be searched, because that is the
shortest substring written into the index. Searching for a single
character may or may not return something, depending if it happens that
a substring starts with it. 999 and  are in the index.


 If my DB containes very many addresses, say more than 1000, then a
 search could easily match lot more than the 12 that can be displayed at
 one time in this app.

Yes, then you may scroll down in the chart.


 If the number of matches also was quite big, then I think it would
 have been nice to see this number down by the back- and forth-buttons at
 the bottom. Is it easy to get hold of this number?

Not in general. As I said, the search is incremenetal. 1000 is not much,
I have a million in some databases. Searching through all of them just
to obtain the count of matches is not feasible.

So QueryChart searches only as many as is given by the chart, and then
continues to fetch the next single line, or the next page of 12 lines.


 How many addresses do you think this simple app can handle, without
 operations (search, update) getting very slow? More than 100.000? I’m
 just curious.

No limit. It won't get slow even with 100 millions, for the above
reasons.

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


Re: A Minimal PicoLisp DB/GUI Application, Importing

2015-01-15 Thread Jon Kleiser
Hi Alex,

Now I have got this import thing working. I added the following code at the end 
of the minDbGui.l file:

# To import from tab-separated file, use: (importAddr myAddrDB.csv)
(de importAddr (F)
   (let (Cnt 0  L NIL)
  (in F
 (while (setq L (split (line) ^I))
(dbSync)
(let Obj (request '(+Prs) 'nm (pack (car L)))
   (put Obj 'adr (pack (cadr L)))
   (put Obj 'em (pack (caddr L)))
   (put Obj 'tel (pack (cadddr L)))
   (put Obj 'dob (format (pack (get L 5 )
(commit 'upd)
(inc 'Cnt) ) )
(prinl Lines read:  Cnt) ) )

If I do the import twice from the same file, then I get duplicates of each 
address in the DB. That’s not a big problem, but if it is possible to prevent 
duplicated names by doing something simple, that could be something I’d like to 
do.

Another observation:
One of the addresses in my DB is Veien 1,  Byen”. If I search for 1 in 
Address, I get no match, but if I search for 9 in Address, I get a match. Why 
this difference?

If my DB containes very many addresses, say more than 1000, then a search could 
easily match lot more than the 12 that can be displayed at one time in this 
app. If the number of matches also was quite big, then I think it would have 
been nice to see this number down by the back- and forth-buttons at the bottom. 
Is it easy to get hold of this number?

How many addresses do you think this simple app can handle, without operations 
(search, update) getting very slow? More than 100.000? I’m just curious.

/Jon

On 15. Jan, 2015, at 07:57, Alexander Burger a...@software-lab.de wrote:

 On Wed, Jan 14, 2015 at 05:54:17PM +0100, Alexander Burger wrote:
 A simple example would be
 
   (in myAdrDB.csv
  (while (split (line) ^I)
 (dbSync)
 (let Obj (request '(+Prs) 'nm (pack (car L)))
(put Obj 'adr (pack (cadr L)))
(put Obj ...)
... )
 (commit 'upd) ) )
 
 Not correct of course. Better:
 
   (use L
  (in myAdrDB.csv
 (while (setq L (split (line) ^I))
(dbSync)
... L ...
 -- 

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


RE: A Minimal PicoLisp DB/GUI Application, Importing twice

2015-01-15 Thread Jon Kleiser
Hi Alex,

From: picolisp@software-lab.de picolisp@software-lab.de on behalf of 
Alexander Burger a...@software-lab.de
Sent: 15 January 2015 16:42
To: picolisp@software-lab.de
Subject: Re: A Minimal PicoLisp DB/GUI Application, Importing

Hi Jon,

 (de importAddr (F)
(let (Cnt 0  L NIL)
   (in F
  (while (setq L (split (line) ^I))
 (dbSync)
 (let Obj (request '(+Prs) 'nm (pack (car L)))
(put Obj 'adr (pack (cadr L)))
(put Obj 'em (pack (caddr L)))
(put Obj 'tel (pack (cadddr L)))
(put Obj 'dob (format (pack (get L 5 )
 (commit 'upd)
 (inc 'Cnt) ) )
 (prinl Lines read:  Cnt) ) )

OK, fine. Looks good :)


 If I do the import twice from the same file, then I get duplicates of
 each address in the DB.

This is strange, and should not be the case. Are you sure? The 'request'
prevents that, as long as the names 'nm' are different.

...
♪♫ Alex


Yes, I have now repeated my experiment from scratch, importing same file twice. 
I get duplicates. Here is my myAddrDB.csv file, just replace the vertical bars 
with tabs:

Per|Veien 1|p...@no.no|11223344|712582
Pål|Veien 2|p...@no.no|11223345|712583
Espen Askeladd|Veien 3|es...@no.no|11223346|712584
Ola Normann|Veien 4||11223347|712585

Here is the dumped results:

(obj (+Prs) (1 . 7)
   dob 712584
   tel 11223346
   em es...@no.no
   adr Veien 3
   nm Espen Askeladd )
(obj (+Prs) (1 . 19)
   dob 712584
   tel 11223346
   em es...@no.no
   adr Veien 3
   nm Espen Askeladd )
(obj (+Prs) (1 . 12)
   dob 712585
   tel 11223347
   adr Veien 4
   nm Ola Normann )
(obj (+Prs) (1 . 26)
   dob 712585
   tel 11223347
   adr Veien 4
   nm Ola Normann )
(obj (+Prs) (1 . 2)
   dob 712582
   tel 11223344
   em p...@no.no
   adr Veien 1
   nm Per )
(obj (+Prs) (1 . 13)
   dob 712582
   tel 11223344
   em p...@no.no
   adr Veien 1
   nm Per )
(obj (+Prs) (1 . 6)
   dob 712583
   tel 11223345
   em p...@no.no
   adr Veien 2
   nm Pål )
(obj (+Prs) (1 . 18)
   dob 712583
   tel 11223345
   em p...@no.no
   adr Veien 2
   nm Pål )
(commit)

/JonPԔ � j)mX�����zV�u�.n7�

Re: A Minimal PicoLisp DB/GUI Application, Importing twice

2015-01-15 Thread Alexander Burger
Hi Jon,

 Yes, I have now repeated my experiment from scratch, importing same
 file twice. I get duplicates. Here is my myAddrDB.csv file, just replace
 the vertical bars with tabs:

 Per|Veien 1|p...@no.no|11223344|712582
 Pål|Veien 2|p...@no.no|11223345|712583
 Espen Askeladd|Veien 3|es...@no.no|11223346|712584
 Ola Normann|Veien 4||11223347|712585

Then something else must be wrong. The expression

   (request '(+Prs) 'nm (pack (car L)))

re-uses an existing object with that name.

BTW, if you want the combination of name and address to be unique, you
could call

   (request '(+Prs)
  'nm (pack (car L))
  'adr (pack (cadr L)) )


Anyway, I imported your data several times, and always end up with 4
objects in the DB.

Perhaps these objects remained from previous experiments? Did you start
with an empty DB? Please remove the adr.db file once, and try again.

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


Re: altering lists

2015-01-15 Thread Alexander Burger
Hi Dave,

On Fri, Jan 16, 2015 at 01:18:19AM +, Loyall, David wrote:
 Should either (insert ...) or (place ...) be destructive?

No, but destructive operators could be made in a similar way.

A destructive 'place' is basically 'set', BTW, if you combine it with
'nth' or 'seek' etc..


 Are they meant to be synonyms?

No. 'place' replaces, and 'insert' inserts ;-)

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


Re: A Minimal PicoLisp DB/GUI Application, Importing

2015-01-15 Thread Henrik Sarvell
Hi Jon, maybe this script will be of help:
https://bitbucket.org/hsarvell/ext/src/tip/sqlimport.l?at=default

It's very crude but it is trying to handle the SQL - PicoDB
conversion through the constraint that you have to first run it on
table A if A is referenced in table B, and then run it again on table
B, that way you can create the +Ref on import.



On Thu, Jan 15, 2015 at 7:57 AM, Alexander Burger a...@software-lab.de wrote:
 On Wed, Jan 14, 2015 at 05:54:17PM +0100, Alexander Burger wrote:
 A simple example would be

(in myAdrDB.csv
   (while (split (line) ^I)
  (dbSync)
  (let Obj (request '(+Prs) 'nm (pack (car L)))
 (put Obj 'adr (pack (cadr L)))
 (put Obj ...)
 ... )
  (commit 'upd) ) )

 Not correct of course. Better:

(use L
   (in myAdrDB.csv
  (while (setq L (split (line) ^I))
 (dbSync)
 ... L ...
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


altering lists

2015-01-15 Thread Loyall, David
Should either (insert ...) or (place ...) be destructive?

Are they meant to be synonyms?

Cheers,
--Dave


: (setq truck '(frame))
- (frame)
: (show truck) 
- (frame)
: (insert '2 truck 'cab)
- (frame cab)
: (show truck)  
- (frame)
: (place '2 truck 'cab)  
- (frame cab)
: (show truck) 
- (frame)
: 
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe