FW: Record locking

George Simon george at worldest.com
Wed Mar 31 11:49:48 PST 2004


I meant to send this to the list as well as John, but it only went to John.
Using the following actual code from the "called" table that assigns the
invoice number:

19  -------   -   -   -   -   -   -   -   -   -
       ? If:
       Then: lookup gfctrl  k=129  i=a -epx
 20  -------   -   -   -   -   -   -   -   -   -
LOOP10 ? If:
       Then: 10=gfctrl(1);gfctrl(1)=gfctrl(1)+"1"; write gfctrl

I get unique invoice numbers 99.9% of the time.  If I want the invoice
numbers to be unique 100% of the time, I have to add:

21  -------   -   -   -   -   -   -   -
       ? If:
       Then: 'check for duplicates
22  -------   -   -   -   -   -   -   -   -   -
       ? If:
       Then: lookup dup = gfsales  k=10   i=G -nx
 23  -------   -   -   -   -   -   -   -   -   -
       ? If: not dup
       Then: display; gosub SAVEIT; end
 24  -------   -   -   -   -   -   -   -   -   -
       ? If: dup(@rn) ne @rn
       Then: goto LOOP10
 25  -------   -   -   -   -   -   -   -   -   -
       ? If:
       Then: display
 26  -------   -   -   -   -   -   -   -   -   -
       ? If:
       Then: gosub SAVEIT
27  -------   -   -   -   -   -   -
       ? If:
       Then: end

I don't know why this happens, but it happens.  It should not happen, but it
does.
So, since I cannot afford to have duplicate invoice number, I have to keep
using this code.

George Simon (IT Department)
American River Logistics, LTD
614 Progress St.
Elizabeth, NJ  07205
Phone:(908)354-7746      Fax:(908)354-7491
mailto:george at worldest.com
http://www.americanriverintl.com/



-----Original Message-----
From: filepro-list-bounces at lists.celestial.com
[mailto:filepro-list-bounces at lists.celestial.com]On Behalf Of John Esak
Sent: Wednesday, March 31, 2004 3:05 AM
To: filePro mailing list
Subject: RE: Record locking


>       I have *always* done a "write" and then a "close" in a situation
> like this, where I'm working with a control file.  If I didn't do it this
> way, I can show you instances of this type of code not working correctly
> dating all the way back to filePro version 0.95 on Tandy Model 16's.
>

I wasn't going to comment on this thread because I had heard it in the FP
Room and didn't know what to offer toward solving it... but since both of
you have shown this code...


    write filename;  close filename

and say it is a good (and even necessary) syntax... it just has to be said.
This is patently, and completely _wrong_. Mike, Richard... it has been said
over and over and over again in this forum and elsewhere. The CLOSE
statement _does_ a WRITE as part of what it does. There is simply NO need to
do a WRITE before a close. It is just redundant, not needed, inelegant...
whatever you want to call it... but please, please don't call it required.
Mike, you say you can post code that will show a write that does not work
properly... please do. I don't believe a properly written code segment
incrementing a control file field and then writing the record to unlock will
break.  At least, I will say this with absolute confidence on the *nix
platforms. If you are saying Windows is different... well then you can't be
talking about a .95 version...  Put up the code you mentioned and show us
how it breaks. I would very much like to see a specific example... I'm sure
FP Tech would, too. Heck you might have exactly the code which discloses
whatever Richard's problem is.

I agree with you about doing nothing in between the "getting" of a unique
number and the incrementing and writing of that field out  as in:

   them" lookup ctrl=cotrol_file r=("1") -p
   then: num=ctrl(1);  ctrl(1)=ctrl(1)+"1";  write ctrl

This is all the code that is needed... end of story. It works. It has always
worked for me... and simply never failed. Again, I stipulate that this is on
Unix and Xenix systems of the past 20 years. I can not vouch for the Windows
product.

One other minor point. Richard's code that goes out to check if the number
has been used before... well, that makes _no_ sense to me. Why would you
have to check such a thing? If you are only supplying the next highest
number out of a control file in the way shown above... there is no need to
check whether the number you've just retrieved has ever been used... how
could it be?

As for the way you are incrementing the number itself Richard, it is a
little roundabout. You are adding the number you just assigned to the number
instead of adding "1" to the number itself. No big deal, but it is a little
odd and if that assignment is not specifically "written" maybe that is where
the problem is... _although_ the way filePro works this should absolutely
NOT be a problem. It is just odd that you do it this way.

Just so no one gets the wrong idea. I believe Richard is having the problem
he describes... I also believe whatever he did to fix it appears to have
fixed it... but it is simply _not_ an endemic filePro problem. How, could it
be? It is the basis upon which nearly _every_ filePro program has ever been
written... at least in my experience... and that is with lots of
programmers, lots of programs, lots of years... etc., etc. The times I've
ever seen a duplicated unique number, more than likely there has been a
power failure, a bad spot on a hard drive... any other thing but the fact
that filePro (or the O/S) could just decide to do it wrong one time as
opposed to another.

John

_______________________________________________
Filepro-list mailing list
Filepro-list at lists.celestial.com
http://mailman.celestial.com/mailman/listinfo/filepro-list



More information about the Filepro-list mailing list