Stephen Wintle
(Seasoned Scripter)
2012-01-06 01:23 PM
Wallpaper daily counter down

Hi folks, and happy new year.

I wonder if any of you out there could give me some pointers, the Head at the School where I work has asked if we could have a count down message appear on pupil desktops to tell them the number of days to go before a certain date (the Exams). I have used BGinfo in the past to display messages to users, is there a way we can do this with KIX/BGinfo?

Regards,


AllenAdministrator
(KiX Supporter)
2012-01-06 02:57 PM
Re: Wallpaper daily counter down

It's been like forever and a day since the last time I used BGInfo, so I had to look up its options ( http://technet.microsoft.com/en-us/sysinternals/bb897557 )It seems like to me you would just need to add a custom field that was would be used for a kix calulation. Assuming that the import file is text, open the file in kix, add the custom field with the calculated date, and save the changes. Then you would rerun the bginfo either by task scheduler or admin script to re-import the settings file.

I use serialdate for this type of thing... something like

$daystoevent=serialdate($eventdate)-serialdate(@date)

SerialDate -
http://www.kixtart.org/forums/ubbthreads...=true#Post82573


How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1


Glenn BarnasAdministrator
(KiX Supporter)
2012-01-06 03:05 PM
Re: Wallpaper daily counter down

Greetings!

BGInfo allows you to create a custom attribute. This can be the contents of a file or an environment var, among other options. Kix can easily create either - just make sure bginfo is called after Kix updates the value.

You can use one of the timediff() UDF to easily return the number of days between dates.. for example, if the exams start on Feb 15, 2010, you would run
 Code:
$Days = TimeDiff('2/15/2012', 'Today', 'D')
Save the result, along with any other message, to a file or environment var
 Code:
$ = RedirectOutput('C:\Temp\countdown.txt')
Int($Days) ' days before start of exams!'
$ = RedirectOutput('')
I tested this with BGInfo and the custom File attribute. The Int() is required because the TimeDiff will return the fractional day part.

Glenn


Stephen Wintle
(Seasoned Scripter)
2012-01-06 03:53 PM
Re: Wallpaper daily counter down

Many thanks ill get to work on this now, I shall let you know how I get on!

Stephen Wintle
(Seasoned Scripter)
2012-01-06 03:55 PM
Re: Wallpaper daily counter down

Of course it doesn't have to use BGinfo if Kix can be used to do it all. Cheers.

Mart
(KiX Supporter)
2012-01-06 05:02 PM
Re: Wallpaper daily counter down

 Originally Posted By: Stephen Wintle
Of course it doesn't have to use BGinfo if Kix can be used to do it all. Cheers.


Kix cannot display text on the user’s desktop without it being some kind of window like a command window, a custom made window using kixforms, etc... If you want it as text over the user’s desktop background then bginfo works fine. Been using it for some time and I do not have any complains yet.

A custom value like Glenn suggested should do the trick. It is not dynamic but it refreshes the value with whatever is in the text file every time the background is applied by BGInfo. If you want something dynamic then I suggest using a desktop gadget.


LonkeroAdministrator
(KiX Master Guru)
2012-01-06 05:32 PM
Re: Wallpaper daily counter down

hmm...
with a bitmap background kixtart might be able to do the trick too.


Mart
(KiX Supporter)
2012-01-09 09:10 AM
Re: Wallpaper daily counter down

 Originally Posted By: Lonkero
hmm...
with a bitmap background kixtart might be able to do the trick too.


Really?
Can you post an example?


LonkeroAdministrator
(KiX Master Guru)
2012-01-09 09:29 PM
Re: Wallpaper daily counter down

nope. I did read on it a bit...
kixtart just can't handle the char(0) that is required to do any kind of real "work" on "real files"


It_took_my_meds
(Hey THIS is FUN)
2012-01-10 03:46 AM
Re: Wallpaper daily counter down

Actually you can if you use Adodb.Stream and a reference binary file.

Stephen Wintle
(Seasoned Scripter)
2012-01-11 05:26 PM
Re: Wallpaper daily counter down

Hi Guys and thanks for the replies, it seems the solution is going to be a bit more complex than first thought, I have got BGinfo working and displaying a message etc. But I need to chop off weekends, holidays etc to calculate the actual working (school) days...

Ouch.


Stephen Wintle
(Seasoned Scripter)
2012-01-11 05:54 PM
Re: Wallpaper daily counter down

Hi, I need to calculate number of working days between to dates, (so miss weekends and holidays) looking at the Datecalc UDF is this possible? Then can I use a custom field in BGinfo to somehow automatically reduce the number by one?

The goal posts have moved.. \:\(


AllenAdministrator
(KiX Supporter)
2012-01-11 05:59 PM
Re: Wallpaper daily counter down

Using serialdate...
I am sure this could be golfed to death, but this should be very direct

break on
 
$excludeddates="2012/01/01,2012/01/07,2012/01/08,2012/01/14,2012/01/15,2012/01/21,2012/01/22,2012/01/28,2012/01/29" $eventdate="2012/01/31" $today=@date
$days=serialdate($eventdate)-serialdate($today) ? "Total Days: " + $days
for each $date in split($excludeddates,",") if serialdate($date)>serialdate($today) $days=$days-1 endif next ? "Days, excluding Holidays and Weekends: " + $days


Stephen Wintle
(Seasoned Scripter)
2012-01-11 06:09 PM
Re: Wallpaper daily counter down

Excellent I shall have a play, many thanks.

AllenAdministrator
(KiX Supporter)
2012-01-12 07:40 AM
Re: Wallpaper daily counter down

I got way to interested in this... See what you think.



break on


$excludeddates=GetUSHolidays("Federal")
$eventdate="2012/01/31"
$today=@date


$days=serialdate($eventdate)-serialdate($today)
? "Total Days: " + $days


for $i= serialdate($today) to serialdate($eventdate)
if $i mod 7 = 6 or $i mod 7 = 0 or ascan($excludeddates,serialdate($i))>-1
$days=$days-1
endif
next
? "Days, excluding Holidays and Weekends: " + $days




You can get GetUSHolidays() here:
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=204064#Post204064