Page 2 of 2

Re: harbour lock function

Posted: Fri Oct 15, 2010 7:55 am
by mlacecilia
Hi l3whmg,
just for curiosity:
you tried to test DBRLockList() against the record to be locked?
If the record already locked in the process A is present in the list you could obtain the expected behaviour using:

Code: Select all

/***************************************************************
* try to lock a record
***************************************************************/
FUNCTION RecLock(cAliasName, nRecNum)
LOCAL lLock := .F.
LOCAL cAlias := IIF(VALTYPE(cAliasName)=="C", ALLTRIM(cAliasName), "")
LOCAL nSeconds := NET_SECS * 2
LOCAL nCurArea := SELECT(), nArea := 0
LOCAL nNumRec := 0

nArea := IIF(LEN(cAlias)>0, SELECT(cAlias), SELECT())
IF nArea<>0
 DBSELECTAREA(nArea)
 IF VALTYPE(nRecNum)=="N" .AND. nRecNum>0 .AND. nRecNum<=LASTREC()
  nNumRec := nRecNum
 ELSE
  nNumrec := RECNO()
 ENDIF
 if AScan( DBRLockList(), { |e| e == nNumrec } ) == 0     // <<<------
     IF DBRLOCK(nNumRec)
      lLock := .T.
     ELSE
      WAIT WINDOW "Record Lock Processing..."  NOWAIT
      WHILE nSeconds>0
       DO EVENTS
       IF DBRLOCK(nNumRec)
        lLock := .T.
        EXIT
       ELSE
    * waiting
        INKEY(NET_WAIT)
        nSeconds -= NET_WAIT
       ENDIF
      END
      WAIT CLEAR
     ENDIF
    ENDIF
endif                               //    <<------
DBSELECTAREA(nCurArea)
RETURN lLock
I not tested, however.
Very interesting question, as I also have same problem to protect the edit of same record in the same application.
Best regards.
Maurizio

Re: harbour lock function

Posted: Mon Oct 18, 2010 8:48 am
by l3whmg
Hi Maurizio,
many thanks for your suggestion :D
I've tested your solution and work fine :o

Best regards

Re: harbour lock function

Posted: Mon Oct 18, 2010 1:12 pm
by esgici
Hi Luigi

Again, sorry for delay; I'm a lazy man :(
What do you thing about the famous Plug&Play or MsWin .dll and register (installed, update, reinstalled, reupdate and deleted....and so on by every program you want use) ?
Well !...

Old men yearn old days and the world continue turn on its own track; everything must improve and advance. There isn't any way (nor reason) to prevent from this course. Only old men ( like me :mrgreen: ) are out of step with this speed and grumbles continuously ;)
But behind all of this there are programmers (human)
Of course !

But, I'm worried. While programming techniques grown up, count of (real) programmer goes decreased, I'm thinking. What is your opinion?
... why is not there a "DataBase" based upon dbf technique?
We have MySql, PostGreSql, etc. Why Not?
As fas as I know, meaning of database didn't changed from beginning : A filing system consisting on one or more file. "dbf" is an abbreviation of "Data Base File"; not expressing a "system", but a kind of file. At that (happy ;) ) days, there wasn't any database system in the actual meaning. Programmers have construct him/her database system manually, that is by hard coding. For now, this is necessary when you are using RDDs DBFNTX, DBFCDX etc; that is other than <this> or <that> SQL or anything else data base server.

My preference ?

For now, until an occurrence of real need for a db-server, I'm thinking to continue using that "primitive" (manual) database systems. I need also some courage and time for learning that modern :mrgreen: systems.

At the first times of PC (early 80's) the first programming tool was interpretive BASIC. And my main question was : does we are really writing programs or simply we are writing some parameters to an existing program?

In my understanding, programmers writes programs and who writing parameters are users ;)

What is yours ?

Saluti

--

Esgici

Re: harbour lock function

Posted: Mon Oct 18, 2010 1:23 pm
by Rathinagiri
Nice, thought provoking words Esgici. Thanks.

Re: harbour lock function

Posted: Mon Oct 18, 2010 1:34 pm
by esgici
rathinagiri wrote:Nice, thought provoking words Esgici. Thanks.
Thanks to your thanks, Rathi :)

No any intention to provoking I have, only my humble (and sincere) opinions.

I never said "only my way is right", everybody has right of having own right way and I'm always respectful to this human right :)

Regards

--

Esgici

Re: harbour lock function

Posted: Tue Oct 19, 2010 1:32 pm
by l3whmg
Hi my great friend,
don't worry for delay: it's a pleasure write to you and this it's a forum ;)

I'm in agreement with you, for many reason.
But, I'm worried. While programming techniques grown up, count of (real) programmer goes decreased, I'm thinking. What is your opinion?
Yes, I think so: Too many people think of mastering different programming languages with just copied the source code.
I'm remember (when I was young :lol: ) my boss when he said:
"You are filling a source with code or writing a program? And remember: we have only 32MB of RAM and 80MB HD" (but before I had 640KB and Floppy Disk)".
For this reason I like to find a good way to write program: standardize code, a good skeleton, respect syntax, etc.
I had write too with BASIC (interpretative and compiled) and then with COBOL and RPG: always in team and for network. I think it's a good school to learn :mrgreen: For example with BASIC I had write a tool like (I'm sorry Roberto for this comparison!) HMG: read external form file and manage form field, key functions and so on. It was (about) 1986 / 1987. For these reasons I really like the style of Roberto (and all other developers) to write HMG code, because I remember the difficulty of writing "programs for programmers".
As fas as I know, meaning of database didn't changed from beginning...
Of course, but sometimes I think about integrity, speed. On the other hand I prefer DBF for ease management...
I'v only one (old) problem with dbf and ntx: deleted records. In a network environment I can't use DBPACK and DBREINDEX, but when I "seek" for a key it can happen that I find a record already deleted.
Probably I don't understand very well use of "SET DELETED [ON | OFF]": normally I use (SET DELETED OFF) an indicator and I leave the user to determine the status of record. So, I can also add any conditions related to the program :)
In my understanding, programmers writes programs and who writing parameters are users ;)
Yes, IMHO it's a great true

Well, that's all folks

Best regards

Re: harbour lock function

Posted: Tue Oct 19, 2010 5:08 pm
by apais
Yes it is since clipper days.
It's called ADS (Advantage Database Server)

There were 2 other ones but I don't know if they still exist: Apollo and CodeBase

Regards
Angel

Re: harbour lock function

Posted: Tue Oct 19, 2010 6:26 pm
by l3whmg
Hi Apais,
I've read about these DataBase: very interesting.
IMHO Apollo seems to be most similar to dbf technique and others most similar to MySql, PostGreSql, etc.

Any way, many thanks for your replay and information.

Bye

Re: harbour lock function

Posted: Tue Oct 19, 2010 6:41 pm
by gfilatov
But why is not there a "DataBase" based upon dbf technique?
Hello,

You can take a look for FiveDB library 8-) also at
http://www.hallogram.com/fivedb/index.html
and
http://www.tomsoft.de/content/fivewin.aspx

It is provided free of charge and with Full Source Code.

Re: harbour lock function

Posted: Tue Oct 19, 2010 8:18 pm
by l3whmg
Hi Grigory,
many thanks, I'll check: very interesting.

Bye