Need pascal help, fast :| (file reading);

Discussion about everything. New games, 3d math, development tips...
Post Reply
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Need pascal help, fast :| (file reading);

Post by serengeor »

So I have a file which contains lets say text ant numbers.
Apples 5 6 1 20 18
tomatoes 8 3 4 2 3


Also what I know that this text will occupy only 15 chars, not more not less.(so apples occupies 6 chars and after that there are 9 spaces, but you cant see them because of html thingie in the forum, so visualize 8) )

So how would I read those 15 chars of text into a string and then read the numbers?

I know how to read numbers when there are just numbers in file, but now what I have to do is read text assign it to a variable and also get all the numbers after the text.
There aren't many tutorials for pascal(well there are, but they all lack of sth.).
I've looked trough bunch of the tutorials, still no clue how to do this.

And yes, I must do this in pascal :cry:

This is not my homework, I'm trying to do an exam assignment from the last year.
Working on game: Marrbles (Currently stopped).
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

too bad i don't know pascal. hopefully someone here can help you. good luck.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

ok figured it out, that read function reads the whole line into my string, so instead i have to read the string char by char.
I won't post the code here since the variables and comments are in my language, but if anyone needs help regards this question, ask :wink:.
Working on game: Marrbles (Currently stopped).
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

arhhwhhh, i thought that i will never see this language after they fired me school... BUT I SEE THIS AGAIN :(
btw, i dunno, really dunno why in schools they are using pascal to learning programming. i thought that only Poland have only stupid education system, but i see this is worldwide :D
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

pascal is not so bad at the beginning, but when it comes to some complicated tasks it's like a pain in the a**.
Working on game: Marrbles (Currently stopped).
Brainsaw
Posts: 1183
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Imho Pascal is a good language for learning programming. You can just read the code, and it's definetely better than any Basic I know (I learnt programming with Basic 2.0, just in case anyone remembers ;) ). And I have used Borland Deplhi (aka "Pascal with a good IDE") in a big german company until about three years ago. And if I ever get asked which language to choose if you were planning a small program that does database stuff I would recommend Delphi. Never seen anything else that makes writing normal Windows applications easier (as long as you don't have any fancy stuff besides acessing a database ;) ).
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

Today I participated in pascal competition (olimpiad, if thats the right word in english), having 4 hours of time, I could only solve 2 out of 3 tasks :oops:.

Now I feel, kind of smacked with a brick in the head. :D
Working on game: Marrbles (Currently stopped).
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

Brainsaw wrote:I learnt programming with Basic 2.0, just in case anyone remembers ;)
Yeah!
It was also my first language, I stared learning it when I was 9 on my commodore :D
Very funny history btw. I've been playing games when my joystick crashed (power gaming :D). I found box of my C64, but cannot find any other joystick. Instead, I found programming book.
I enjoyed programming much more than games.
And now, thanks to that book, today I am programmer :D
Here's that book, I still have it :
http://img26.imageshack.us/img26/4462/dsc01091zz.jpg
http://img59.imageshack.us/img59/2086/dsc01090ex.jpg

Backing to the learning programming subject, I think C++ should be much much better.
I remember when I was in high school, everybody feel pain in ass using pascal. When they switched to C++, there was much more pain due to that in C++ is everything different that they learned in pascal.
But after about month they enjoyed C++ much more than pascal before.

Pascal is very very very old language. It's something that like you want to learn to exam for driving license, learning driving on old Ford :)
Image
Post Reply