Loading file into an array

J

Jose

I would like to know if anyone can help me with this. I would like to
load a file into a switch/case function but dont know how. Here is an
example file.
;File Example
;Created 03/04/99
[Command]
name = "2QCF_y"
command = ~D, DF, F, D, DF, F, y

[Command]
name = "5b"
command = b, b, b, b, b
time = 30
etc....

My question is if someone can help me to load any file (I know how to
open it) but then input it into a switch/case function where each case
is

command = ......

Also, I would like to know if there was any way to impose a time
limit, the times shown with the command, with the default time being
15 if no time is specified. And then with each case, the name of that
command is shown?

I also have one further problem. I would like to know if there was any
way to increase the amount of commands depending on the amount in the
files and stop once I get into a certain section.

If anyone can help point me in the right direction? An example maybe?
I just need the switch/case function that would work with a file that
I open. Thanks in advance for any help that can be provided.
 
J

John Harrison

Jose said:
I would like to know if anyone can help me with this. I would like to
load a file into a switch/case function but dont know how. Here is an
example file.
;File Example
;Created 03/04/99
[Command]
name = "2QCF_y"
command = ~D, DF, F, D, DF, F, y

[Command]
name = "5b"
command = b, b, b, b, b
time = 30
etc....

My question is if someone can help me to load any file (I know how to
open it) but then input it into a switch/case function where each case
is

command = ......

Do you know how to read a line from a file into a string? Do you know how to
examine the content of string to see what is there? Do you know how to write
loops and if statements? Do you know how to define a data structure for your
command objects? That is all that you have to do, but its going to be an
awful lot of tedious code. And forget about switch case, it seems completely
inappropriate for what you are trying to do. Switch case works on integers,
and I don't see many integers in that file format.

john
 
J

Jose

John Harrison said:
Do you know how to read a line from a file into a string? Do you know how to
examine the content of string to see what is there? Do you know how to write
loops and if statements? Do you know how to define a data structure for your
command objects? That is all that you have to do, but its going to be an
awful lot of tedious code. And forget about switch case, it seems completely
inappropriate for what you are trying to do. Switch case works on integers,
and I don't see many integers in that file format.

john

Good point. Umm, do you have any idea as to how I would make the
structure so that it can increase or decrease according to the amount
of command objects?
 
J

John Harrison

Jose said:
Good point. Umm, do you have any idea as to how I would make the
structure so that it can increase or decrease according to the amount
of command objects?

Use a vector, or maybe a map. See my other post.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top