hi all i made a stop watch app i want to add seconds to the stop watch while it is running like there will be 2 buttons named 1 and 10 seconds respectively if the user clicks the 1 second button 1 second should be added to the stopwatch and if the user presses 10 second button 10 seconds should be added to the stopwatch
so in the numbers if the user clicks the numbers (1 to 10) that many seconds should be added to the stop watch.. HOW TO ADD THE TIME TO THE STOP WATCH TIME IS MY QUESTION
can it be done like this in the last section(of the block page pic) can we check if the button is pressed we can add the last section and the respective seconds by using the add block?
please try something... everything you need to know is explained in the documentation...
and if you get stuck, post a screenshot of your updated relevant blocks...
AddSeconds( instant , quantity )
Returns an instant in time some seconds after the given instant.
for example the instant in time could be the Clock.Now block and the quantity could be 10
see also again the documentation to understand what is an instant...
Operations on dates and times, such as from DatePicker and TimePicker, are accomplished through methods in Clock. Date and Time are represented as InstantInTime and Duration.
Duration : time in milliseconds elapsed between instants. Duration can be obtained by the Duration method.
Instants are assumed to be in the device’s local time zone. When they are converted to or from milliseconds, the milliseconds for a given Instance are calculated from January 1, 1970 in UTC (Greenwich Mean Time).
hi! can you say me the solution for my problem I already asked but i didnt get proper answer from the article you sent..my problem is when the user clicks the start button the stopwatch should run it is running perfectly and for example its 10 seconds there will be a number keypad layout which has 1,2,3,4 etc numbers buttons on it so when the user clicks on number 1 button 1 second should be added to the stopwatch like if it is 10 seconds immediately when the user taps the number button it should show 11 seconds and continue like that and when the user presses the number 5 button 5 seconds should be added to stopwatch seconds.. FOR PICS REFER THE POST HOW TO ADDING SECONDS TO A STOPWATCH WHILE ITS RUNNING
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.
To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.
up to now unfortunately you did not try anything...
you might want to use the AddSeconds method as already mentioned and provide an updated screenshot of your blocks...
great to hear
please provide the solution to the problem then…
this community is to help each other…
and your answer can help others with the same issue in future… thank you…
in the button click blocks i didnt take a snap of two other button but the function are the same as button N1 and like..
and variable (k1 to k10) it is intialized as blank
Regarding the resetting problem, that stems from the data flow.
The data flows from global start_time, and everything downwards in the Clock Timer derives from that.
So that's what you should adjust:
To add to your time, move the start_time back in time by adding a negative duration to it.
@Anke yes this is the thing i want can you say instead of 3 buttons(5,8,10) how to keep 10 buttons(1 to 10)..also in designer page only a label , start btn , stp btn , numbers btn and only clock component in needed right or anything should be added?
by the way thanks for solving my problem