Page 1 of 1

Stop button adding script

Posted: Sun May 17, 2009 2:25 am
by bidgeeman
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

Posted: Sun May 17, 2009 4:36 am
by gyroscope
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.

:)

Posted: Sun May 17, 2009 4:46 am
by bidgeeman
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

Posted: Sun May 17, 2009 4:56 am
by gyroscope
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

Posted: Sun May 17, 2009 5:20 am
by bidgeeman
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

Posted: Sun May 17, 2009 6:22 am
by bidgeeman
I figured it out :)

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

on each checkbox works great!

Thanks for all the help
Cheers
Bidge