View Full Version : calendar program
sandyrepope
21-11-2007, 05:34
My calendar program. I hope someone finds this useful.
Thanks
Sandy
adding updated version.
Sandy you are smoking with all these cool releases, thanks.
Possible additions:
It would be nice to have a next and previous month button to quickly flip through the months.
It would be nice to have buttons to flip through the days too.
Also an outline or subtle color to show days with notes in the calendar.
Michael Clease
21-11-2007, 10:08
Brilliant I really like this it reminds me of something we use at work.
If you want to make your script smaller try this to replace all the button checks with this.
case %WM_COMMAND
'---Test which control has been clicked
For n = %ID_BUTTON+1 to %ID_BUTTON+42
If LOWRD(wParam) = n THEN
control get text hDlg, n TO Button_Clicked
if Button_Clicked <> "" then Day_Clicked
end if
NEXT
SELECT CASE lowrd(wParam)
'---Something has happened with %Combo01
ErosOlmi
21-11-2007, 12:03
Sandy,
nice, nice, nice!! :o
Here my little contribution. In %WM_INITDIALOG event, after all your code, add the following lines. Will transform notes part more dynamic:
control set resize hDlg, %ID_TXTBUFFER, 1, 1, 1, 1
control set resize hDlg, %ID_LISTBUFFER, 0, 1, 1, 1
control set resize hDlg, %save_notes_button , 0, 1, 0, 1
control set resize hDlg, %clear_notes_button, 0, 1, 0, 1
control set resize hDlg, %delete_note_button, 0, 1, 0, 1
Thanks
Eros
PS: I will try to add a new command in UI module in order to constrain window size to a minimum. In this way controls will not overlap when window is resized.
Petr Schreiber
21-11-2007, 14:48
Hi Sandy,
this program is very nice!
I am sure I will use it from Today, at least I will forgot less things :)
Idea for improvement - days which have some notes could have different color, so I could see where to seek for things I forgot to do :)
Thanks,
Petr
sandyrepope
21-11-2007, 17:24
First of all, I'd like to thank everyone for their comments and suggestions. They are appreciated.
Abraxas.
case %WM_COMMAND
'---Test which control has been clicked
For n = %ID_BUTTON+1 to %ID_BUTTON+42
If LOWRD(wParam) = n THEN
control get text hDlg, n TO Button_Clicked
if Button_Clicked <> "" then Day_Clicked
end if
NEXT
SELECT CASE lowrd(wParam)
'---Something has happened with %Combo01
I noticed that there are two if statements but only one end if. Having never used an if on a single line I was wondering if it doesn't need an end if if it is on a single line?
Kryton9.
Possible additions:
It would be nice to have a next and previous month button to quickly flip through the months.
It would be nice to have buttons to flip through the days too.
Also an outline or subtle color to show days with notes in the calendar.
I agree that the next and previous month buttons would be nice. It also would be nice to have the days marked with some color or something when the month is displayed.
I'm not sure what you are suggesting about flipping through the days too. Do you mean like next and previous buttons for the days?
Eros.
PS: I will try to add a new command in UI module in order to constrain window size to a minimum. In this way controls will not overlap when window is resized.
This would be so nice to have. I would appreciate it a lot!
Psch.
Idea for improvement - days which have some notes could have different color, so I could see where to seek for things I forgot to do
The color idea is really nice. I've got it on my list of things to do.
Thanks
Sandy
Petr Schreiber
21-11-2007, 18:56
Hi Sandy,
regarding your confusion with 2 IFs and one END IF.
In case you need to execute more statements depending on condition, you should use:
IF something THEN
doSomething1
...
doSomethingN
END IF
... but in case you just need to do one action, you can use single line IF/THEN syntax, which does not need END IF, like:
IF something THEN doSomething
To put it simply - if after THEN word there is no statement on the same line, then statements must follow on next lines and end with END IF, else you do not need END IF.
Bye,
Petr
Michael Clease
21-11-2007, 20:19
The calendar we use at work is from http://www.keepandshare.com a web based community thing.
a screen shot
http://keepandshare.com/graphics/calendar/cal_week_view.jpg
One Idea I just had was If you wanted to do it like this you could make each day a new window with a textbox rather than a button.
Michael Hartlef
21-11-2007, 22:06
Great job. A little improvement could be to ask to save a new/changed note if you wanna to switch the day and forgot to save.
ErosOlmi
21-11-2007, 22:20
... yes, and even better if not necessary to ask but just always save ...
Asking too much is nice at first but boring after a while.
ErosOlmi
22-11-2007, 00:21
Eros.
PS: I will try to add a new command in UI module in order to constrain window size to a minimum. In this way controls will not overlap when window is resized.
This would be so nice to have. I would appreciate it a lot!
Sandy,
next preview will have the following command:
dialog set resize hDlg, MinWidth, MinHeight
So just after creating the new dialog or when needed, calling the above command will limit the minimum size of the window when resizing.
I think I will release it by tomorrow evening.
Ciao
Eros
sandyrepope
22-11-2007, 01:05
Eros, Thank you for the new command. I'll check it out soon after the new preview is out.
Concerning Michael's suggestion about saving when changing days. I think he meant that the program should ask to save only if the note is changed. Although I like the idea I don't know if this can be done. I'll have to check it out and see.
Petr
Thanks for the explanation. Although I prefer the type that uses the end if now when I see the one line if statement I'll know that it is ok.
Abraxas
I'm really impressed by the screen shot. I don't know if I know enough to be able to make a version like this but I'll see if I can figure out how it's done. It will take me a while.
Thanks
Sandy
ErosOlmi
22-11-2007, 01:12
For a quick test copy attached thinBasic_UI.dll into your thinBasic\Lib directory replacing your current one.
After that you will be able to use new command. Attention, min limits are referring to client area and not to window size (client area is the one inside a window expluding borders and caption). I will try to change this behave in future versions.
Let me know
Ciao
Eros
Michael Clease
22-11-2007, 01:52
Sandy here is a solution as to when to save or not.
Dim TxtStatus as LONG ' This is the status flag.
'1 = TextBuffer Changed. Remember to reset to 0 when saved.
CASE %ID_TXTBUFFER
SELECT CASE HIWRD(wParam)
case %EN_CHANGE ' has the buffer changed.
TxtStatus = 1
end select
So some simple checking and resetting of TxtStatus would provide information if the textbuffer has changed.
Sandy, about the months and days, yes, buttons to go to next and previous for each. The reason being... if I have note for a certain day, but days on either side might have notes, it would make it easy to scan through the days and to quickly see the notes. The same of course for going month to month.
For days with notes, just a different shade for the day would be nice to indicate a note is saved for that day.
I agree with others, just auto save the notes.
You have developed a program that is very nice and useful!!
Petr Schreiber
22-11-2007, 09:13
Eros,
if the command should set minimal size allowed, why not call it DIALOG SET MINSIZE ?
RESIZE sounds to me less clear, but maybe just because I went to bed too late and woke up too early :)
Thanks for new feature!
Petr
ErosOlmi
22-11-2007, 11:36
Agree Petr.
I used RESIZE bacuse it is a keyword already defined but effectively it is not clear.
OK, I will add MINSIZE keyword.
sandyrepope
30-11-2007, 03:20
Ok. I updoaded an updated version. (see first post). I've added some features that were suggested. I hope I got all the important ones in. If I forgot any, please, just post a reply letting me know.
Any comments are welcome and appreciated.
Thanks
Sandy
Sandy very nice.
Only one minor thing... the year shows 2008 and if I keep going through the months... you never see the year updated to reflect the year.
Other than that.. really nice to flip through quickly and to see which dates have notes with the highlighting!
Petr Schreiber
30-11-2007, 13:09
Hi Sandy,
very nice, thanks a lot for the update!
I like sympatic color for days with some notes, really good job!
Petr
sandyrepope
30-11-2007, 16:57
Only one minor thing... the year shows 2008 and if I keep going through the months... you never see the year updated to reflect the year.
I thought I'd caught this bug.... I'll check it out asap and see what I can do.
Thanks
Sandy
ErosOlmi
30-11-2007, 19:20
Sorry guy but I forgot to add promised MINSIZE keywords in current preview.
I will do in next one.
Ciao
Eros
ErosOlmi
30-11-2007, 20:03
Sandy,
I've noticed that some button equates have the same control ID.
For example
%delete_note_button = 303
%Change_flagcolor_button = 303
This is very dangerous and can bring unpredictable results because the wrong command can be fired for the right button and the other way round.
Every control id must be unique on the same dialog.
Ciao
Eros
sandyrepope
30-11-2007, 23:17
I've managed to find the bug about the year not changing. In an if.. then loop I used a 'less than' sign when it should have been a 'greater than' sign. It's corrected and will be in the next update.
I've noticed that some button equates have the same control ID.
For example
%delete_note_button = 303
%Change_flagcolor_button = 303
This is very dangerous and can bring unpredictable results because the wrong command can be fired for the right button and the other way round.
Every control id must be unique on the same dialog.
This will be corrected in the next update.
Big thank yous to everyone for helping me with this.
I must admit that I don't really like having to use the os_shellexecute but I haven't been able to find another way to do the color change utility yet. I think I could put the entire script in a function IF there were a way to let thinbasic know about the functions at the first of the main script. If there were some kind of DECLARE statement that could go at the first of the script then it would know about functions that are contained in a function.
Thanks
Sandy
ErosOlmi
30-11-2007, 23:23
Sandy,
sorry but I do not understand what you are asking. Can you give a little more details?
Trying to guess ...
functions can be placed anywhere in thinBasic scripts, before or after their usage. thinBasic autodiscover them during pre-parsing process just before execution time. But I'm not sure if I'm answering to your question ???
Ciao
Eros
sandyrepope
30-11-2007, 23:54
What I was trying to do is have everything in one script. I tried putting the color changing utility in a function in the month calendar script but when I ran it none of the functions within the function containing the utility were recognized as functions.
I'll try to get together a simple script to show what I mean sometime today.
Thanks
Sandy
sandyrepope
01-12-2007, 02:09
The v3 update is now in the first post.
sorry but I do not understand what you are asking. Can you give a little more details?
Trying to guess ...
functions can be placed anywhere in thinBasic scripts, before or after their usage. thinBasic autodiscover them during pre-parsing process just before execution time. But I'm not sure if I'm answering to your question
Here is an very simple script to give you an idea of what I'm talking about.
uses "UI"
%launch_button = 100
%a_button = 101
dim Z as long = 1
DIM hDlg AS DWORD, hImg AS DWORD, x AS DWORD, Y AS DWORD
dim Msg, wparam,lparam as dword
DIALOG NEW 0, "thinBASIC", -1, -1, 260, 240, _
%WS_DLGFRAME OR _
%DS_CENTER OR _
%WS_CAPTION OR _
%WS_SYSMENU OR _
%WS_OVERLAPPEDWINDOW, _
0 TO hDlg
control add button, hDlg, %launch_button, "CLICK ME", 5, 5, 50, 50
'control set color hDlg, %launch_button, -1, rgb(0, 0, 0)
DIALOG SHOW modeless hDlg
while isWindow(hDlg)
Msg = GetMessage(hDlg, wParam, lParam)
select case Msg
case %WM_COMMAND
SELECT CASE wParam
case %launch_button
Launch_it()
end select
CASE %WM_SYSCOMMAND
SELECT CASE wParam
CASE %SC_CLOSE
EXIT WHILE
END SELECT
END SELECT
wend
DIALOG END hDlg
function Launch_it()
msgbox 0, "made it"
if Z = 1 then
Working()
else
exit function
end if
function Working()
msgbox 0, "inside function"
end function
end function
I'm attaching the error message I get from this script.
Thanks
Sandy
Sandy, thanks version 3 is working fine. Very nice features and very quick to flip through the months to see what is where. Great job!
ErosOlmi
01-12-2007, 09:47
Sandy,
ok, now I've got it.
Functions inside functions (nested functions) is a concept not present in thinBasic. So you cannot nest a function inside another. Pascal has this concept.
Here your example again:
uses "UI"
%launch_button = 100
%a_button = 101
dim Z as long = 1
DIM hDlg AS DWORD, hImg AS DWORD, x AS DWORD, Y AS DWORD
dim Msg, wparam,lparam as dword
DIALOG NEW 0, "thinBASIC", -1, -1, 260, 240, _
%WS_DLGFRAME OR _
%DS_CENTER OR _
%WS_CAPTION OR _
%WS_SYSMENU OR _
%WS_OVERLAPPEDWINDOW, _
0 TO hDlg
control add button, hDlg, %launch_button, "CLICK ME", 5, 5, 50, 50
'control set color hDlg, %launch_button, -1, rgb(0, 0, 0)
DIALOG SHOW modeless hDlg
'------------------------------------------------------
' Main loop
'------------------------------------------------------
while isWindow(hDlg)
Msg = GetMessage(hDlg, wParam, lParam)
select case Msg
case %WM_COMMAND
SELECT CASE wParam
case %launch_button
Launch_it()
end select
CASE %WM_SYSCOMMAND
SELECT CASE wParam
CASE %SC_CLOSE
EXIT WHILE
END SELECT
END SELECT
wend
DIALOG END hDlg
'------------------------------------------------------
function Launch_it()
'------------------------------------------------------
msgbox 0, "made it"
if Z = 1 then
Working()
else
exit function
end if
end function
'------------------------------------------------------
function Working()
'------------------------------------------------------
msgbox 0, "inside function"
end function
Here another version where even the main while/wend loop is inside a function named Main and called at the beginning of the script:
uses "UI"
'------------------------------------------------------
' Global Variables amd equates
'------------------------------------------------------
%launch_button = 100
%a_button = 101
dim Z as long = 1
DIM hDlg AS DWORD, _
hImg AS DWORD, _
x AS DWORD, _
Y AS DWORD
DIM Msg , _
wparam , _
lparam as dword
'------------------------------------------------------
' Call Main script function
'------------------------------------------------------
Main
'------------------------------------------------------
' Script functions
'------------------------------------------------------
'------------------------------------------------------
function Main() as long
'------------------------------------------------------
DIALOG NEW 0, "thinBASIC", -1, -1, 260, 240, _
%WS_DLGFRAME OR _
%DS_CENTER OR _
%WS_CAPTION OR _
%WS_SYSMENU OR _
%WS_OVERLAPPEDWINDOW, _
0 TO hDlg
control add button, hDlg, %launch_button, "CLICK ME", 5, 5, 50, 50
'control set color hDlg, %launch_button, -1, rgb(0, 0, 0)
DIALOG SHOW modeless hDlg
'------------------------------------------------------
' Main loop
'------------------------------------------------------
while isWindow(hDlg)
Msg = GetMessage(hDlg, wParam, lParam)
select case Msg
case %WM_COMMAND
SELECT CASE wParam
case %launch_button
Launch_it()
end select
CASE %WM_SYSCOMMAND
SELECT CASE wParam
CASE %SC_CLOSE
EXIT WHILE
END SELECT
END SELECT
wend
DIALOG END hDlg
end function
'------------------------------------------------------
function Launch_it()
'------------------------------------------------------
msgbox 0, "made it"
if Z = 1 then
Working()
else
exit function
end if
end function
'------------------------------------------------------
function Working()
'------------------------------------------------------
msgbox 0, "inside function"
end function
Hope I replied to your question now.
Ciao
Eros
sandyrepope
01-12-2007, 17:07
Functions inside functions (nested functions) is a concept not present in thinBasic. So you cannot nest a function inside another.
I didn't realize this. I understand now. Thanks for the answer.
Sandy
Petr Schreiber
08-03-2008, 10:49
Hi,
here is unofficial v4, fixing MOD operator issues
Petr