none
Replacement for Random Access File in VS 2010?

    Question

  • The application reads information similar to a DXF file.  For purposes of discussion, the data consists of lines, those lines have endpoints, x1,y1,x2,y2.  Within the file those lines create "paths", in other words, they are connected.  There can be many separate paths within a single file.  However in the original file, the geometry is not in any particular order, the paths are not indicated.

    In my original application, I would read in the file, process it into "paths" and assign each "path" to a separate Random Access File.  Later, each of these files would be processed.  The processing could involving reversing the order, changing which geometric element began the path, etc.

    While it is "possible" to use a RA file in VS, it is not recommended, and it is certainly not as straightforward as it was in VB6.  I would much prefer to program with the intent of VS2010 rather than try to "work around" issues like this.

    At this point, my code can read in the file (I currently put it in an Arraylist), display it using an img in a picture box, zoom, pan, report actual x,y coordinates of the cursor location.

    I know how to separate the paths, what I need to know is WHERE to put these paths?  Putting them all in one Arraylist will not work very well, since manipulating each of them within that list will become a nightmare, the same would be true of a database. 

    A question I have is it possible to create Arraylists on the fly?  This is necessary since the number of paths is not known when the program begins.

    Anyone have any ideas?

    I have not included any code because this really isn't a coding question.

    Thanks in advance!  This forum has been a well of information as I have been making the transistion from VB6 to VS2010, it is my "Go To" place.

    Friday, September 03, 2010 3:02 PM

Answers

  • Hi,

    Please this example on creating RANDOM ACCESS FILEs.>>

    http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/50d7b930-edd3-4ba4-92fe-2c16e5235e51

     

    Since the number of paths is not known then a RANDOM ACCESS file is

    not very suitable as R.A. files in Vb.Net are based on fixed length records.

     

    What is the maximum number of paths you will use and what is the format of the data you are using?

    Can you give an example of PATH data please?

    If you can decide on a maximum number then you could use random access files.    :-D

     

    Can you use a separate file or files for your path data?



    Regards,

    John


    • Marked as answer by TReischl Friday, September 03, 2010 5:52 PM
    Friday, September 03, 2010 3:58 PM

All replies

  • Hi,

    Please this example on creating RANDOM ACCESS FILEs.>>

    http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/50d7b930-edd3-4ba4-92fe-2c16e5235e51

     

    Since the number of paths is not known then a RANDOM ACCESS file is

    not very suitable as R.A. files in Vb.Net are based on fixed length records.

     

    What is the maximum number of paths you will use and what is the format of the data you are using?

    Can you give an example of PATH data please?

    If you can decide on a maximum number then you could use random access files.    :-D

     

    Can you use a separate file or files for your path data?



    Regards,

    John


    • Marked as answer by TReischl Friday, September 03, 2010 5:52 PM
    Friday, September 03, 2010 3:58 PM
  • My first thought is of course serializing and deserializing.

    http://www.vb-tips.com/SerializeArrayList.aspx

    If that is to simple reply

     


    Success
    Cor
    Friday, September 03, 2010 4:05 PM
  • Hello John Anthony!

    The URL you supplied was just the ticket! When I read the docs on RA files, it was extremely confusing, and it seemed MS was implying that there were better methods to be used than RA files.  I would hazard a guess that in the VAST majority of cases that is so.  But for what I am doing they work very well.

    To answer some of your questions:

    I actually am reading a DXF file.  The entity types include Lines, Arcs, Circles, LWPolylines and Ellipses.  However, they are all eventually boiled down to being a line, an arc or circle.  Circles are a special case, since they do not have "end points".  End points are calculated for lines and arcs.  So the data for each is stored:

    Line: x1 y1 x2 y2
    Arc: x1 y1 x2 y2 xc yc rad sa ea  (where sa and ea are starting and ending angles)
    Circle: xc yc rad

    Other information is stored in the record in addition to the geometric data.

    There are no maximum number of paths, that is why the RA file works so well.  I have worked with files that have over 3,000 "paths" in my old application.

    The fixed length records are not a problem either.  In my old application I defined all string records as fixed to conserve disk space. 

    Your response was terrific!  As I mentioned in my post this is my "Go To" place for information, and your response is an example of why I come here to read and learn.  Thanks again.

    Ted

    Friday, September 03, 2010 5:52 PM