1 (edited by lara.0080 2024-04-04 13:34:04)

Topic: Some question's

Currently, I have this project and I have three questions. Firstly, in the attached program, I want to select a start date and in the second, an end date. Upon pressing the button, I want the program to calculate all the days from the start date to the end date and place them in the 'mymonth' table in 'Dates', with a column for the day, for example, 1 for Monday, 2 for Tuesday, and so on. The second question, I often notice this sentence: form1.menu := nil;. What is its purpose? The third question is about a strange problem that always occurs to me. After working on a specific form, suddenly when I return to it for testing, I find that the buttons or other elements do not work, and the problem is only resolved when I place another object, for example, another button, and put the code inside it. Sometimes, I have to create multiple instances of the same element for one of them to work!! What is the reason for that??? Thanks in advance."

Post's attachments

Attachment icon Thetest.zip 671.21 kb, 20 downloads since 2024-04-04 

Re: Some question's

1.  See attached.
2.  form1.menu := nil is one way to prevent the standard windows menu from appearing on the start form. 
Derek.

Post's attachments

Attachment icon Thetest.zip 671.63 kb, 28 downloads since 2024-04-04 

Re: Some question's


Thank you very much, Derek, but there seems to be a misunderstanding regarding what is needed. I want the days to be listed with the day number of the week, each on a separate line, not to calculate the number of days. I mean, each line should have today's date and the day number in the week, then the next line should follow with the next day, and so on(Since I want to remove some days and each day will have different hours, I want to generate the month and then perform operations on it) . As for the second point, it is very clear thank you . What about the third point, do you think there is a specific reason for that?


i have a strange problem that always occurs to me. After working on a specific form, suddenly when I return to it for testing, I find that the buttons or other elements do not work, and the problem is only resolved when I place another object, for example, another button, and put the code inside it. Sometimes, I have to create multiple instances of the same element for one of them to work!! What is the reason for that?

Re: Some question's

Try it something like this (see attached).
Obviously you'd need to add some sort of error checking to prevent duplicating date ranges.
I'm not sure what the point of having the 'day number' displayed is when you could just show the actual 'day of the week' as part of the date (ie Fri, 05/04/2024) but maybe you need the actual 'day number' for some reason.
I have no idea what causes the problem you mention when working on a form;  as far as I know, no one has ever had any issues like that.  One possible thing might be that you are not pressing 'enter' once you have made a change to an object (for example, if you change it's name) but I doubt it's that.
Derek.

Post's attachments

Attachment icon Thetest2.zip 672.64 kb, 27 downloads since 2024-04-05 

Re: Some question's

Thanks derek for your great support as always

i will tell you why i need the number of day's and tell me if i am wrong please   :


I'm working on an employee program, and this table is a temporary table, meaning that I won't need a mechanism to check for date repetitions because it will be reconstructed as needed. Regarding your mention of(I'm not sure what the point of having the 'day number' displayed), I want day's to appear as a number instead of the days for this ... the reason is simple: this table is for scheduling employees' workdays. If I want to remove weekly off days based on the date, I have to go through each date separately and check all the dates, which is a cumbersome process. However, this way, I can easily remove weekly off days using just numbers! Do you think this mechanism is wrong??? Now, I have another part left, which is how to remove days based on the date from the table. For example, from this date to that date, they must be removed. I'm currently working on this part. In your opinion, am I correct, or not? And this table is actually for reports...

Re: Some question's

Hi,
Have a look at the attached.  Hopefully it is closer to what you have described.
1.  Above the tablegrid is where you specify the range of dates that you want to generate.
2.  Below the tablegrid is where you specify 1) the range of dates you want to delete and / or 2) the 'day number' of the week that you want to delete (for example, to remove all dates that fall on a Sunday, enter 1 then click delete etc etc.
Hope this helps,
Derek.

Post's attachments

Attachment icon Thetest2.zip 674.9 kb, 29 downloads since 2024-04-05 

Re: Some question's

i want to say just one word "wow"
That's amazing 

"The solution is perfect. Now, I will use a checkbox for each day of the week with a Boolean element in the table to mark the weekly holiday, as this will be easier than writing numbers. Dear Derek, you have an amazing solutions; thanks is not enough for you."

You saved me smile 

"Can I ask you a question? How can I be like you in finding solutions?"

Re: Some question's

Why is Sunday the first day of the week?

Destiny

9 (edited by lara.0080 2024-04-06 09:36:50)

Re: Some question's

In SQLite, days are defined based on international standards. Many standards, like ISO8601, consider Monday as the first day. However, in programming traditions, Sunday has been regarded as the first day, as is the case in some countries. The

strftime

function returns the number one for Sunday.

Re: Some question's

As for the history of this, you can read here:
https://www.timeanddate.com/calendar/da … -week.html


As for SQLite, new versions support both Sunday and Monday as the first day.
%u day of week 1-7 with Monday==1
%w day of week 0-6 with Sunday==0
https://www.sqlite.org/lang_datefunc.html


However, for compatibility with previous versions it is better to use %w