opening a diferent card based on day of the week

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

opening a diferent card based on day of the week

Post by magice » Sun Sep 05, 2010 4:21 am

I have a stack with 7 cards. I need a script that will look at the day of the week it is when the stack is opened, and go to a specific card based on that data. i have been trying to use the date function to get the data i need, but I have so far been unsuccessful. How can I sort the day portion of the data from the rest of the date?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: opening a diferent card based on day of the week

Post by jmburnod » Sun Sep 05, 2010 8:59 am

Hi Magice,

if i understand what you want this script should work

Code: Select all

on openstack
   GoCdTheDay
end openstack

on GoCdTheDay
   put the long date into TheDate
   put item 1 of TheDate into TheDay
   put TheDay
   open cd TheDay
end GoCdTheDay

Best

Jean-Marc
https://alternatic.ch

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: opening a diferent card based on day of the week

Post by magice » Sun Sep 05, 2010 7:34 pm

thank you, that put me on the right path. However it still has one unexpected problem in my situation. Each of my cards is tied to a tab menu group so I can switch "days" manually by clicking the tabs. The script changes each card, but the tab menus hilight doesn't follow.
I have tried the following script to rectify this:

Code: Select all

set the hilitedButton of group "Days" to TheDay
(Group "Days" being my tab menu) I recieved an error that TheDay was not an integer
so I tried the following script:

Code: Select all

if the value of TheDay = "Monday" then put 1 into tDayNum
   else end if
   if the value of TheDay = "Teusday" then put 2 into tDayNum
   else end if
   if the value of TheDay = "Wednesday" then put 3 into tDayNum
   else end if
   if the value of TheDay = "Thursday" then put 4 into tDayNum
   else end if
   if the value of TheDay = "Friday" then put 5 into tDayNum
   else end if
   if the value of TheDay = "Saturday" then put 6 into tDayNum
   else end if
   if the value of TheDay = "Sunday" then put 7 into tDayNum
   else end if
   put tDayNum
set the hilitedButton of group "Days" to tDayNum
but it isn't working either. Any idea how to get the Tab Menu to follow the cards the same way the cards follow the tab menu?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: opening a diferent card based on day of the week

Post by Mark » Sun Sep 05, 2010 9:01 pm

deleted by poster
Last edited by Mark on Sun Sep 05, 2010 9:30 pm, edited 2 times in total.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: opening a diferent card based on day of the week

Post by bn » Sun Sep 05, 2010 9:04 pm

Magice,
look at the menuhistory in the dictionary. You can switch the tab at the same time you switch to the card or you could just set

Code: Select all

 set the menuHistory of button "Tab Menu" to tDayNum
where tDayNum is a number which corresponds to your Tab Menu. This switches to the card. So you would not issue a go to card x but just change the menuhistory of the Tab Menu. By the way you can also query the menuhistory of the tab menu to know which is the active tab.
regards
Bernd

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: opening a diferent card based on day of the week

Post by magice » Sun Sep 05, 2010 9:20 pm

Once again Bernd you saw past my poor descriptions got to the root of the problem.
Thank You

Post Reply