How to read...

For questions about using Classic.

Post » Fri Dec 05, 2008 12:35 pm

Hi all!

I have one question about reading text files. Is it possible to read a file LINE per LINE and CHAR per CHAR?

Example:

//Music 01
1000 - a
2000 - b
3000 - c


Which these values (1000; 2000; 3000) are the time in miliseconds and these (a; b; c) are the type of the notes.

I need at the Start of Layout, the Construct to read a text file called: "music01.txt", reading each line and each character. Sorry if it's so complexy.


ps: i am making a Guitar Hero game style.


Thanks!
B
4
G
4
Posts: 27
Reputation: 1,179

Post » Fri Dec 05, 2008 12:49 pm

You could use an ini file. it just like a txt file but its is seperated by groups and Items. So you could have an A group and then the 1000 2000 and so on just use a get Item value this.

it would be something like

Every ini.Itemvalue(A,1000) // these are the groups and the items in the group.
play A note


you would use the ini object to write your values at the start of the program or make a program to write the file for you and then make it global and read the values as you need them. I think this would be a much easier way to read in from a file and is exactly what you are looking for... Hope this helps.
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Fri Dec 05, 2008 1:02 pm

Thanks for the help Aeal5566, but it's too complexy for me, i am newbie at INI, could you make an little example about that? Or just give me a link with INI tutorial, because i don't understand any of read/write files.


thanks!
B
4
G
4
Posts: 27
Reputation: 1,179

Post » Fri Dec 05, 2008 1:14 pm

Sure NP I can have a demo for you your gonna have to give me a little time though Ill try to have it to you by the end of the day I have to go to work now but my boss is out today so I think can make a quick demo for you. Its not so bad once you get into it....
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Fri Dec 05, 2008 1:19 pm

np, i can wait, relax, now i am making the design of the notes and the guitar table, so, i will finish that at the end of day too. thanks again.
B
4
G
4
Posts: 27
Reputation: 1,179

Post » Fri Dec 05, 2008 6:51 pm

Check you PMs i sent you a link to the thing I wrote for you... Sorry if its hard to use ill try to refine it ill let you know about any updates.
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Sat Dec 06, 2008 7:09 pm

ah crap i thought this thread was going to teach me how to read :(

wow. my posts really are getting worse and worse...
B
2
S
2
G
5
Posts: 448
Reputation: 2,546


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 10 guests