Re: Questions and answers

Scott Raney ((no email))
Mon, 4 Jul 94 10:38:05 MDT

>
> I have a minor problem and it's like this:
>
> I ask the user a question and he is allowed to answer it 3 times tops.
> He gives the answer and I compare it to the right one. If it's wrong
> the user may have another try. But after three tries he will be given
> the right answer and he won't be able to try again.
>
> The user will score depending on how many hints he has used and how
> many times he has tried to answer the question.
>
> So my question here is that what is the best way to count the
> tries the user has done and execute the script if he has tried less than
> 3 times?
>
> Did this make any sense?
> I hope you understood.
>
> Anna Loimulahti

The answer depends on how you are asking the question. If you
repeatedly ask the question in the same handler, just keeping a local
variable with the count in it would be sufficient.

If the user can leave the card with the question and come back to try
to answer it later, the solution is more complex. There are basically
three approaches I can see:

1) Keep a local variable declared *outside* all of the handlers in the
script that asks the question. A variable declared this way retains
its value until MetaCard exits.

2) Use global variables.

3) Use a hidden field.

-- 
***********************************************************************
* Scott Raney  303-447-3936            Remember: the better you look, *
* raney@metacard.com                   the more you'll see -- Lidia   *
***********************************************************************