Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Eliminating Variables
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Snicket




PostPosted: Mon May 29, 2006 6:45 pm   Post subject: Eliminating Variables

Is there any way that one can delete a variable totaly.


Simple as that.
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Mon May 29, 2006 6:55 pm   Post subject: (No subject)

In Turing? 'fraid not.

However, you use free to do something similar, though the data that you are deleting must be an object, collection, type... (it must be referenced by a pointer).
Tony




PostPosted: Mon May 29, 2006 6:56 pm   Post subject: (No subject)

as Cervantes says, you can free an object

or reduce the size of a flexible array
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Snicket




PostPosted: Mon May 29, 2006 7:11 pm   Post subject: (No subject)

In my case I am trying to reset my variable to thier original values. It should be easy but it is causing a lot of problems. I am missing a variable in my program I guess. Well Thanks Anyway.
Snicket




PostPosted: Mon May 29, 2006 7:24 pm   Post subject: (No subject)

Alright. My problem is that in my game, when one dies and click on the play button again, none of the sprites show up. My code is rather sloppy, sorry


Outpost Defence.zip
 Description:

Download
 Filename:  Outpost Defence.zip
 Filesize:  345.87 KB
 Downloaded:  41 Time(s)

Cervantes




PostPosted: Mon May 29, 2006 7:26 pm   Post subject: (No subject)

If you're trying to reset a single variable to its starting value, just declare a constant of the same name (though use a capital letter to start it) and assign it the initial value. Then when you want to reset the variable, assign it to the value of the constant.

If you need to do this for a lot of variables, it would be much wiser to have all your initial values stored in a file. Read them in at the start of the program and reread them in whenever you want to reset your variables.
Snicket




PostPosted: Mon May 29, 2006 8:03 pm   Post subject: (No subject)

My main problem is that the sprites declared when the program is first run do not redraw themselves when the program is run again. They dont even appear when redeclared. The game continues to run so it is definately the sprites. I just have no idea.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: