If operator statement screw up

Desktop Mac.
This statement is in the open event in a window. AdCardList is a Listbox
AdCardList.SelectedRowIndex = If( LstIntRow > -1, LstIntRow, 0 )
The above statement is not resetting SelectedRowIndex. SelectedRowIndex was -1 before this. LstIntRow is 0.

I restarted my Mac in case it had been up for too long.

From what I understand SelectedRowIndex should be 0

I also broke the if operator statement into traditional and it still doesn’t get set.
If LstIntRow > -1 Then
AdCardList.SelectedRowIndex = LstIntRow
AdCardList.SelectedRowIndex = 0
End If

Have you stepped through this code in the debugger?

Yes. That’s how I got values.

Do you expect the AdCardList.SelectedRowIndex to set it to NoSelection ?
Listbox has a Constant available called AdCardList.SelectedRowIndex = AdCardList.NoSelection
which is equal to -1

AdCardList.SelectedRowIndex = 0

Would just set the first row selected.
Not sure what you expect the outcome to be.

Apologies. It works correctly (I assume). I had moved the filling of the list to a separate method and Control-Z removed the callout. Sometimes improvements are a pain.

I dislike the Inline If statement because they are hard to debug. It’s not like you can put a breakpoint in the true or false part and see when things happen. There is a time and place for the Inline If but my experience says not to use it unless absolutely necessary.

Agree, but either way, "If is not broken". :slight_smile:

I agree. They are good if conditions are simple and results have one line. They also have to be fool proof. Yes I do mean fool as in idiot proof.
Unfortunately our Control-Z undo isn’t also fool-proof. You suddenly find some weird error because you hit undo too many times. It is better than it used to be. Most of the time it will go to the page you undid, but then. Sigh. It’s much better than it used to be.