Home > Community > Forums > PCB SKILL > parseFile() with structed object?

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 parseFile() with structed object? 

Last post Wed, May 16 2012 12:21 AM by stillfish. 0 replies.
Started by stillfish 16 May 2012 12:21 AM. Topic has 0 replies and 2040 views
Page 1 of 1 (1 items)
Sort Posts:
  • Wed, May 16 2012 12:21 AM

    • stillfish
    • Top 500 Contributor
    • Joined on Thu, Jun 17 2010
    • Posts 32
    • Points 430
    parseFile() with structed object? Reply

    Dear all,

      I have met some problems on parsing files, and i will take a simple example to describe my question.

      I have an object m1 build like this:

    defstruct(myPoint x y)
    defstruct(myObject name type listCord)
    defun(test ()
      p1 = make_myPoint(?x 1 ?y 2)
      p2 = make_myPoint(?x 3 ?y 4)
      m1 = make_myObject(?name "test" ?type "Poly" ?listCord list(p1 p2))
    )
     

       And I saved m1 to a text file with format :

      myObject = {
        name = test
        type = Poly
        listCord = {
            myPoint = {
                        x=1
                        y=2
                    }
                    myPoint = {
                        x=3
                        y=4
                    }
                }
            }

       I try to parse this format to rebuild m1 with parseFile() function but have no good idea to continue..

      parseFile("C:/m1.txt" 'myParseHndl "'\" \t")

      defun(myParseHndl (curLine lineArg result)
         case(car(lineArg)
           ("
    myObject
            result = make_myObject()
           )
    ("name"
    result->name = nthelem(3 lineArg)
    )
    ("type"
    result->type = nthelem(3 lineArg)
    )
    ("
    listCord"
    result->listCord = myCordParseHndl..........??? 

        )
      

        It seems not possible to call another handle in myParseHndl, and I was stuck here. 
        Is there a good routine for parsing this kind of files or any tips about parsing file ?
        The format of text file is flexible if need to be changed.    

    Filed under:
    • Post Points: 5
Page 1 of 1 (1 items)
Sort Posts:
Started by stillfish at 16 May 2012 12:21 AM. Topic has 0 replies.