DoCommand NewProperty

Hi

I’m using Xojo 2024r3.1 with a Mobile project.

I’m writing an IDE Script to add properties and methods to the SelectedProjectItem (a Xojo Class). It reads the properties and methods from a file.

When the script runs, it creates a property correctly, but on each iteration it just writes over the previously created property name.

How do I get it to add a new property on each iteration instead?
Do I need to reselect the SelectedProjectItem, if so would do I do that?

Here is the script code:

DoCommand NewProperty
ChangeDeclaration(name, "", type, 0, "")|

I found some old documentation, so I worked it out.

This is the revised code:

Dim importingClass as String = ProjectItem
// get the properties and methods and loop through them
// convert name and type to Xojo

if SelectProjectItem(importingClass) then
   DoCommand "NewProperty"
   ChangeDeclaration(name, "", type, 0, "")
end if

The online documentation have entries for DoCommand

and the main entry is: build-automation-ide-scripting-docommand-commands-used-by-docommand

1 Like

The updated script looks good, especially using SelectProjectItem() to pick the right item. For anyone new, checking the DoCommand docs like Emile said can help a lot. It’s a nice way to learn more about automation in Xojo.

2 Likes