Computer Science Canada complex data importation |
Author: | atrain [ Tue May 31, 2005 12:08 am ] | ||
Post subject: | complex data importation | ||
Im trying to import data in sets of 5 (4 coords, 1 object type) from more than 1 file im using a flexable 2d array per set I can get it to detect how many files and open them in order, but getting the data into the array i messed something up... If you see how u can help, plz do...
|
Author: | Delos [ Tue May 31, 2005 2:39 pm ] | ||
Post subject: | |||
Woah...no need to get so complicated! You know the exact structure of each file and its contents. So extract the entire file into a flexible array and then sort through the array to find what you need. Or you could do that dynamically, but that's a lot more challenging. If you absolutely must, add flags to your objects. So, the set of 5 numbers could begin and end with "#" or something like that, and any other 'objects' you have could be handled similarly. A few pointers: It's great that you're using procedures, please keep that up. But in the immortal words of Cervantes: "[procedures] shoudl know as little about the outside world as possible." You shouldn't have any of your Global Variables editted directly by the procedure unless you're calling a procedure that alters global variables . Keep things dynamic and use paramters (AKA arguments) as often as you can. You can smooth your "numberoflevels" thing by simply incorporating your "File.Exists" boolean into your extraction. Adding the count there will do just as good of a job.
Just a minor point, you needn't have 2 seperate file streams if you're only ever going to have 1 file open at a time. Once you've close "file" you can use it again to open the files once more. It's just that expendable! |
Author: | atrain [ Tue May 31, 2005 4:37 pm ] |
Post subject: | |
Nah, i figured it out... basicly, the file structure is sets of 4 coordanates (x1, y1, x2, y2) then a object type With that i was importing from every map instead of 1 I fixed it first it finds how many files then it probes inside the one u chose to find how many sets then it does 2 for loops for i: 1..numberofsets for j: 1..5 get : file, objects (i,j) end for end for So it works great now.... Thanx anywayz! |