Welcome, Guest
Please Login or Register.    Lost Password?

Get Number of Calendars to show in text
(1 viewing) (1) Guest
Go to bottomPage: 123
TOPIC: Get Number of Calendars to show in text
#14827
Get Number of Calendars to show in text 3 Years, 6 Months ago  
I was wondering if someone could help me do a script that will get the number of calendars that are "enabled" so that I can display that with a <text> string in my skin.

Let's say I have 4 active calendars out of 7 ... in the calendars window, 4 would be checked.

At the top of my main grid calendar window (without the "Calendars Window" showing) I'd like to be able to output <text> that says "4 Calendars" ... just so I know quickly how many of them are already selected.

Thanks in advance.
Rodger
Junior Boarder
Posts: 33
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Manyk Photography Location: Canada Birthday: 05/07
The administrator has disabled public write access.
 
#14828
Re:Get Number of Calendars to show in text 3 Years, 6 Months ago  
Again, I'm not sure if this is the better way.

Code:

function MyWindowName_Initialize(skin, window)
  Rainlendar_SetEventHandler(CountEnabledCalendars, 13, window)
  Rainlendar_Redraw(0, window)  
end 

function CountEnabledCalendars(_, window)
  value = tonumber(Rainlendar_GetOption("Calendars", "Count"))
  active = 0

  for i = 1, value do
    active = active + tonumber(Rainlendar_GetOption("Calendars/Calendar" .. i, "Enabled"))
  end
  Rainlendar_SetItemValue(window, "MyWindowName.Text", "text", active .. " of " .. value)
end



The only way I found is reading the ini file to know how many calendars I have, and then look for enabled and disabled calendars. (0 is disabled, 1 is enabled).
Jorge_Luis
Platinum Boarder
Posts: 795
graphgraph
User Offline Click here to see the profile of this user
Gender: Male My Rainlendar Skins Location: Argentina Birthday: 03/15
Last Edit: 2011/03/23 10:35 By Jorge_Luis.Reason: Changed id name to avoid confusion
The administrator has disabled public write access.
 
#14829
Re:Get Number of Calendars to show in text 3 Years, 6 Months ago  
OK, I'm a little confused. in the xml for the calendar, is this a time element or text?
Basically, do I do this?:

<text id="MyWindowName.Time" element="font.big" origin="TOP-LEFT" color="255,255,255,255" x="85" y="17" align="TOP-LEFT" text="" />

and will the script fill in the [text=""] ?

Thanks for you assistance Jorge
Rodger
Junior Boarder
Posts: 33
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Manyk Photography Location: Canada Birthday: 05/07
The administrator has disabled public write access.
 
#14830
Re:Get Number of Calendars to show in text 3 Years, 6 Months ago  
Sorry, I've made a mistake in the code, I was reusing a previous code. Yes, its a text element (I will edit the code to avoid more confusion).

Yes, that's the idea. Change the ".Time" to ".Text". The id is more like a name, so, as Shakespeare said: "What's in a name? That which we call a rose. By any other name would smell as sweet."
Jorge_Luis
Platinum Boarder
Posts: 795
graphgraph
User Offline Click here to see the profile of this user
Gender: Male My Rainlendar Skins Location: Argentina Birthday: 03/15
The administrator has disabled public write access.
 
#14833
Re:Get Number of Calendars to show in text 3 Years, 6 Months ago  
OK, so I redid the script "calendar.lua"

I referenced it in the "skin.ini"

I added the text line in the "calendar.ini" window I want it in.

It's not showing up ... and there are no errors (visible) with Rainlendar.

Suggestions?
Rodger
Junior Boarder
Posts: 33
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Manyk Photography Location: Canada Birthday: 05/07
The administrator has disabled public write access.
 
#14836
Re:Get Number of Calendars to show in text 3 Years, 6 Months ago  
To avoid more confusion (I don't know why you're talking about a file called calendar.ini) I attach a working window with the text.

(Inside the zip is the .r2skin file)
File Attachment:
File Name: TestSkin.zip
File Size: 1422
Jorge_Luis
Platinum Boarder
Posts: 795
graphgraph
User Offline Click here to see the profile of this user
Gender: Male My Rainlendar Skins Location: Argentina Birthday: 03/15
Last Edit: 2011/03/23 21:03 By Jorge_Luis.
The administrator has disabled public write access.
 
Go to topPage: 123
get the latest posts directly to your desktop