Stop button adding script

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
bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Stop button adding script

Post by bidgeeman » Sun May 17, 2009 2:25 am

Hi.
I can't figure this one out (new user) but it so basic it's probably embarassing for you seasoned users to read :oops:

I have a script that adds some text data to a text field based on a checkbox selection. The problem is my text data gets added to the text field when the button is clicked even if no checkboxes are selected. How can I stop the text being added and just have the button do nothing till a checkbox selection is made?

on mouseUp

put empty into b_list
repeat with i = 1 to the number of buttons of this card
if the style of button i = "checkbox" and the hilite of BUTTON i = true then
put the LABEL of btn i &"+" after b_list
end if
end repeat
delete char -1 of b_list
put the LABEL of btn i &"copy /b " before b_list

## puts data into test field

put b_list into field "Test"

end mouseUp

Thanks for any help
Bidge

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Sun May 17, 2009 4:36 am

Hi Bidge

I'm not a seasoned user but thought I'd have a bash at helping if I can.

Haven't tested the code below but think it might be:

Code: Select all

on mouseUp 
put empty into b_list 
repeat with i = 1 to the number of buttons of this card 
if the style of button i = "checkbox" and the hilite of BUTTON i = true then 
put the LABEL of btn i &"+" after b_list 
delete char -1 of b_list 
put the LABEL of btn i &"copy /b " before b_list 
## puts data into test field 

put b_list into field "Test" 
end repeat 
end if 
end mouseUp 
Hope that works for you.

:)

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Sun May 17, 2009 4:46 am

Hi gyroscope

Thanks for the help.
I tried your code but I get an error at this line:


Sorry, meant to say getting an error a the repeat?

button "Button": compilation error at line 11 (if: missing 'end if'), char 1


Cheers
Bidge
Last edited by bidgeeman on Sun May 17, 2009 4:58 am, edited 1 time in total.

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Sun May 17, 2009 4:56 am

Ah, I got your "end repeat;end if" round the wrong way... would this now work :?:

Code: Select all

on mouseUp 
put empty into b_list 
repeat with i = 1 to the number of buttons of this card 
if the style of button i = "checkbox" and the hilite of BUTTON i = true then 
put the LABEL of btn i &"+" after b_list 
delete char -1 of b_list 
put the LABEL of btn i &"copy /b " before b_list 
## puts data into test field 

put b_list into field "Test" 
end if
end repeat 

end mouseUp

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Sun May 17, 2009 5:20 am

Gyroscope it worked thanks mate :lol: :lol: :lol:
However....it opened up another dilemma for me. I realize now that if someone selects a checkbox and then presses the generate button, the rev script writes the data into the text field..... but if they "deselect" a checkboxe, the text in the text field stays there?

Is there a way of connecting any "checkbox deselect" to a "clear entire text field function"? I think that would work.

Cheers
Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Sun May 17, 2009 6:22 am

I figured it out :)

on mouseUp
put " " into field "Test"
end mouseUp

on each checkbox works great!

Thanks for all the help
Cheers
Bidge

Post Reply