anOparator Active Member Licensed User Longtime User Jun 30, 2016 #1 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?
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?
JordiCP Expert Licensed User Longtime User Jun 30, 2016 #2 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
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
anOparator Active Member Licensed User Longtime User Jul 1, 2016 #3 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
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.
DonManfred Expert Licensed User Longtime User Jul 1, 2016 #4 anOparator said: Am just wanting to give NextTimeInstance 6 seperate event times. Click to expand... 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
anOparator said: Am just wanting to give NextTimeInstance 6 seperate event times. Click to expand... 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
anOparator Active Member Licensed User Longtime User Jul 1, 2016 #5 very ugly having 8 or more event_Clicks needed. Upvote 0
anOparator Active Member Licensed User Longtime User Jul 1, 2016 #6 DonManfred said: 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 Click to expand... oh , OK , will try that Upvote 0
DonManfred said: 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 Click to expand... oh , OK , will try that
DonManfred Expert Licensed User Longtime User Jul 1, 2016 #7 anOparator said: what approach could I take to add 6 time instances to StartServicesAt? Click to expand... 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
anOparator said: what approach could I take to add 6 time instances to StartServicesAt? Click to expand... 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.
anOparator Active Member Licensed User Longtime User Jul 1, 2016 #8 DonManfred said: 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. Click to expand... 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
DonManfred said: 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. Click to expand... 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.
DonManfred Expert Licensed User Longtime User Jul 1, 2016 #9 anOparator said: if that is what is meant by 'calculate Click to expand... 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
anOparator said: if that is what is meant by 'calculate Click to expand... 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?
Erel B4X founder Staff member Licensed User Longtime User Jul 1, 2016 #10 Check this example: https://www.b4x.com/android/forum/threads/b4x-calculating-the-next-scheduled-time.65041/#content Upvote 0
Check this example: https://www.b4x.com/android/forum/threads/b4x-calculating-the-next-scheduled-time.65041/#content