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: [email protected] [mailto:u2-users- > [email protected]] 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 [email protected] http://listserver.u2ug.org/mailman/listinfo/u2-users
