Progress bars on multiple cards of same stack

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jon
Posts: 52
Joined: Sat Apr 14, 2007 11:44 am

Progress bars on multiple cards of same stack

Post by jon » Tue May 15, 2007 5:23 pm

Hi,
I am trying to get my progress bar to update according to the state of highlighted buttons on individual cards, I can make it update okay but ---

My problem is I don't know of a way to save the present state of progress bar on card 1 and make changes to the progress bar on card 2 without affecting card 1's progress bar state

The progress bar is part of the main Template

Any advice appreciated, thanks

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

Post by Mark » Tue May 15, 2007 8:43 pm

Hi Jon,

What is a template? Do you mean a group?

You could save the thumbPos of a scrollbar (progress bar) to a custom property of the card and reset the thumbPos when you come back to the card. Script should look something like this:

Code: Select all

on closeCard
  set the cProgress of this card to the thumbPos of scrollbar "Progress"
end closeCard

on preOpenCard
  set the thumbPos of scrollbar "Progress" to the cProgress of this card
end preOpenCard
You can include these scripts in the stack script.

Best,

Mark
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

jon
Posts: 52
Joined: Sat Apr 14, 2007 11:44 am

Post by jon » Tue May 15, 2007 9:05 pm

Hi Mark,
What is a template? Do you mean a group?
Sorry, yes I did, Im really new to this

Also I found a way to do it by creating new progress bars as each card is created, but oh boy am I glad I read your post before I got much further

I think it could have taken me ages and lots of repetative code to do it my way...... you just showed me how to acheive the similar result with hardly any code at all....and my mind has now gone off on another fact finding tour of the help files

Thanks
Really appreciated Mark

jon
Posts: 52
Joined: Sat Apr 14, 2007 11:44 am

Further probs with create card

Post by jon » Thu May 17, 2007 10:23 pm

Hi,
Your code works very nicely Mark....

I have been hours now on trying to find out how to get a the same thing happenning when i click my new record button to create a newcard, i get the error message "property not an integer" ... the error points to the "preOpenCard" and when i cancel the error message it creates a card and runs ok again, any advice welcome
I dare not shake the dew drop from a rose lest I disturb the stars.

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

Post by Mark » Thu May 17, 2007 10:34 pm

Hello Jon,

Change

Code: Select all

set the thumbPos of scrollbar "Progress" to the cProgress of this card 
into

Code: Select all

if the cProgress of this cd is an integer then
  set the thumbPos of scrollbar "Progress" to the cProgress of this cd
else
  set the thumbPos of scrollbar "Progress" to 0
end if
This may be not exactly what you are looking for, but I just don't know the exact situation. Perhaps, you don't want a new progress bar to start at 0 all the time?

Best,

Mark
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

jon
Posts: 52
Joined: Sat Apr 14, 2007 11:44 am

Post by jon » Thu May 17, 2007 10:51 pm

:D Mark....Thank you for the very quick and accurate reply....two minutes after reading you reply I am up and running again.......

I have really been trying for hours ( about 9 ) because i wanted to learn more...

I found lots of other interesting facts while searching......

maybe one day i will just look at a problem and solve it as quickly as you do.......yeah right...in my next life i think

just gluing my hair back on....

Thanks again Mark
I dare not shake the dew drop from a rose lest I disturb the stars.

Post Reply