Android Question StartServiceAt(Me, Min(NextTimeInstance?

anOparator

Active Member
Licensed User
Longtime User
Code:
Sub Service_Start
StartServiceAt(Me,  Min(NextTimeInstance(8, 01), NextTimeInstance(12, 01)), True
CallSub(Main, "button1_Click")
This instruction helps by eliminating 2 services but gives a 'Too many parameters' error when adding a third NextTimeInstance(17, 01).

What is this 'Min' keyword, and what approach could I take to add 6 time instances to StartServicesAt?
 
Min() only works with 2 arguments

The ugly but effective way for 6 arguments could be nesting the calls (NTIn is NextTimeInstance(...))
Code:
Min(Min(Min(NTI1,NTI2),Min(NTI3,NTI4)),Min(NTI5,NTI6))

or you could also make your myMin Sub passing a list of all the NTIs as a parameter

Code:
Sub myMin( longValuesList as List)as long
   Dim minValue as Long = longValueList.Get(0) 'feed it with an existing value in the list
   for each val as Long in longValueList
      minValue=min(val,minValue)
   Next
   return minValue
End Sub
 
Upvote 0
ugly is good, and I hope this can be done , but:
Code:
Min(NextTimeInstance (8, 01)
refers to 8:01 A.M.
I get 'Invalid number of parentheses' errors no matter what I try.
Am just wanting to give NextTimeInstance 6 seperate event times.
 
Upvote 0
Am just wanting to give NextTimeInstance 6 seperate event times.
You should write a small sub which does the calculation and return just the correct value in this case.

Note that the sub from @JordiCP can handle multiple times... 1, 2, 100
 
Upvote 0
very ugly having 8 or more event_Clicks needed.
 
Upvote 0
what approach could I take to add 6 time instances to StartServicesAt?
You only can set the NEXT occurence.
If you have X times (maybe 6, 8). Calculate the time of the NEXT COMING event and set startserviceat to this time.
If your service running the next time and want the next event. Recalulate it again and again set the startservicdat to the next time it should raise.
 
Upvote 0
You only can set the NEXT occurence.
If you have X times (maybe 6, 8). Calculate the time of the NEXT COMING event and set startserviceat to this time.
If your service running the next time and want the next event. Recalulate it again and again set the startservicdat to the next time it should raise.
I hope I know what is being said, I will make a list of 8 times for my event and increment the time with each Click. (if that is what is meant by 'calculate).
thanks for the pointers.
 
Upvote 0
if that is what is meant by 'calculate
Not exactly.

Try to understand what the sub from @JordiCP really does. Create a list with 8 different times in the future. call the method and check which of them are giving back. Why it is exct this value?
 
Upvote 0
Back
Top