This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help reading in data from a file

 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

So I am reading in a configuration file for a game. It holds data about the type of symbols the game has and the possible winning combinations of symbols. I wrote this program for a simpler configuration file where all of the symbols were on two characters. So I only had to read those two characters.

Now I have a line like this:

3 Silver7 Bell Bar : 2

And I need to read each of those strings into a separate variable. I'm hoping someone has ideas for a good way to do this. Also, please note that I am not using Java for this project(I know how to do this very easily in Java), I'm hoping to get some ideas as to what processes I can use.

Thanks
Hunter
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're not doing this in Java, then in what language age you doing it? It would be much easier to help you if you told us in which language you're programming...

For Java, one obvious way would be to use class java.util.Properties to load a *.properties file, which contains a key-value pair on each line (where keys and values are separated with an =).
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the company I am working for this summer has asked me to do this project in Python. I know this isn't a python forum; I'm just trying to get some ideas for determining how many characters to read into one variable.

so if I have something like:

Silver7 Bell Bar //I could look at this line and see that Silver7 is 7 chars long, Bell is 4 chars long, and Bar is 3 chars long
//so I would know to read in 7, then 4, then 3 chars

What I currently do is:


This only works for 2 characters however, I am looking for a more flexible solution since this program will be reading in a lot of these files.


Thanks
Hunter

(Note: the reason I posted this in the Java section was because the moderators there have been very helpful with my Java issues, I was looking more for ideas than language help)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic