Getting project type with IDE Scripting

I am writing an app that uses IDE communicator to automate some stuff and it would be helpful if it could tell what the project type (desktop, web, etc) is. I see the CurrentBuildTargetIs* commands, but that is restricted to build steps, right?

I suppose I could check a project for a Session object since that would be web-only, and I would think there is something similar for an iOS or Android project.

If you prefix with # then the code is not included outside of the debugger. But if you don’t use the # command, you can do whatever you want ie

#If TargetMacOS Then
  'only runs in macOS
  MessageBox "Mac only"
#EndIf

If TargetMacOS Or TargetWindows Then
  'runs in macOS or Windows
  MessageBox "Mac and Windows only"
  
  #If TargetMacOS Then
    'do something for macOS only
  #ElseIf TargetWindows Then
    'do something for Windows only
  #EndIf
End If

well, that’s close. But it doesn’t distinguish project type, just the target platform.

This is the full list.

Aren’t things like TargetDesktop, TargetConsole, and TargetWeb what you are looking for?

Yes, do those work in an IDE script?

Ahh yeah, you’re right. Those don’t work in an IDE script.

You can set up constants and variables in a Script to do this:

'Const kOSX32 = 7
Const kMacOSARM64 = 24
Const kMacOSIntel64 = 16
Const kMacOSUniversal64 = 9

Const kWindowsARM64 = 25
Const kWindowsIntel32 = 3
Const kWindowsIntel64 = 19

Const kLinuxARM32 = 18 'Raspberry Pi 32-bit
Const kLinuxARM64 = 26
Const kLinunIntel32 = 4
Const kLinuxIntel64 = 17

Const kiOSDeviceARM64 = 14
Const kiOSSimulatorARM64 = 10
Const kiOSSimulatorIntel64 = 13

Const kAndroidDeviceARM64 = 23
Const kAndroidEmulatorUniversal64 = 21

Const kXojoCloudIntel64 = 12

Var isCompileDesktop As Boolean = True
Var isCompileWeb As Boolean = True
Var isCompileMobile As Boolean = True

If isCompileDesktop then
Var Path As String = BuildApp(kMacOSIntel64, False)
ElseIf isCompileWeb then
…
ElseIf isCompileMobile then
…
End If

That’s still not quite what I am asking, so maybe a little more context will help.

The app I am writing uses the IDE communicator to add a listbox subclass directly to the IDE. That subclass has different events, methods, etc depending on if it’s a desktop listbox or a web listbox. Right now, the app just has a popup menu to select if it’s a desktop or a web listbox, but I would like it if the app can query the active project via the communicator to get the project type automatically.

@Clifford_Antrim

Something to try IIRC:

SelectProjectItem(“App”)
DoCommand(“Copy”)

The clipboard should have a Text component and I believe it’ll be something like:

App as ConsoleApplication

I’m doing this all from memory so it may need some tweaking.

It turns out you can’t copy the App object :frowning:

I’ll play around with this approach to see if there is another way to get there, but I am starting to think that I’ll just need to check for the presence of a “Session” object as my flag.

Bingo! Thanks @Greg_O !!

If SelectProjectItem(“App”) Then
Print (TypeOfCurrentLocation)
End

1 Like