Status of Checkbox Button for if... then...

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
tazmax
Posts: 2
Joined: Tue Nov 11, 2008 5:07 pm

Status of Checkbox Button for if... then...

Post by tazmax » Tue Nov 11, 2008 5:15 pm

Hi,
I'm an absolute beginner to this and I wonder if there is a chance to use the status of a checkbox for a if .. then.. operation.

Example:

if button "checkbox" is checked then answer "Hello World"
else if button "checkbox" is unchecked then answer "No Hello"
I've thested a hundret possible expressions but didn't find a working one.

Is it possible? How?
Looking foreward to answers.
Regards,
Taz

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Tue Nov 11, 2008 6:04 pm

Hi Taz, this should do the trick:

Code: Select all

if the hilite of button "checkboxname" then
 answer "hello world"
 -- "... is true" is implied, you can, for the sake of legibility use:
 -- "if the hilite of button "checkboxname" is true then"...
else 
 answer "the box is not checked" --(read: the hilite of button "checkboxname" is false)
end if

tazmax
Posts: 2
Joined: Tue Nov 11, 2008 5:07 pm

Post by tazmax » Tue Nov 11, 2008 7:31 pm

Hi SparkOut,
works perfect for me! Thank you very much for your quick reply!

Taz

urbaud
Posts: 120
Joined: Tue Feb 24, 2009 12:10 am

Is there an equivalent in Revolution to "c = c +1"

Post by urbaud » Thu Feb 26, 2009 3:39 am

As some of you know, in other basic languages the programmer can use: c = c +1 as a counter. I'm sure all of you who are good at programming in Revolution are annoyed when "newbies" ask dumb questions. I'm a newbie to Revolution. It's pretty different than Visual Basic for example. Is there an equivalent. I'm trying to input numbers into a dialog box and have the number inputted appear in a text field and the running balance along side. Any suggestions?

I can't seem to find a site that has good examples of the syntax. The dictionary in Revolution is somewhat helpful, but it doesn't have good examples. The only way I learn this stuff is to see the code, so if anyone knows of other sites I'd appreciate a reply. Any help greatly appreciated
urbaud

paul_gr
Posts: 319
Joined: Fri Dec 08, 2006 7:38 pm

Post by paul_gr » Thu Feb 26, 2009 4:13 am

Hi Urbaud,
Look in the resource center, the button next to the dictionary :).
There's a lot of interesting examples and scripts in there.

Paul

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Is there an equivalent in Revolution to "c = c +1&q

Post by sturgis » Sat Feb 28, 2009 11:59 pm

I'm very very new at this (started yesterday pretty much) but heres a couple examples that are close to what you want.

put 10 in temp
add 10 to temp

temp has 20 now.
Not quite as shorthand as the other method, but pretty short.
I didn't try it, but suspect if you didn't initialize a value for temp the add would still work just starting at 0, but i'm paranoid about things like that so always initialize values.

I suspect similar can be done directly in a field, but haven't tried it yet, like I say i'm very new. (started yesterday)

something like
put 10 into fld "fieldname"
add 10 to fld "fieldname"..

sec gonna try it.

Yep, works. I did this with a button and 2 fields.
on mouseUp
put 10 into fld "nextNum"
add fld "nextNum" to fld "runningTotal"
end mouseUp

That also could say
add 10 to fld "nextNum" rather than using 2 fields.

I'm sure you've already figured out how to do what you want, but answering helps me get a better handle on things so, there ya go.

urbaud wrote:As some of you know, in other basic languages the programmer can use: c = c +1 as a counter. I'm sure all of you who are good at programming in Revolution are annoyed when "newbies" ask dumb questions. I'm a newbie to Revolution. It's pretty different than Visual Basic for example. Is there an equivalent. I'm trying to input numbers into a dialog box and have the number inputted appear in a text field and the running balance along side. Any suggestions?

I can't seem to find a site that has good examples of the syntax. The dictionary in Revolution is somewhat helpful, but it doesn't have good examples. The only way I learn this stuff is to see the code, so if anyone knows of other sites I'd appreciate a reply. Any help greatly appreciated

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sun Mar 01, 2009 12:36 pm

how about:

Code: Select all

put theVar + 10 into theVar
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

urbaud
Posts: 120
Joined: Tue Feb 24, 2009 12:10 am

Post by urbaud » Sun Mar 01, 2009 11:02 pm

Hi Sturgis,
Thank you for your reply and suggestions. You were right I was able to figure it out on my own. Here's my script:
on mouseUp
put empty into field "text1" --clears textbox
put empty into field "text2" --clears textbox
wait 1 second --waits a second to show that textboxes are actually cleared
repeat with count = 1 to 10 --sets up the repeat command
put count into line count of field "text1" --numbers 1-10 displayed in textbox1
add count to c --math to create running total
put c into line count of field "text2" --running total displayed in textbox2
end repeat
end mouseUp

Urbaud
urbaud

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Mon Mar 02, 2009 5:05 am

Can't get this to work? Is it supposed to?
BvG wrote:how about:

Code: Select all

put theVar + 10 into theVar

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Mon Mar 02, 2009 12:13 pm

yes it works... As long as the variable actually contains a number, of course.

Code: Select all

on mouseUp
   put 1 into theVar
   put theVar + 1 into theVar
   put theVar
end mouseUp
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Mon Mar 02, 2009 6:21 pm

DOH I knew that. Thx.

urbaud
Posts: 120
Joined: Tue Feb 24, 2009 12:10 am

Post by urbaud » Mon Mar 02, 2009 9:46 pm

Sturgis,

Yes, it's suppose to work. I just tried it again and it worked fine. As you know it requires 2 text fields, one called text1 and the other text2, and of course a button. I assume you are using a Mac.
Hope it helps,
urbaud
urbaud

Post Reply