Is it possible to change the Super class via IDE Scripting?

I like to run a Pre-Build script that changes the Super of a particular class.

Is that doable?

PropertyValue(“Class1.Super”) = “timer”

recording it as you do it manually is handy :slight_smile:

Really nice. This allows me to test with RbScript in REAL Studio but build with XojoScript in Xojo 2019 without having to manually edit the project each time :slight_smile:

The only scripting feature that I’m missing is to query the IDE version. Ideally I’d like to know which IDE version I’m compiling in, so that I can enable or disable features such as this super class for RbScript vs. XojoScript. Instead, I can only apply these modifcations when I built for release vs. debug now.

Well, this has been introduced for IDE Scripts… somewhen in 2017: XojoVersion
Ah - here it is: 2017r2

Here is how we have “approximately” figured out the XojoVersion with IDE Build Scripts that have been shared in projects using 2011r3, 2015r4, 2016r3, 2017r3, 2018r4 and 2019r1.1:

'IDE Build Script...

'let's assume an old version: REAL Studio 2011r3
Dim dUsedXojoVersion As Double = 2011.03

#if Target64Bit then
'we're running a 64Bit IDE - which means that XojoVersion is available for IDE Build Scripts
dUsedXojoVersion = XojoVersion
'wir definieren die von uns verwendeten Versionen anhand vorhandener Einstellungen
'we need to query a property in a specific window... that property has been introduced in/about 2015.04
if (PropertyValue("wndMainWindow.FullScreenButton") <> "") or (PropertyValue("wndRSReportDesigner.FullScreenButton") <> "") then
dUsedXojoVersion = 2015.04
end if
'that one has been implemented in/about 2016.03, so we know it's at least this XojoVersion
if (PropertyValue("App.OptimizationLevel") <> "") then
dUsedXojoVersion = 2016.03
'and this one has been introduced in/about 2017.03
if (PropertyValue("App.CopyRedistNextToWindowsEXE") <> "") then
dUsedXojoVersion = 2017.03
end if
end if

Sorry… Indents don’t seem to get copied… and beware: this approach has been used to distinguish (reliably) between the XojoVersion mentioned (that we have been using for production builds). It obviously won’t/can’t work for each and every XojoVersion before XojoVersion has been introduced for IDE Scripts. Still - maybe this helps :wink:

So in short: Since 2017r3, the IDE is 64Bit. This allows the use of #if Target64Bit then to use XojoVersion, but not fail on older IDE’s (which aren’t running in 64Bit). On older IDE versions, some other “checks” can be used to make a “good guess”.

Awesome. Thanks, Jürg!

I had not realized that the #if Target… checks could be used to check the IDE’s build settings, but it makes sense to me now.

So, to check which target the IDE was built with, use “#if Target…”, and to check which target is being built, use “if CurrentBuildTargetIs…”.

Follow-up question:

Can I change the build settings from 32 bit to 64 bit for current platform from within a pre-build script?

Changing the architecture or even un/checking a platform is not recorded in 2019r3 (whereas the latter was still recorded in RS 2012).

which suggests they arent being done as actions (and so cant be undone / redone ) :frowning:

I think the closest you get is BuildApp

Be very careful using #if compiler directives in ide scripts. If any part of the condition is undefined, the IDE will hard crash.