handler troubles
Klaus Major
klaus at major-k.de
Sat Feb 4 06:56:38 EST 2006
Hi Ben,
> I am going to make a standalone, that saves to a separate data
> stack. Right now I have 2 sample stacks to work out the kinks,
> "button sample" and "data sample". On the "button sample" stack I
> have a series of quiz items per card, each with yes or no
> responses. I used radio buttons, grouped for each item.
>
> So item #1 has a "YES" btn and a "NO" btn, named "yes1" and "no1",
> & these are grouped to make "group1".
>
> At the bottom of the page is a btn "Go Next Page", with the script:
>
> on mouseUp
> put the value of hilitedbutton of group "group1" into field "1"
> of stack "data sample"
> end mouseUp
Don't use "value":
...
put hilitedbutton of group "group1" into field "1" of CD X of
stack "data sample"
## see below...
...
This will only return the NUMBER of the hilited button of that group
1
if the the FIRST button in that group is hilited and
2
if it i the second one.
> This works alright, but it puts "YES" as 1 and "NO" as 2,
> apparently based on the ID. What I want is to be able to code the
> correct answers "1" & the incorrect answers as "-1", with the
> unanswered items as "0".
>
> So I tried scripts like this, with -1 for the incorrect buttons:
>
> global dataValue1
> on mouseUp
> put -1 into dataValue1
> end mouseUp
>
> And this in the "Go Next Page " btn:
> global dataValue1
>
> on mouseUp
> send dataValue1 to field "1" of stack "data sample"
> end mouseUp
>
> But get error message:
> Type Handler: can't find handler
> Object: Next
> Line: send dataValue1 to field "1" of stack "data sample"
>
> Hint: -1
>
> I can't figure out what is wrong. I've tried many permutations
> that I have not listed. Thanks for any help,
You cannot "send" the value of a variable.
You can only "send" a message = the name of a handler.
So you just:
global dataValue1
on mouseUp
PUT dataValue1 to field "1" of CD X of stack "data sample"
## see below...
end mouseUp
And try this for checking which radiobutton is hilited:
on mouseUp
put empty into temp_var
## we willstore the NUMBER of the hilited button here
if the hilitedbutton of grp "group1" = 1 then
## the first button = "yes1" is hilited
put "YES" into temp_var
else
## the secong button is hilited
put "NO" into temp_var
end if
if temp_var = empty then put 0 into temp_var
## NO button is hilited!
put temp_var into field "1" of CD X of stack "data sample"
## if you omit the descriptor "of CD X" it will only work if the
field is on
## the current card of stack "data sample" or it there is only ONE
card in that stack!
end mouseUp
Hope that helps.
> Ben
Regards
Klaus Major
klaus at major-k.de
http://www.major-k.de
More information about the use-livecode
mailing list