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

Username:   Password: 
 RegisterRegister   
 Declaring multiple variables
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
timtimpei




PostPosted: Thu Jan 10, 2008 3:57 pm   Post subject: Declaring multiple variables

I'm making a program that needs a lot of variables of the same type (int). Is there any way to declare multiple variables (maybe by using if and else, loop, etc) so that i don't have to write out everysingle one of them one by one?
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: Thu Jan 10, 2008 3:59 pm   Post subject: Re: Declaring multiple variables

Arrays are your solution
timtimpei




PostPosted: Thu Jan 10, 2008 4:09 pm   Post subject: Declaring multiple variables

Sorry, my question wasn't really clear. Right now i need to upload pictures like this:

const welcomebg : int := Pic.FileNew ("UltimateEarth.jpg")

I can write this for just a few pictures, but i have tons of pictures to upload, so is there any way to make this easier (or quicker)?
Zampano




PostPosted: Thu Jan 10, 2008 4:12 pm   Post subject: Re: Declaring multiple variables

Well, if it's line that you're concerned about, you can use the init procedure to initialize an array of all the file names of your pictures in an array without using too many lines. Then, use a for loop to Pic.FileNew them
Tony




PostPosted: Thu Jan 10, 2008 4:23 pm   Post subject: RE:Declaring multiple variables

you can read the contents of a file directory, and load every file from there, into an array.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: