Groups > dBase > dBase support > Re: Proper Retrieval of Locking information




Re: Proper Retrieval of Locking information

Re: Proper Retrieval of Locking information
Mon, 03 Dec 2007 12:20:04 -050
Ken,

I did change the function to RLOCK() but the output didn't change. In fact with
my current coding. Even if the file is not locked, my logic still states that it
is... So here is the full CFIND.PRG file's contents. I guess I don't understand
how to tell it to check the file for lock. In more modern languages I can pass
parameters, but it doesn't seem like I can do that in this language. Either that
or I lack understanding of my reference material.


SET TALK OFF
CLOSE DATABASES
STORE 'Y' TO CFV
STORE '1' TO PGV
DO WHILE CFV = 'Y'
CLEAR
 IF PGV = '1'
 STORE SPACE(21) TO CNAMEV   
 STORE '    ' TO CSTNOV
 @ 3,5 SAY 'ENTER CUSTOMER NAME OR RETURN TO QUIT ' GET CNAMEV
 READ
  IF SUBSTR(CNAMEV,1) = ' '
  STORE 'QUIT' TO CSTNOV
  STORE 'N' TO CFV
  LOOP  
  ENDIF
 STORE TRIM(CNAMEV) TO CNAMEV
  IF SUBSTR(CNAMEV,1,1) = ' ' 
  RETURN
  ENDIF
 SELECT A
 
 * BELIEVE THIS PART TO BE WHERE IT TRIES TO ACCESS THE LOCKED FILE
 * WILL TRY TO USE THE LKSYS() FUNCTION HERE
 IF RLOCK() == .F. 
   ? "FILE LOCKED ON
"+LKSYS(0)+LKSYS(1)+LKSYS(2)+LKSYS(3)+LKSYS(4)+LKSYS(5)
   WAIT
   CLEAR
    RETURN
   ELSE
    USE CST INDEX CSTNNDX
  ENDIF

 * USE CST INDEX CSTNNDX
  FIND &CNAMEV
  IF EOF()
  @ 10,10 SAY 'SORRY NO CUSTOMERS MATCH THIS NAME '
  @ 12,10 SAY 'DO YOU WISH TO TRY AGAIN ? (Y) OR (N) 'GET CFV
  READ
   IF CFV='N'
   STORE 'QUIT' TO CSTNOV
   RETURN TO MASTER
   ENDIF
  LOOP
  ENDIF
 ENDIF
STORE 8 TO V
STORE CSTNO TO CSTNOV
@ 7,1 SAY 'NAME'
@ 7,22 SAY 'DEPARTMENT'
@ 7,43 SAY 'CONTACT'
@ 7,59 SAY 'DIVI'
@ 7,64 SAY 'CITY'
@ 7,75 SAY 'CUST#'
DO WHILE V < 17 .AND. .NOT. EOF()
@ V,1 SAY SUBSTR(CNAME,1,20)
@ V,22 SAY SUBSTR(INFO,1,20)
@ V,43 SAY SUBSTR(CCONTACT,1,15)
@ V,59 SAY SUBSTR(DIV,1,4)
@ V,64 SAY SUBSTR(CCITY,1,10)
@ V,75 SAY CSTNO
STORE V + 1 TO V
SKIP
ENDDO
STORE V + 1 TO V
@ V,10 SAY 'ENTER (N)ext page (Q)uit OR CUSTOMER NUMBER ' GET CSTNOV
READ
 IF SUBSTR(CSTNOV,1,1) = 'N'
 STORE '2' TO PGV
 LOOP
 ENDIF
  IF SUBSTR(CSTNOV,1,1) = 'Q'
  STORE 'N' TO CFV
  RETURN TO MASTER
Post Reply
Re: Proper Retrieval of Locking information
Mon, 3 Dec 2007 14:34:33 -0600
"Matthew" <mrockhold@walzeq.com> wrote in message 
news:Qt0t%23CdNIHA.1852@news-server...
> Ken,
>

<snip>
> * BELIEVE THIS PART TO BE WHERE IT TRIES TO ACCESS THE LOCKED FILE
> * WILL TRY TO USE THE LKSYS() FUNCTION HERE
> IF RLOCK() == .F.

&& maybe this will work.
IF .NOT. RLOCK()
   && record lock failed.
   ? "FILE LOCKED ON "+LKSYS(3)+LKSYS(4)+LKSYS(5)

Hope it helps,
Rick Miller 

