@muneer alright, I have implemented all these procedures, however, when I run the app, Thunkable crashes. I think this may have to do with the iteration of functions. I will show each function in the process:
I’m out now and would not be able to see the project before this evening.
One quick way to locate the error is to add a label to the screen and in the screen opens event add a text to that label prior to each function and a wait block to see what stage you are.
This way you will focus your efforts in the problem block not all the blocks.
If you’re interested in the days between 2 dates can’t you use that trick of calling an api that calls a Javascript to do that? or cinvery both dates to millisecond since 1970. Take the difference and convert to date? Or is the problem about parsing a manually entered date? Then it’s a challenge. Unless there’s already an api that does only that.
: convert a human entered date to task date.
No, it’s not.
I already designed a function to convert a seconds since 1970 to human date. As you know the first round you are focused in logic to performance. So I have it working but need to enhance it further.
Hi @muneer . I am thinking about how to best implement the for loop in these procedure. I think this may be the cause for the app instability. Currently, I have implemented the loop in the last procedure:
Currently, the app will not crash when the screen is opened. However, if you navigate throughout the app and then return to the screen, Thunkable crashes. I have tried to implement this for loop throughout the procedures but nothing has resolved the issue.
Moreover, I tried your suggestion of printing values to a label in each function. This helped with fixing some of the logical errors in my code. Thanks for the tip.
Anyways, any suggestions on how I can improve app stability would be much appreciated. Here is the link:
i think daysInGiverDate is mixing apples and oranges because it’s adding year and days together. for computing date differences between dates in the same year, it might work, but will fail when the years are different.
i think you should use the daysInUnixDate variable (unixdate / 86400) format as the base for subtracting dates. this is really the # of days since 1/1/1970.
if you get two dates into this format, just subtract them and you get the difference in days.
the challenge i was referring to was the conversion from standard date (year, month, day) to unixdate . the # of days since 1/1/1970 can be derived from there.
I can do this easily. If you like the idea in the sample project then we can, maybe, work together and design the reverse to convert from year, month, day to Unix timestamp.
Thanks @muneer for noticing this. I think I may have sent you an outdated link as I actually did notice that issue and resolved it:
The conditions are now working (I still need to refine them). However, there is still a major issue with app stability. It is prone to crashes quite a lot which I believe is down to the for loop. Any suggestions would be much appreciated.
@muneer please ignore my previous replies, I have an update. The procedures are now working smoothly and the app stability has been improved. The crashes were due to the functions being called simultaneously at different point in the code. There is one final thing I would like to implement.
Currently, the code parses the dates and adds a label when the screen is opened and when an assignment is added. However, this is a problem as the for loop implemented within the function keeps adding the label every time when either of these events occurs. Therefore, would it be possibly to implement a condition that only adds the label to assignments without one? Additionally, the labels would need to be updated once the current date changes. Any suggestions on how to do this? Here is the link:
You can do something similar to the function All Filled.
Create a function to receive the text entry as its parameter and check that none of the status wordings is available and return true or false according to the situation then you only process the ones that are not processed yet.
That sounds like a great idea @muneer . One thing, how would make it so that the list items are indeed processed when the current date changes? If the user’s task contains the label ‘Due today!’, how would the code update the label to ‘Overdue’ once the due date has passed?
The procedure is not working though. I think this may be due to the fact that the ‘compare dates’ function is a for loop and is calling the other ‘check due date status’ function which is also a for loop. I am not too sure. Any suggestions would be much appreciated.
You need only the IF conditions without the loop. You will check the condition before updating the status and if status is available then remove it along with the new line character prior to it.
This procedure worked fine when I did not add a parameter to the function but I want to add a parameter so I can pass in different variables. Any idea on what could be causing this?
i found an article (written by Victor Vogelpoel in 2002!) that shows how to convert year-month-day to excel serial date and back. it’s pretty cool! it only takes a little adjustment to make it work for unix dates. i translated it to thunkable and it works!
right now it recognizes unix dates in milliseconds, but you can convert them to days by dividing by 86400. the calendar date needs to be entered as in 2021-12-31 (hyphens between the parts).
this is the time we need a function in thunkable IDE to be able to “textify” (convert to text) blocks AND a reverse function to “blockify” the text back to blocks. this would eliminate the re-typing we have to do when we want to bring a subroutine into our program. just wishful thinking. or better yet, if we only had a way of building thunkable libraries!
@muneer , is there a way of passing a parameter like I tried to do above? This is because when the user deletes an assignment, the assignment is archived. I would therefore like the due date status to be removed from archived assignments. I could use this function and pass in ‘item’ as ‘assignment’ when a list item is clicked.
The only issue is that it is not being completed as outlined above. When I pass in ‘j’ (the list item), it is not being processed by the function. Any idea why this could be occurring?