Computer Science Canada

"Variable has no value" error

Author:  AFG34 [ Sat Jun 16, 2007 3:23 pm ]
Post subject:  "Variable has no value" error

Hi
I am making a shooting game where there is a target, and the close you shoot to the centre of the target, the more points you earn. You only get to shoot for 30 seconds though. I am having difficulty with adding a high score. When i get a high score in game, it calls upon a procedure which asks you for your name and then stores it. But i cant call it i get this:



Posted Image, might have been reduced in size. Click Image to view fullscreen.
variable has no value

Can someone please tell me what i am doing wrong?



Also i have uploaded the game with all the files for you guys for some feedback:
http://www.megaupload.com/?d=AX4MQ5PJ

Please give it a try and i am open for feedback Smile

Author:  Tony [ Sat Jun 16, 2007 5:16 pm ]
Post subject:  RE:"Variable has no value" error

well it just means that either score or list(7).score (or both actually) have no value.

code:

var foo:int % has no value
var bar:int := 42 % has value of 42


So just don't forget to initialize all the variables to some default value (for scores, it would likely be 0 ).

Author:  AFG34 [ Sat Jun 16, 2007 6:10 pm ]
Post subject:  Re: "Variable has no value" error

i have score set to zero, before the game starts

and list(7).score is set to 300.

Author:  Clayton [ Sat Jun 16, 2007 6:19 pm ]
Post subject:  RE:"Variable has no value" error

Just a query: Why is an if statement that only has one option in an infinite loop? Get rid of the loop around that if statement. Also, nowhere do I see that you have given list (7).score the value of 300 like you said you have.

Author:  AFG34 [ Sat Jun 16, 2007 7:05 pm ]
Post subject:  Re: "Variable has no value" error

I have written it to the data file: high_scores
In the main menu, click on high scores, and you will see.

And thank you both for your replies Very Happy

Author:  AFG34 [ Sat Jun 16, 2007 8:33 pm ]
Post subject:  Re: "Variable has no value" error

edit: I did a little tweaking and it works now Razz

But the ranks don't work. For example if you score between certain numbers, i have it so it gives your a rank, like n00b or godl1ke.

Here is the updated code: http://www.megaupload.com/?d=U9H0DDFT

if you dont like mega upload, give me a link to another host thats more suitable for you.


Thanks for your reply m8 Very Happy



EDIT: Ok did a little more tweaking and finally got it to work. When im done i will post the complete game.


: