Sergio,
I just wanted to make sure you (and others on the forum) understood what is happening in your UniVerse code sample because if the logic was used in a multi-user application it could lead to the application code taking a route through the code you didn't want it to follow as no LOCKED clause exists in the READU statement.
In a single user environment, the code would work as the first time it is run, the ELSE clause is taken as the record does not exist and the LOCK is set. The second time through the ELSE clause is taken because the record does not exist and the LOCK is owned by the user running the program. If you moved this logic into a mulit-user environment the ELSE clause can be taken if you timeout on waiting to get a lock. The default timeout is 60 mintues in UniVerse. I can supply an example if required to demostrate the problem if you or others wanted to see that.
In terms of your UniObjects, I have tested here and I cannot reproduce the problem using all the standard tokens in UniObjects. I used the following code in UO to read the record 3 times.
Dim ParseNxt As Integer
Dim RepeatRecord As UniDynArray = Nothing
Dim RecordLocked As Boolean
Dim RecordOnFile As Boolean
For ParseNxt = 1 To 3
RecordLocked = False
RecordOnFile = True
Try
RepeatRecord = VocFile.Read("LISTY")
Catch ex As UniFileException
If ex.ErrorCode = 30001 Then
RecordOnFile = False
End If
MsgBox("LISTY read from VOC failed (UniFile Exception)" + vbCrLf + "Error Number : " + ex.ErrorCode.ToString + vbCrLf + "Error Message : " + ex.Message, MsgBoxStyle.Critical)
Catch ex As Exception
MsgBox("LISTY read from VOC failed : " + ex.Message, MsgBoxStyle.Critical)
End Try
MsgBox("Parse " + ParseNxt.ToString + " On File = " + RecordOnFile.ToString + " Locked = " + RecordLocked.ToString, MsgBoxStyle.Information)
Next
Each time through the loop the ex.ErrorCode contained 30001 (for record not on file) as I would expect with all the default tokens set.
Are you able to share the code you are using to read the record in UO and how you are testing to see if the record is on file.
Thanks,
------------------------------
Jonathan Smith
UniData ATS
Rocket Support
------------------------------
Original Message:
Sent: 03-27-2023 10:05
From: Sergio Perin
Subject: UniObjects
In UniVerse Basic, if we read a record, not present in a file, with locking (after each read the record is not unlocked), it looks like this:
OPEN "VOC" TO VOC ELSE STOP 201,"VOC"
READU RECORD FROM VOC,"LISTY" THEN
CRT "1: [":RECORD:"]"
END ELSE
CRT "1: NOT ON FILE"
END
READU RECORD FROM VOC,"LISTY" THEN
CRT "2: [":RECORD:"]"
END ELSE
CRT "2: NOT ON FILE"
END
READU RECORD FROM VOC,"LISTY" THEN
CRT "3: [":RECORD:"]"
END ELSE
CRT "3: NOT ON FILE"
END
Running program, the result is:
1: NOT ON FILE
2: NOT ON FILE
3: NOT ON FILE
and is as expected, but if we tray this in UniObjects ActiveX o UniObjects .Net, the result looks like this:
1: NOT ON FILE
2: []
3: []
Oops!! The first read is as expected but the next reads return an empty record like exiting for the THEN clause rather ELSE.
If we unlock the record after each read, the result become:
1: NOT ON FILE
2: NOT ON FILE
3: NOT ON FILE
The result is the Basic program.
Another stuff to take into account.
------------------------------
Sergio Perin
Ing.
Self Registered
Buenos Aires AR
------------------------------