I would suggest that in a case where you want to determine which one of the apparently multiple possible states the remote record occupies you should consider calling a subroutine from an I descriptor which returns a status code of some sort.

George Gallen wrote:
If you a 'C' instead of using 'X' TRANS returns the @ID if the read
   was unsuccessful, my only problem with this was that on occaision
   my data was the same as the @ID, so I couldn't differential between
   the bad read response from TRANS and a good read with data = @ID

I suppose, I could read the whole record, and only if data = @ID
   do a second read wouldn't be too expensive, since it's quite a
minority of the time that would happen.
But either way, 'X' or 'C', unless I actually do an OPEN/READ it will
require a double TRANS to clarify.
George

-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-
boun...@listserver.u2ug.org] On Behalf Of Rick Nuckolls
Sent: Monday, October 11, 2010 4:06 PM
To: U2 Users List
Subject: Re: [U2] Stumped with TRANS...

I do not think that there is a way to test the result of a TRANS to
discover if the read succeeded or was not found.  So, that would leave
the slightly flawed options of a) calling a subroutine or b) using the
itype below (though it does have a problem with a record id of "", or a
value in F1 of 'not found').  What did you want to happen if the record
is not on file?

I doubt that you would, in practice, find much penalty for doing the
TRANS twice on the same record.

Example for a dictionary:

TRANS(transfile, @ID,@ID,'X'); IF @ = '' THEN 'not found' ELSE TRANS(
transfile, @ID, F1,'X')

For Basic:

VALUE = TRANS("TRANSFILE", id, 1, "X")
IF VALUE = "" THEN
        IF  TRANS("TRANSFILE", id, 0, "X") = "" THEN
                VALUE = "not found"
        END
END

But ultimately, either one is flawed if the key is blank.
Is there some reason why you do not want to open the file to named
common?

COMMON /MYSUB/ MYTIME, MYFILE
IF (MYTIME # @TIME ) THEN
        *  new program execution
        OPEN '','TRANSFILE' TO MYFILE ELSE ....
        MYTIME = @TIME
END

(Just as I am about to send this, I see a similar suggestion from Mark
Eastwood.)

Rick Nuckolls
Lynden Inc

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


--
------------------------------------------------------------------------
Jeff Schasny - Denver, Co, USA
jschasny at gmail dot com
------------------------------------------------------------------------
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to