Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Duplicate Label ?!
#1
HEy guys, this is probably a very simple problem with a very simple answer, but, I am trying to make an RPG game that allows the user to save in binary to three slots... so...

Open Slotsave1 FOR BINARY AS #1
PUT #1 , , playername$
PUT #1 , , playerlevel
PUT #1 , , strength
CLOSE #1

right?

But, when I say something like:
PRINT "Choose a slot to save"
input slot
if slot = 1 then goto saveinslot1
if slot = 2 then goto saveinslot2
if slot = 3 then goto saveinslot3

saveinslot1:
Open Slotsave1 FOR BINARY AS #1
PUT #1 , , playername$
PUT #1 , , playerlevel
PUT #1 , , strength
CLOSE #1

saveinslot2:
Open Slotsave2 FOR BINARY AS #2
PUT #2 , , playername$
PUT #2 , , playerlevel
PUT #2 , , strength
CLOSE #2

and so forth, but then it says on the variable 'strength'

DUPlICATE LABEL

or something like that. I use this at the top

DIM SHARED strength AS INTEGER

do I need to put something else at the top... like
'$DYNAMIC
or
DEFIN A-Z I think that's it, but maybe not

anyway, it gives me a duplicate label error message whenever I try to do that, so I guess, is it only possible to save to one slot?

Any help would be appreciated, uh, if this doesn't make sense email me or post a message

NOVA@EDGEEMU.COM

thanks
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply
#2
If it is but it's supposed to be a completely different variable than the one in the main routine, take out the "SHARED" attribute in your DIM statement. (And if "strength" doesn't need to be a global variable, you don't need the "SHARED".) Generally, that error message means that you're trying to reuse/redefine a variable that's already had its type specified.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#3
It sounds like a side effect, it isn't definitely a problem of wanting to save in several slots.

Check that you are not using the same name for an array and for a label, and that you are not using the same name for arrays/variables of different types.

In QB, identifiers must be unique. Check your program carefully.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
If you dim a variable AS something, you can't use the same name with a different type:

Code:
CLS
'DIM a AS INTEGER
'a = 6
a% = 5
a! = 500000000
a$ = "5"
a# = .5
a& = 50000
a: PRINT a; a%; a!; a$; a#; a&

Uncommenting a = 6 sets a% and a! to 6. Uncommeting the DIM only allows you to set a% = 5.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#5
Quote:If you dim a variable AS something, you can't use the same name with a different type:

Code:
CLS
'DIM a AS INTEGER
'a = 6
a% = 5
a! = 500000000
a$ = "5"
a# = .5
a& = 50000
a: PRINT a; a%; a!; a$; a#; a&

Uncommenting a = 6 sets a% and a! to 6. Uncommeting the DIM only allows you to set a% = 5.

The question is, where's he reusing "strength"?
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#6
ok, so what I am doing is:
using strength to represent the player's strength alone (it is an RPG), notincluding the weapon's power.
whenever I try to put anything as an integer...
it comes up with a dupilcate label error and stuff like that...

umm

so there is other integer values... such as weaponpower armordfc bootagl and stuff like that that are also coming up with error messages.

When I asked how to save a game (a long time ago) Na_th_an told me that I should save it as a binary like so
OPEN saveslot1 FOR BINARY AS #1
put #1,,

and so on
but whenever I do that for the integers it always comes up with 'dupilcate error' so...
I am wondering if it matters if strength is DIM(ed) and then set as an integer or something like that. Actually, I am talking out of my butt, I don't know what I am saying. Later I will obtain some source copy (I can't right now) so you guys can see it, but for the current time just help me out if you can... thanks again.
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply
#7
Run this simple program:

DIM STRENGTH AS INTEGER
STRENGTH=&H4241
OPEN "STRENGTH.TXT" FOR BINARY AS #1
PUT#1,, STRENGTH
STRENGTH=&H0A0D
PUT#1,, STRENGTH
CLOSE #1
END

Then use notepad or some other text editor to look at the file STRENGTH.TXT. You should see "AB". Let me know what happens.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)