help

Blitz3D Forums/Blitz3D Beginners Area/help

Saz(Posted 2007) [#1]
this program keeps telling me i need to duplicate variable name before i can run it WHAT DOES IT MEAN


degac(Posted 2007) [#2]
Please be a little more specific!
Usually this means that you have a Const or a Function already with that name...


Saz(Posted 2007) [#3]
fine ill be specific

I have put Global PLAYER = 2 and it says i need to duplicate this variable name before i can run it


EmerGki(Posted 2007) [#4]
Saz, comment this command, maybe you have in other part of your program, the same comand with the same variable.
The Blitz only "says" what you HAVE a duplicate variable name and NOT what you need to duplicate.


Stevie G(Posted 2007) [#5]
:) It actually means you have a duplicate "PLAYER" global already defined. Call the other one something else and it'll work fine.

Stevie


Andy(Posted 2007) [#6]
>I have put Global PLAYER = 2 and it says i need to
>duplicate this variable name before i can run it

Blitz just tells you what is wrong, it isn't suggesting how to correct it. When it says 'Duplicate variable name', it means that you have two similar variable names, and you have to change one.


Andy


b32(Posted 2007) [#7]
I think the problem is using the variable before it is declared Global.


GfK(Posted 2007) [#8]
Possibly worth noting at this stage, Blitz products do not use case-sensitive variables, so "PLAYER" and "Player" are treated as the same.


H&K(Posted 2007) [#9]
I think the problem is using the variable before it is declared Global
Or its being declared Global Twice

@Sez, Youve probably solved the problem by now, but anyway

1) Yep, stupid problem with English "Duplicate" is a noun and a verb, so the phase "Duplicate variable Name" has two meanings
a) Verb, "Please Copy Variable Name"
b) Noun, "Copy of existing Variable Name"
In this case, its ment to be b)

2) The first time the program finds a Name, it gives it a type, and a scope. So you might have Global String$ or Global Player etc. The first time
This is why lots of programs will have a long list of variable names at the begining, so that the programer can be sure that the Variables are ready/defined before use.
Some common mistakes are (which includes what GFK and B32 posted)
a) Have a string and an Int (or float), with the same name. (you Cannot)
b) Having Caps to Change the name PLAYER and Player (They are the same)
c) Putting the Global before the variable name everyTime (Dont)
or d) Not putting the Global on the first time the variable appears, but on a subsquent one (Only First Time)

So everytime you use Global, you are about to create a new variable, which must have a unique name, so make sure you havent used that name before