harbour lock function

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

mlacecilia
Posts: 22
Joined: Fri Oct 08, 2010 2:44 pm

Re: harbour lock function

Post 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
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: harbour lock function

Post by l3whmg »

Hi Maurizio,
many thanks for your suggestion :D
I've tested your solution and work fine :o

Best regards
Luigi from Italy
www.L3W.it
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: harbour lock function

Post 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
Viva INTERNATIONAL HMG :D
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: harbour lock function

Post by Rathinagiri »

Nice, thought provoking words Esgici. Thanks.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: harbour lock function

Post 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
Viva INTERNATIONAL HMG :D
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: harbour lock function

Post 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
Luigi from Italy
www.L3W.it
User avatar
apais
Posts: 441
Joined: Fri Aug 01, 2008 6:03 pm
DBs Used: DBF, Leto, MariaDB, SQLite
Location: uruguay
Contact:

Re: harbour lock function

Post 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
Angel Pais
Web Apps consultant/architect/developer.
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: harbour lock function

Post 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
Luigi from Italy
www.L3W.it
User avatar
gfilatov
Posts: 1116
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: harbour lock function

Post 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.
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: harbour lock function

Post by l3whmg »

Hi Grigory,
many thanks, I'll check: very interesting.

Bye
Luigi from Italy
www.L3W.it
Post Reply