Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / variable problem

Author
Message
glint
22
Years of Service
User Offline
Joined: 9th Feb 2004
Location: the Synth
Posted: 22nd May 2004 05:59
Sorry, I've already bothered you all about more than enough problems with my side-scrolling engine. But I have another one, and I can't figure it out.

I developed the scrolling, screen-reloading, etc. Now I'm adding in the character which the screen centers on.

Here's my problem :

What is going on when you try to run a program and the Darkbasic Editor outputs, "Variable 'x' does not exist at line 23"? Obviously, variable x exists, or else the program would not have had any way of pointing out its nonexistence to you.

This seems to happen at random. I'll have a piece of code that workds perfectly, I'll add more to it, and suddenly one of the variables is no longer valid.

I don't understand what's going on. Can someone help?
zircher
23
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 22nd May 2004 16:50
How about posting your code? That will give some of a chance to help.
--
TAZ

History did not begin with PONG. -- Greg Costikyan

Game Beavers
Tapewormz
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 23rd May 2004 05:48 Edited at: 23rd May 2004 05:53
It means that you haven't formally declaired your variable. I find that this usually happens inside functions.

ie.

test()
function test()
print b
endfunction

This gives me an error. But if I do the following...

test()
function test()
b as integer
print b
endfunction

I've now formally declaired the variable b as an integer. No more error.

If you're declariing your variables outside functions then do it at the top of your code. Befor you dim arrays even.

ie.
a as integer
b as byte
c as string
d as dword

dim a(10) as integer
dim b(10) as byte
dim c(10) as string
dim d(10) as dword

then you can assign values to your variables without any problem.

ie.

a=10
a(a)=a

Quote: " Timesoft - Your wife is death. How? NO idea.
But it is murder. REVENGE!!!!!!!!!"

Hands down the funniest synopsis for a game ever. All your base are belong to us!
glint
22
Years of Service
User Offline
Joined: 9th Feb 2004
Location: the Synth
Posted: 23rd May 2004 07:12
Thanks, that kind of makes sense - It wasn't the problem in this case though.

I rewrote my code and the problem went away. I think an error in syntax was what was messing things up.
UnderLord
22
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 25th May 2004 07:37
ooo tapewormz that actually is some good discription for that problem i might have to save that to a text file and name it "var help" or something just incase i forget how to hehe

The search continues.

Current project - A space game

Login to post a reply

Server time is: 2026-06-09 13:55:52
Your offset time is: 2026-06-09 13:55:52