Archived

This topic is now archived and is closed to further replies.

Wizzy

Reading a file up to a certain point

Recommended Posts

ok... i''m working on something... but before i start i''m trying to figure out how i''m going to do what i want... so i''ve searched and searched and tested my own methods and i''ve found ways to do most of what i want... but there is one thing i can''t find... anyone played EHM? i''m working on a basketball simulator - and i''m trying to figure out the best way to display career statistics... now - here is an example from EHM, of what a career file might look like #1 1992-93 Swift-Current Broncos WHL 65 3679 206 6 2 3.36 0 0 0 0 0.000 1993-94 Richmond Renegades ECHL 43 2299 155 4 0 4.05 18 16 5 1174 0.883 1993-94 Salt-Lake Golden Eagles IHL 9 381 25 0 0 3.93 5 1 0 207 0.892 1994-95 Denver Grizzlies IHL 15 798 47 2 1 3.53 9 4 1 382 0.890 1998-99 Sparta Praha Czech 50 2877 109 0 0 2.27 0 0 0 0 0.000 1999-00 Hartford Wolf Pack AHL 36 1979 71 4 5 2.15 22 11 0 916 0.928 1999-00 New-York Rangers NHL 2 86 5 1 0 3.49 0 1 0 44 0.886 2000-01 Atlanta Thrashers NHL 36 1879 105 1 2 3.35 12 19 2 951 0.890 2001-02 Atlanta Thrashers NHL 60 3367 179 9 3 3.19 13 33 10 1956 0.908 2002-03 Chicago Wolves AHL 15 838 33 1 1 2.36 11 2 1 390 0.922 2002-03 Atlanta Thrashers NHL 21 1097 65 0 0 3.56 4 13 1 605 0.893 2003-04 Atlanta Thrashers NHL 54 3134 173 1 2 3.31 13 33 5 1672 .906 2003-04 Czech NAT 6 360 16 0 1 2.67 6 0 0 106 .869 2004-05 Atlanta Thrashers NHL 64 3756 200 2 2 3.19 26 33 4 1721 .896 2004-05 Czech NAT 4 88 7 0 0 4.77 1 0 0 18 .720 #2 1999-00 UMass-Lowell NCAA 30 2 10 12 24 2000-01 UMass-Lowell NCAA 17 1 6 7 22 2001-02 UMass-Lowell NCAA 37 4 9 13 38 2002-03 UMass-Lowell NCAA 23 2 5 7 2003-04 HIFK Helsinki FIN 55 5 11 16 69 10 2004-05 HIFK Helsinki FIN 54 2 7 9 101 11 #3 1993-94 Kansas-City Blades IHL 71 15 18 33 64 1993-94 San-Jose Sharks NHL 1 0 0 0 0 1994-95 Kansas-City Blades IHL 43 15 10 25 55 1994-95 San-Jose Sharks NHL 26 3 5 8 94 1995-96 Kansas-City Blades IHL 27 4 6 10 118 1995-96 San-Jose Sharks NHL 42 7 7 14 62 1996-97 Kentucky Thoroughblades AHL 3 1 2 3 4 1996-97 San-Jose Sharks NHL 60 12 15 27 222 1997-98 San-Jose Sharks NHL 40 1 1 2 112 1997-98 Tampa-Bay Lightning NHL 14 1 1 2 58 1998-99 Tampa-Bay Lightning NHL 26 2 0 2 43 1998-99 Calgary Flames NHL 36 5 9 14 30 1999-00 Calgary Flames NHL 76 10 22 32 78 2000-01 Anaheim Mighty Ducks NHL 16 1 0 1 29 2000-01 Boston Bruins NHL 63 1 4 5 200 2001-02 Boston Bruins NHL 47 0 2 2 164 2001-02 Phoenix Coyotes NHL 30 6 3 9 51 2002-03 Phoenix Coyotes NHL 59 3 0 3 135 2003-04 Phoenix Coyotes NHL 80 7 8 15 240 -18 2004-05 Phoenix Coyotes NHL 82 7 10 17 252 -11 2004-05 Russia NAT 4 0 1 1 2 0 you''ll notice each one starts with a "#" and then a number... what would be the best way of reading the stats for a number (say i want #3 to show) and displaying them on either a text control or an internet control... i''ve figured the internet one is easier - cause it''ll display things properly aligned as they are in the text file... but i''m not sure how to only read the stuff between #2 and #3 (don''t need the #x, just the stats below it).... as i said - i think the internet control is the best way - but how would i do that?

Share this post


Link to post
Share on other sites
on a side note: the stuff i posted didn''t align as it is in the actual file - in the file it''s quite neatly aligned and everything... so i''d like to keep it that way when i display the entry(s) for a player.

Share this post


Link to post
Share on other sites
oh - and if you know how to do it on a text control, even better... i'd like to avoid using internet controls as much as possible.

[edited by - Wizzy on May 6, 2003 1:03:05 AM]

Share this post


Link to post
Share on other sites
Wanna give us a clue on what language and such you are using? I''m guessing MFC... VB... or C# But It''s kinda hard to help without knowing for sure.

Share this post


Link to post
Share on other sites
sorry - i''m an idiot, i forget to post the language every time i ask a question :mad:

i''m using VB (6.0 to be exact)

Share this post


Link to post
Share on other sites
Ahh, well in that case a Textbox control is fine. Maybe a RichEdit Box if you want color stuff later on.


Basically I''ll try and give you rough idea since its been a good year and half since I touched VB.

Open "file.txt" for Input as #1
Input #1, FileData '' Not sure if this loads whole file or a single line LOL, find out
'' if its the whole file then youll need to break it up using Split and the CRLF delimiter, if its each line youll have too loop through and read them all into an array until end of file

now at this point you should have an array of lines, loop through until you find the string with the # you want

then continue looping and adding each line to a textbox until you get to next number

Sorry I can''t give real code on this its just been to long, I used to be awesome at VB too C/C++ have dulled my mind.

Share this post


Link to post
Share on other sites