A project with a ListBox, a TextField and two PushButtons is really unstable.
Either the ContextualMenu or the MenuItems that does the same thing stays doing nothing, sometimes.
Sometimes an Exception occured.
Running the project a second time changes nothing.
That was yesterday. Today, it worked on the first run (a reboot occured in between), but I changed nothing to the code.
The project was born with API I, changed to API II solme times ago. *
I still have some work to do in the convert because some features stop on Row before the end / do not works at all (crash) because of the difference 1-based, 0-based…
Beside checking from where the exception occured (I do not remember what exception it was), do you have reached this kind of behavior / have ideas ?
What do the project when this happens ?
Essentialy looking at two columns (start date, end date), compute the ellapsed time in days and report the result in the next column.
You do understand that this is what exceptions are all about, right? The whole point of wrapping code in a try-catch is to handle the times when you code doesn’t do what you asked, the exception to the rule.
So yes, we do need to see your code to truly help, or just wrap your code in a try-catch and handle the exception or ignore it.
The project work fine with the same text file, OR get an Exception (probably OutOfBoundsException).
That is what I think the code MAY not be involved.
Next time (when ?), I will make a screen shot of the error message and try to analyze the problem (add a refresh for each Row change so I can know when in the text the crash occured but I have doubts).
on the beginning, minutes ago, I wanted to set the Stories length having a submenu with the two entries below in the screen shot.
Then I recall that yesterday I do not saw the colors, and so I changed the search reason.
NB: this project were born with API 1.
I will change what I found to be API 2 compliant now.
The problem comes when I use the ContextualMenu to fire a method who analyze a ListBox contents loaded from a text file.
This arise once more earlier today.
I get a friend visit while debugging and I let the laptop alone. After some times I saw something happens in the screen but I do not touched it not the Mouse.
A window owned by TextEdit appears at frontmost window (my project window) -1, so not frontmost, but an another window was there (the help window, I suppose.
This confirm (IMHO) that I have troubles in macOS or the SSD. I will try asap to install Tahoe on an external SSD and do what have to be done with the internal SSD / system.
Before someone chime in with that suggestion, yes I used Disk Utilities. No error was reported.
And, I still have the Stocks application that appears when I fire another application. I kill it, but it comes back when I run a project (but this is not related to Xojo; it is related to an application launch).
I checked that code because the problem arise wqhen I use a Contextual Menu / and … when I implemented the two “Strips” MenuItems, I do not took time to check how to add a MenuItem with Submenus, so today was the day to fix that (done).
I realized that I stayed with MenuItems vs API 2 (the project is meants to be API 2) everywhere else (I hope and do not want to mix both API).
I fired the project as is, loaded the same text file, asked to add the number of days between two columns and report in a third one WITH SUCCESS (no OutOfBoundsException).
Something is wrong and I do not think at what it can be !
Code provided by Sascha (CountDaysWithOrWithoutSundays in this Forum) and it is a Method.
I was unable to get the error in the last two hours.
PS: I found another, unrelated, bug in the "Set Background Color" code: I use the SubMenu name instead of the Color Names…
I wonder how that was working in API 1…
Apparently I refactored simple entries with many colors into a SubMenu and never finished it. That is why it does not works “now”.
That is why the Case "Set Background Color" is skipped at debug time (I followed the running…
That was untested Code I changed a few things this morning (after reading your reply here):
Public Function CountDaysWithOrWithoutSundays(startDate As DateTime, endDate As DateTime, Optional WithoutSundays As Boolean = False) As Integer
// Check is startDate is before endDate
If startDate > endDate Then
Return 0 // or report an error, if startDate is later than endDate
End If
Var countedDays As Integer = 0
If WithoutSundays Then
While startDate < endDate
// check if current day is no sunday (weekday 1 in Xojo)
If WithoutSundays Then
If startDate.DayOfWeek <> 1 Then countedDays = countedDays + 1
End If
// Advance 1 day
startDate = startDate.AddInterval( 0, 0, 1 )
Wend
Else
countedDays = (endDate.SecondsFrom1970 - startDate.SecondsFrom1970) / 86400
End If
Return countedDays
End Function
It was used (tested if you prefer) since you shared it on daily basis (Dailies, never Sundays), then I added the call to get also the number of Sundays (just a matter of True / False in the calling, but I do needed only the dailies for some times and added a call with the other value to get the number of Sundays).
To be short: your code was working.
Going to your code was having troubles. The trouble comes before the call to your shared code.
Unfortunately, I have another troublesome on the same project, and this is not related to the Search window.
This is converted to API 2 in a (now) running Xojo 2025r2.1
The trouble: I am unable to Paste a Text to the SearchField.
Copy the Text typed in the SearchField, tried to Paste does not works (no text).
I add another DesktopSearchField in the Search Window and Paste does not worked.
Everything is DesktopXxxx (the window/ the SearchField), the Window MenuBar is correct too.
I searched in the project where there is code to my SearchField: only in MouseUp. And I checked each line.
Cmd-V hilight the Edit Menu (so the command is activated)
Even using Paste in the MenuBar does not POaste the text.
I searched in Issues and see a project (to demonstrate some other bug) and downloaded it, run it, Paste works fine in the SearchField.
I created a new project, add a SearchField and run it: works fine.
I Save As… / Close the project / Load it and see what happens: I get the same result.
Save to XML is no more possible ! Or I really really have eye troubles too…
Must I create a new project and Copy Paste the current elements to the new project ?
Should I light a candle in my church?
I lack ideas except throw througth the window (the computer since I cannot do that with Xojo but it is not possible (these windows are locked at my local McDonald’s where I am), fortunately.
This project was started as API 1 and converted to the current version (2025r2.1), everything Desktop (I checked).
The tests were done on MBPro 13" M1 running Tahoe 26.1.
I added a TextField to the window, Copy KeyUp, Paste it in the TextEdit (Navigator), run, it works file, my Results ListBox is filled (with wrong information, but this is a work in progress).