Post Reply
Re: Proper Retrieval of Locking information
Mon, 03 Dec 2007 20:26:12 -080
Matthew wrote:
> Ken,
> 
> I did change the function to RLOCK() but the output didn't change. In
> fact with my current coding. Even if the file is not locked, my logic
> still states that it is... So here is the full CFIND.PRG file's
> contents. I guess I don't understand how to tell it to check the file
> for lock. In more modern languages I can pass parameters, but it
> doesn't seem like I can do that in this language. Either that or I
> lack understanding of my reference material.

Does the table in question have the _DBASELOCK field in it? I.e., did 
you run the CONVERT command against the table?

Ken

-- 
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
Post Reply
Re: Proper Retrieval of Locking information
Tue, 4 Dec 2007 08:40:59 -0500
In article <Qt0t#CdNIHA.1852@news-server>, mrockhold@walzeq.com says...
> 
> SET TALK OFF
> CLOSE DATABASES

Here, you've just closed all the tables.

> STORE 'Y' TO CFV
> STORE '1' TO PGV
> DO WHILE CFV = 'Y'
> CLEAR
>  IF PGV = '1'
>  STORE SPACE(21) TO CNAMEV   
>  STORE '    ' TO CSTNOV
>  @ 3,5 SAY 'ENTER CUSTOMER NAME OR RETURN TO QUIT ' GET CNAMEV
>  READ
>   IF SUBSTR(CNAMEV,1) = ' '
>   STORE 'QUIT' TO CSTNOV
>   STORE 'N' TO CFV
>   LOOP  
>   ENDIF
>  STORE TRIM(CNAMEV) TO CNAMEV
>   IF SUBSTR(CNAMEV,1,1) = ' ' 
>   RETURN
>   ENDIF
>  SELECT A
>  

You haven't opened any tables, so this has nothing to function with.  
You have to open the table before testing the lock....

>  * BELIEVE THIS PART TO BE WHERE IT TRIES TO ACCESS THE LOCKED FILE
>  * WILL TRY TO USE THE LKSYS() FUNCTION HERE
>  IF RLOCK() == .F. 
>    ? "FILE LOCKED ON
"+LKSYS(0)+LKSYS(1)+LKSYS(2)+LKSYS(3)+LKSYS(4)+LKSYS(5)
>    WAIT
>    CLEAR
>     RETURN
>    ELSE
>     USE CST INDEX CSTNNDX
>   ENDIF
> 
>  * USE CST INDEX CSTNNDX
>   FIND &CNAMEV
>   IF EOF()
>   @ 10,10 SAY 'SORRY NO CUSTOMERS MATCH THIS NAME '
>   @ 12,10 SAY 'DO YOU WISH TO TRY AGAIN ? (Y) OR (N) 'GET CFV
>   READ
>    IF CFV='N'
>    STORE 'QUIT' TO CSTNOV
>    RETURN TO MASTER
>    ENDIF
>   LOOP
>   ENDIF
>  ENDIF
> STORE 8 TO V
> STORE CSTNO TO CSTNOV
> @ 7,1 SAY 'NAME'
> @ 7,22 SAY 'DEPARTMENT'
> @ 7,43 SAY 'CONTACT'
> @ 7,59 SAY 'DIVI'
> @ 7,64 SAY 'CITY'
> @ 7,75 SAY 'CUST#'
> DO WHILE V < 17 .AND. .NOT. EOF()
> @ V,1 SAY SUBSTR(CNAME,1,20)
> @ V,22 SAY SUBSTR(INFO,1,20)
> @ V,43 SAY SUBSTR(CCONTACT,1,15)
> @ V,59 SAY SUBSTR(DIV,1,4)
> @ V,64 SAY SUBSTR(CCITY,1,10)
> @ V,75 SAY CSTNO
> STORE V + 1 TO V
> SKIP
> ENDDO
> STORE V + 1 TO V
> @ V,10 SAY 'ENTER (N)ext page (Q)uit OR CUSTOMER NUMBER ' GET CSTNOV
> READ
>  IF SUBSTR(CSTNOV,1,1) = 'N'
>  STORE '2' TO PGV
>  LOOP
>  ENDIF
>   IF SUBSTR(CSTNOV,1,1) = 'Q'
>   STORE 'N' TO CFV
>   RETURN TO MASTER
>   ENDIF
> 

-- 
Marilyn Price
Post Reply
Re: Proper Retrieval of Locking information
Tue, 04 Dec 2007 10:12:12 -050
Ken,

>Does the table in question have the _DBASELOCK field in it? I.e., did 
>you run the CONVERT command against the table?

I did run USE CST, then CONVERT TO 24 command against the table being used
(CST.DBF) in the command line from the beginning. After running LIST STRUCTURE
the _DBASELOCK field is present.

I thought maybe that I had it right because I can get LKYSYS(3) to LKSYS(5) to
output information. (Though 0-3 still output blank.)

Thanks,
Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact