Re: [U2] READU ... THEN _or_ ELSE but not both?

2004-10-30 Thread FFT2001
In a message dated 10/29/2004 2:24:37 PM Pacific Daylight Time, 
[EMAIL PROTECTED] writes:

 READU R.XBWU FROM F.XBWU, X.ONE.ID LOCKED
   CRT 'XBWU RECORD IS LOCKED, IGNORE IT'
 END THEN
   X.LOCKED = '1'
 END ;*END READU
 
 IF X.LOCKED = '1' THEN
   CRT 'OBTAINED LOCK ON XBWU RECORD'
   R.XBWUXBWU.ASURITE = X.ASURITE
   WRITE R.XBWU TO F.XBWU, X.ONE.ID ON ERROR
IF STATUS() = 10 THEN 
  ;* Either the ASURITE or USER.ID is duplicated
  X.ERROR = X.DUPLICATE.ON.WRITE
END ;* IF STATUS
   END ;* END WRITE
 END ;* IF X.LOCKED

Wendy, in the ELSE situation you are leaving a lock.
When a record does NOT exist and you READU it, you still set a lock.  Since 
your WRITE only happens with collusion with the THEN, then a loop on the above 
code, in a situation where some records may not exist will gradually fill your 
lock table.
Will
---
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] READU ... THEN _or_ ELSE but not both?

2004-10-30 Thread FFT2001
In a message dated 10/29/2004 2:58:52 PM Pacific Daylight Time, 
[EMAIL PROTECTED] writes:

 DONELOK = 0
 LOOP UNTIL DONELOK = 1 DO
 READU LOKREC FROM CUSTOMERFILE,CUSTID LOCKED
  CRT TIMEDATE():\ port \:SYSTEM(18):\ file CUSTOMER item \:CUSTID:\locked!\
 ; SLEEP 1
 END THEN DONELOK = 1 ELSE LOKREC = '' ; DONELOK = 1
 REPEAT

Notice, within the body of the loop you have three conditions and you are 
setting your flag in TWO of them.  If you reverse your logic you can instead set 
the flag in ONE and also remove one conditional test entirely.  See:

LOOP
  DONELOCK = 1
  READU LOKREC FROM CUSTOMERFILE,CUSTID LOCKED
 CRT TIMEDATE():\ port \:SYSTEM(18):
 CRT \ file CUSTOMER item \:CUSTID:\locked!
 SLEEP 1; DONELOK = 0
 END  ELSE LOKREC = ''
   WHILE NOT(DONELOCK) DO  REPEAT


Will Johnson
---
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] READU ... THEN _or_ ELSE but not both?

2004-10-29 Thread Allen Egerton
On Fri, 29 Oct 2004 14:07:56 -0700, you wrote:

From the documentation:

READU dyn.array.var FROM [file.var,] record.ID.expr [LOCKED statements]
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}

Am I reading this right?  When I READU I can either have a THEN or an
ELSE, but not both?  (That it does not compile with both tends to
confirm that...) 

At the moment I think I need both. :/ And I need to do the same thing in
either case, so I ended up with:

READU R.XBWU FROM F.XBWU, X.ONE.ID LOCKED
   CRT 'XBWU RECORD IS LOCKED, IGNORE IT'
END THEN
   X.LOCKED = '1'
END ;*END READU

IF X.LOCKED = '1' THEN
   CRT 'OBTAINED LOCK ON XBWU RECORD'
   R.XBWUXBWU.ASURITE = X.ASURITE
   WRITE R.XBWU TO F.XBWU, X.ONE.ID ON ERROR
  IF STATUS() = 10 THEN 
 ;* Either the ASURITE or USER.ID is duplicated
 X.ERROR = X.DUPLICATE.ON.WRITE
  END ;* IF STATUS
   END ;* END WRITE
END ;* IF X.LOCKED

Suggestions for improvement are welcome!

I don't know if this is an improvement, (actually I know that the
GOTO's in it will offend some people), but here's a snippet of code I
lifted directly from a routine that's heavily used in a Universe
multi-user environment:


ATTEMPTS = 0
READ.NAFILE.DB:
READU D.NAFILE.DB FROM F.NAFILE.DB, K.NAFILE.DB LOCKED
 ATTEMPTS += 1
 IF ATTEMPTS LT 50 THEN  ; *  About 20 Mins, (21:15)
CRT CLR22DOWN: NAFILE.DB : K.NAFILE.DB:
CRT  locked by : STATUS(): , (pausing before retry [:
ATTEMPTS: ]).:
CALL !SLEEP$(ATTEMPTS*1000)
CRT CLR22DOWN:
GOTO READ.NAFILE.DB:
 END ELSE
ERROR.MSG = Record locked and consequently skipped
CALL @WSEQ(*** ERROR *** : K.NAFILE.DB, F.RPT.1)
CALL @WSEQ(  : ERROR.MSG, F.RPT.1)
CALL @WSEQ(  : RAW.LINE, F.RPT.1)
CALL @WSEQ( , F.RPT.1)
CNT.LOCKED += 1
GOTO NEXT.INPUT.LINE:
 END
  END THEN
 NULL
  END ELSE
 ERROR.MSG = Record apparently deleted from database.
 CALL @WSEQ(*** ERROR *** : K.NAFILE.DB, F.RPT.1)
 CALL @WSEQ(  : ERROR.MSG, F.RPT.1)
 CALL @WSEQ(  : RAW.LINE, F.RPT.1)
 CALL @WSEQ( , F.RPT.1)
 RELEASE F.NAFILE.DB, K.NAFILE.DB
 CNT.ABNORMAL += 1
 GOTO NEXT.INPUT.LINE:
  END


-- 
Allen Egerton
[EMAIL PROTECTED]
---
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] READU ... THEN _or_ ELSE but not both?

2004-10-29 Thread Horn, John
 On Behalf Of Wendy Smoak
 
 Am I reading this right?  When I READU I can either have a THEN or
an
 ELSE, but not both?  (That it does not compile with both tends to
 confirm that...) 

This snippet of code compiles on Unidata 6.0:

ID=???
OPEN ,VOC TO BLAH ELSE STOP 

READU DUM FROM BLAH,ID LOCKED   
   DISPLAY LOCKED 
END THEN
   DISPLAY GOT IT 
END ELSE
   DISPLAY DON'T GOT IT   
END 

And seems to run correctly.

 - jmh
---
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] READU ... THEN _or_ ELSE but not both?

2004-10-29 Thread CDMI
Wendy - here's a snippet:
DONELOK = 0
LOOP UNTIL DONELOK = 1 DO
 READU LOKREC FROM CUSTOMERFILE,CUSTID LOCKED
  CRT TIMEDATE():\ port \:SYSTEM(18):\ file CUSTOMER item \:CUSTID:\locked!\
; SLEEP 1
 END THEN DONELOK = 1 ELSE LOKREC = '' ; DONELOK = 1
REPEAT

notice the LOCKED END THEN  ELSE

Steve Trimble
Computerized Data Mgmt Inc
PO Box 3473
Fayetteville, AR 72702
(479) 521-5670
9:00am - 6:00pm CST
[EMAIL PROTECTED]

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Wendy Smoak
Sent: Friday, October 29, 2004 4:08 PM
To: [EMAIL PROTECTED]
Subject: [U2] READU ... THEN _or_ ELSE but not both?


From the documentation:

READU dyn.array.var FROM [file.var,] record.ID.expr [LOCKED statements]
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}

Am I reading this right?  When I READU I can either have a THEN or an
ELSE, but not both?  (That it does not compile with both tends to
confirm that...)

At the moment I think I need both. :/ And I need to do the same thing in
either case, so I ended up with:

READU R.XBWU FROM F.XBWU, X.ONE.ID LOCKED
   CRT 'XBWU RECORD IS LOCKED, IGNORE IT'
END THEN
   X.LOCKED = '1'
END ;*END READU

IF X.LOCKED = '1' THEN
   CRT 'OBTAINED LOCK ON XBWU RECORD'
   R.XBWUXBWU.ASURITE = X.ASURITE
   WRITE R.XBWU TO F.XBWU, X.ONE.ID ON ERROR
  IF STATUS() = 10 THEN
 ;* Either the ASURITE or USER.ID is duplicated
 X.ERROR = X.DUPLICATE.ON.WRITE
  END ;* IF STATUS
   END ;* END WRITE
END ;* IF X.LOCKED

Suggestions for improvement are welcome!

--
Wendy Smoak
---
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] READU ... THEN _or_ ELSE but not both?

2004-10-29 Thread Kryka, Richard
I like this format:

READU RECORD FROM FILE, ID LOCKED

END THEN

END ELSE

END

Dick Kryka
Director of Applications
CCCS of Greater Denver, Inc.
Paragon Financial Services
303-632-2226
[EMAIL PROTECTED]
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Wendy Smoak
Sent: Friday, October 29, 2004 3:08 PM
To: [EMAIL PROTECTED]
Subject: [U2] READU ... THEN _or_ ELSE but not both?

From the documentation:

READU dyn.array.var FROM [file.var,] record.ID.expr [LOCKED statements]
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}

Am I reading this right?  When I READU I can either have a THEN or an
ELSE, but not both?  (That it does not compile with both tends to
confirm that...) 

er.u2ug.org/
---
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/