OK, I have a routine that calls a subroutine. There are 2 global variables (string and integer). I go to sub to see if these exist. I check the combo to see if these both exist on a single record. if not, I go to next record. If this combo exists, then true is returned, if not then false. This is using margets DB class, but the problem is weird.
So here's the thing, it increments the integer on every pass of the loop. I did not ask it to do so, but it does.
Here is code with logs. This is workaround. I had to save off integer (TestTrans = ExpTransactionID) and use TestTrans(If ExpEventID2 = db.GetField("DB1_ExpEventID") AND TestTrans = db.GetField("DB1_ExpTransactionID").
So this code works.
Now here is log of working code
......................
0
ExpEventID2=hpt - DB1_ExpEventID=hpt
TestTrans=2 - DB1_ExpTransactionID=1
......................
1
ExpEventID2=hpt - DB1_ExpEventID=wpt
TestTrans=2 - DB1_ExpTransactionID=2
......................
2
ExpEventID2=hpt - DB1_ExpEventID=hpt
TestTrans=2 - DB1_ExpTransactionID=3
......................
Ok, so no let's go back and take out the TestTrans and you'll see that the variable ExpTransactionID gets increments 1 count on every pass.
and now the log. The only thing that changed was the testtrans variable.
Look at the log lines:
ExpTransactionID=1
ExpTransactionID=2
ExpTransactionID=3
......................
0
ExpEventID2=wsop - DB1_ExpEventID=hpt
ExpTransactionID=1 - DB1_ExpTransactionID=1
......................
1
ExpEventID2=wsop - DB1_ExpEventID=hpt
ExpTransactionID=2 - DB1_ExpTransactionID=2
......................
2
ExpEventID2=wsop - DB1_ExpEventID=hpt
ExpTransactionID=3 - DB1_ExpTransactionID=3
......................
See what I mean? Is it me or is ExpTransactionID not supposed to increment each time??? This has been killing me for a week and I finally found the problem. Now I need someone to tell me it's not me.
So here's the thing, it increments the integer on every pass of the loop. I did not ask it to do so, but it does.
Here is code with logs. This is workaround. I had to save off integer (TestTrans = ExpTransactionID) and use TestTrans(If ExpEventID2 = db.GetField("DB1_ExpEventID") AND TestTrans = db.GetField("DB1_ExpTransactionID").
So this code works.
B4X:
Sub LookForEventIDMatch
Dim xx As String
Dim yy As String
xx = db.GetField("DB1_ExpEventID")
yy = db.GetField("DB1_ExpTransactionID")
'-----------------------
'save all vars cause first record will erase them
XFromMainVars 'SR
Dim TestTrans As Int
TestTrans = ExpTransactionID
'-------------------------
'save pointer
Dim OldPointer As Int
OldPointer = db.Record_Pointer
'------------------------------------------------------
db.FirstRecord
Dim Scount As Int
'------------------------------------------------------
For Scount = 0 To db.Record_Count -1
Log("......................")
Log(Scount)
xx = db.GetField("DB1_ExpEventID")
yy = db.GetField("DB1_ExpTransactionID")
Log ("ExpEventID2=" & ExpEventID2 & " - DB1_ExpEventID=" & xx)
Log ("TestTrans=" & TestTrans & " - DB1_ExpTransactionID=" & yy)
'-----WA1
If ExpEventID2 = db.GetField("DB1_ExpEventID") AND TestTrans = db.GetField("DB1_ExpTransactionID") Then
FoundEIDMatch = True
Exit
Else
FoundEIDMatch = False
db.NextRecord
End If
'-----
Next
Log("......................")
'------------------------
'bring pointer back
db.Set_Pointer(OldPointer)
'--------------------------
'return all vars to original areas
XToMainVars 'SR
'----------------------------------------------------
End Sub
Now here is log of working code
......................
0
ExpEventID2=hpt - DB1_ExpEventID=hpt
TestTrans=2 - DB1_ExpTransactionID=1
......................
1
ExpEventID2=hpt - DB1_ExpEventID=wpt
TestTrans=2 - DB1_ExpTransactionID=2
......................
2
ExpEventID2=hpt - DB1_ExpEventID=hpt
TestTrans=2 - DB1_ExpTransactionID=3
......................
Ok, so no let's go back and take out the TestTrans and you'll see that the variable ExpTransactionID gets increments 1 count on every pass.
B4X:
Sub LookForEventIDMatch
Dim xx As String
Dim yy As String
xx = db.GetField("DB1_ExpEventID")
yy = db.GetField("DB1_ExpTransactionID")
'-----------------------
'save all vars cause first record will erase them
XFromMainVars 'SR
Dim TestTrans As Int
'TestTrans = ExpTransactionID
'-------------------------
'save pointer
Dim OldPointer As Int
OldPointer = db.Record_Pointer
'------------------------------------------------------
db.FirstRecord
Dim Scount As Int
'------------------------------------------------------
For Scount = 0 To db.Record_Count -1
Log("......................")
Log(Scount)
xx = db.GetField("DB1_ExpEventID")
yy = db.GetField("DB1_ExpTransactionID")
Log ("ExpEventID2=" & ExpEventID2 & " - DB1_ExpEventID=" & xx)
Log ("ExpTransactionID=" & ExpTransactionID & " - DB1_ExpTransactionID=" & yy)
'-----WA1
If ExpEventID2 = db.GetField("DB1_ExpEventID") AND ExpTransactionID = db.GetField("DB1_ExpTransactionID") Then
FoundEIDMatch = True
Exit
Else
FoundEIDMatch = False
db.NextRecord
End If
'-----
Next
Log("......................")
'------------------------
'bring pointer back
db.Set_Pointer(OldPointer)
'--------------------------
'return all vars to original areas
XToMainVars 'SR
'----------------------------------------------------
End Sub
and now the log. The only thing that changed was the testtrans variable.
Look at the log lines:
ExpTransactionID=1
ExpTransactionID=2
ExpTransactionID=3
......................
0
ExpEventID2=wsop - DB1_ExpEventID=hpt
ExpTransactionID=1 - DB1_ExpTransactionID=1
......................
1
ExpEventID2=wsop - DB1_ExpEventID=hpt
ExpTransactionID=2 - DB1_ExpTransactionID=2
......................
2
ExpEventID2=wsop - DB1_ExpEventID=hpt
ExpTransactionID=3 - DB1_ExpTransactionID=3
......................
See what I mean? Is it me or is ExpTransactionID not supposed to increment each time??? This has been killing me for a week and I finally found the problem. Now I need someone to tell me it's not me.
Last edited: