Jump to content
Sign in to follow this  
TyroElite

Reading files of description

Recommended Posts

TyroElite

I am looking for some advice here. I have several files that describe several objects on a screen. The basic format is like this:

Document:   ADFUNC01

Version:    5.0.3.2638
Document Information Document:  Width 1024; Height 656; Left 0; Top 0; Reference Width 0; Reference Height 0
      Grid off; Pagebreak off; Grid off

Object: 1
    Type:   Cell
    Position:   Left 234; Top 456
    Object properties:   Visible; Active
    Width:  242
    Height: 210
    Font color: #000000
    Color:  #ffffff
    Border: Top (x); Right (x); bottom (x); Left (x); horizontal grid (x); vertical grid (x); frame type 2; frame color 268374015
    Font:   Name Arial; Size 15; Font Standard; Strike through ( ); italic ( ); underline ( )
    Alignment:  Centered

Object: 2
    Type:   Button
    Content:    Formula
    Position:   Left 13; Top 86
    Object properties:  Visible; Active
    Width:  202
    Height: 24
    Font color: #000000
    Color:  #ffffff
    Border: Top (x); Right (x); bottom (x); Left (x); horizontal grid (x); vertical grid (x); frame type 2; frame color 268374015
    Font:   Name Arial; Size 16; Font Bold; Strike through ( ); italic ( ); underline ( )
    Alignment:  Centered
    Calculation formula:    "Click Me"
    On Mouse click: Wait(3)
    MsgBox(0,"Title","Text")
    Border: Top (x); Right (x); bottom (x); Left (x); horizontal grid (x); vertical grid (x); frame type 2; frame color 268374015

Basically, within a document, there are objects. Each object has a set of properties which are different depending on the function of the object on the screen. Buttons may have a different set of properties from an image. I'll have several documents like this that I'd like to read in.

Now, once I have the files read in (maybe to an array or multiple arrays?) I need to be able to search through and find say all objects that have a Color: #ffffff line in them. I'd also like to be able to build a tree that for the above example would look something like this:

- Document: ADFUNC01
     -Document Characteristics
          -Version: 5.0.3.2638
          -Document Information Document: Width 1024; Height 656; Left 0; Top 0; Reference Width 0; Reference Height 0
      Grid off; Pagebreak off; Grid off
     -2 Objects
          -Object: 1
               -Type: Cell
               -Position: Left 234; Top 456
               -Object Properties: Visible; Active
               -Width: 242
               -Height 210
               -Font color: #000000
               -Color: #ffffff
               -Border: Top (x); Right (x); bottom (x); Left (x); horizontal grid (x); vertical grid (x); frame type 2; frame color 268374015
               -Font: Name Arial; Size 15; Font Standard; Strike through ( ); italic ( ); underline ( )
               -Alignment: Centered
          -Object: 2
               -Type: Button
               -Content: Formula
               -Position: Left 13; Top 86
               -Object properties: Visible; Active
               -Width: 202
               -Height: 24
               -Font color: #000000
               -Color: #ffffff
               -Border: Top (x); Right (x); bottom (x); Left (x); horizontal grid (x); vertical grid (x); frame type 2; frame color 268374015
               -Font: Name Arial; Size 16; Font Bold; Strike through ( ); italic ( ); underline ( )
               -Alignment: Centered
               -Formula
                      -Calculation formula: "Click Me"
                      -On Mouse click: Wait(3)
                 MsgBox(0,"Title","Text")

I'm not sure if its best to read through the files line by line or use the FileReadToArray() or something else. Since I need to do some processing to group things together Object: 1 and Object: 2 under 2 Objects for example, is a multidimensional array the best way to do this? If anyone has any sample code they'd like to share on this, or ideas/recommendations on how to accomplish this, I'd love to hear your thoughts.

Share this post


Link to post
Share on other sites
PsaltyDS

An array with more than two subscripts is probably overkill. I would put that into a single 2D array. The first subscript would be object number, and the second subscript would be properties. You can't have varying numbers of elements in a dimension within the same array, so the second dimension has to be declared with the maximum number of properties, and then they just get left blank for unused properties.

The code required to build this array in memory only makes sense if you are going to query it over and over again. If you will only query it once, you could probably write a RegExp to get just what you want straight from the file.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.