0
Answer

Help with recursive

John Q

John Q

10y
712
1

I'm trying to write a program that would read a file and recursively find any "Call " statement in that file and in the files that it's calling.  I got it to work but the coding is nasty.  If someone has a cleaner and better code, please post some or suggest some idea how to go about this.  Thanks in advance.

 

File 1:

     Line 1

     Line 2

     Line 3

     Call SomethingA

     Line 4

     Line 5

     Call somethingB

 

    SomethingA:

         Line 1

         Line 2

         Call SomethingC

         Line 3

         Call SomethingD

 

         SomethingC:

              Line 1

              Call SomethingG

              Call SomethingH

 

    SomethingB:

         Call SomethingE

         Line 3

         Call SomethingF

 

 

Return Array = "0 File 1"

                                "1 SomethingA"

                                      "2 SomethingC"

                                            "3 SomethingG"

                                            "3 SomethingH"

                                      "2 SomethingD"

                                "1 SomethingB"

                                      "2 SomethingE"

                                      "2 SomethingF"