IDE Script to traverse project?

  1. 2 weeks ago

    Julian S

    May 10 Pre-Release Testers, Xojo Pro UK

    I see that SubLocations doesn't return sub items (Events, Methods etc.) of things like Windows, is there another way to traverse everything in a project or is SubLocation bugged?

    Try the following IDE Script on a new project with an open event on Window1 and it's not shown, any idea how to find it?

    Thanks in advance.

    Dim s As String = ""
    
    Sub Traverse(path As String)
      s = s + "" + path + EndOfLine
      
      Dim itemList As String
      itemList = Sublocations(path)
      
      Dim items() As String
      items = itemList.Split(ChrB(9))
      
      Dim name As String
      For Each name In items
        If path <> "" Then name = path + "." + name
        Traverse(name)
      Next
    End Sub
    
    Traverse("")
    
    Print(s)
  2. @Julian S — You should be able to access windows using WindowCount, WindowTitle, SelectWindow...

  3. Julian S

    May 13 Pre-Release Testers, Xojo Pro UK

    Unfortunately those are the open IDE windows, not the content of the project, events, methods etc. :(

  4. @Julian S — Actually it seems to work fine for me (Xojo 2019r1 - macOS 10.14.4)

    print(sublocations( "" ))

    From a new project, I get everything including Window1

  5. Jürg O

    May 13 Pre-Release Testers, Xojo Pro

    @Stéphane ;Mons From a new project, I get everything including Window1

    Just how do you get the Methods, Events, …?

    @Julian S content of the project, events, methods etc

    I've once tried to apply StandardizeFormat to a whole project (not just the selected code). Feedback Case #47517

    That would require to "loop" through all "code content" in a project (including Methods, Events, …)
    @Norman P mentioned several times I could use an IDE Script for that - but I still don't know how :)
    That's as far as I could get: IDE Script: Loop through Project Items
    I still would like to know how to get even further down...

  6. Julian S

    May 13 Pre-Release Testers, Xojo Pro UK

    Aye Jurg, I noted Norman talking about it which got me thinking about it in the first place. I asked Norman off forum after I posted this and he confirmed it's not possible with the current ide script features so he might have been mistaken at the time.

    From what I can gather, ide script was implemented to bridge a few build automation requirements and anything else was just a fortunate byproduct. I don't think they had/have the resources to pile into an all singing all dancing ide scripting system what you could run the entire ide from code. There are a few feedback requests in the system for such but they've been there for a looong time and considering reformatting took 8 years Feedback Case #4155 I can't see it happening any time soon.

    In terms of mass reformatting, I guess it'll have to be brought outside the ide. Using the new reformat code system would have been a nice solution if we could just traverse the project, I did have something else in mind for using the traversal, but that was shot down before I started :(

or Sign Up to reply!