2 Replies Latest reply on Oct 20, 2011 9:29 AM by jchunick

# Declaring Global Variables

Hi People, I'm at the minute doing my Dissertation for University (Hand in December of this year), I'm creating a quiz in Director at the moment.

I did something very simular to the ideas in my second year while at university, when I did this one of mt tutors told me to declair a global variable, but for the life of me I cannot remember how to do this.

Here is the my code as it it at the moment:-

on mouseUp

global testScore

if  field "test1" = 1/2 then

put " " into field "test1"

testScore = testScore + 1

go to 350

else

go to 430

end if

end

When I run the code I get the following message

if field "test1" = 1/2 then

"test1"

Sorry to be a pain on my first post but can anyone help me?

Thanks for any help in advance

Rich

• ###### 1. Re: Declaring Global Variables

It is telling you the problem. There is no field named test1 in your cast. Are you sure you have not typo'd the field name? Are you sure it it is a field and not a text member (they are not the same thing).

• ###### 2. Re: Declaring Global Variables

I'm going to show the solution in both verbose and dot syntax (you are using the older verbose syntax):

-- verbose syntax

if field "test1" = "1/2" then

-- dot syntax

if field("test1").text = "1/2" then

richhemmings wrote:

Hi People, I'm at the minute doing my Dissertation for University (Hand in December of this year), I'm creating a quiz in Director at the moment.

I did something very simular to the ideas in my second year while at university, when I did this one of mt tutors told me to declair a global variable, but for the life of me I cannot remember how to do this.

Here is the my code as it it at the moment:-

on mouseUp

global testScore

if  field "test1" = 1/2 then

put " " into field "test1"

testScore = testScore + 1

go to 350

else

go to 430

end if

end

When I run the code I get the following message

if field "test1" = 1/2 then

"test1"

Sorry to be a pain on my first post but can anyone help me?

Thanks for any help in advance

Rich