IDE Scripting: Select an Event?

Through IDE scripting, I can select a method just fine, but can’t make it select an event. Is there a trick? i.e.

If SelectProjectItem("MyWebPage.Event Handlers.Open") Then
  Print "It Worked!"
End If

I have tried removing the space from “Event Handlers” and removing “Event Handlers” all together.

Events are not “project items” - project items are windows, modules, classes etc.

Try

location = "MyWebPage.Open" Print location

Thanks Norman, that achieves exactly what I want.

IDE scripting is really aimed at automating tasks that you might do manually.
There are things it simply can’t do nor was it ever designed to do.
You can’t create constants, nor can you create the individual instances for each language / platform for a dynamic constant.
There’s actually a list if you search in feedback for “ide script”

You can actually create constants via scripting. You can’t (that I know of) change the declaration of one though, which would be nice. For example, you can create a new property and then change its declaration:

  If SelectProjectItem("App") Then
    DoCommand "NewProperty"
    ChangeDeclaration("AbcXyz", "HELLO", "String", 2, "")
    
  End If

That same code on a constant, though, will err:

  If SelectProjectItem("App") Then
    DoCommand "NewConstant"
    ChangeDeclaration("AbcXyz", "HELLO", "String", 2, "")
    
  End If

The above code will create a new constant, but it remains “Untitled” and the script errs when it comes to the ChangeDeclaration call.

It’d also be nice to be able to write to the IDE Log screen from a script, such as System.DebugLog "john doe" does (<https://xojo.com/issue/27378>)

Right - you can create a constant but not the constant you want so it’s pretty useless as is unless you want everything to be the same types & just named untitled, untitled1, untitled2, etc :slight_smile: