Detect when IDE Script OpenFile has completed - 2nd edition

I came across this topic: https://forum.xojo.com/t/detect-when-ide-script-openfile-has-completed

I have the following script:

OpenFile("#") ' # = path to my Xojo Binary File
Call BuildApp(16) ' macOS x86 64-bit
// DoCommand("BuildApp") ' alternative
DoCommand("CloseWindow")

It opens the project file correctly, but does not execute the underlying instructions, compile and close the project. Why? I can’t see any differences to the scripts in the original forum post. Since @Greg_O_Lone said in the previous thread this should work, I wonder where the bug is?

Info: I use the IDECommunicatorv2 class from Xojo’s sample folder:

Advanced/IDE Scripting/IDECommunicator/v2/IDECommunicator-Tester.xojo_binary_project

Is your path correct? I’ve been doing the same for years and everything works fine:

dim MaxVersion as String = "0"
if MaxVersion = "" then MaxVersion = "0"

dim MajorVersion as string = "6"
dim MinorVersion as String = "2"
dim BugVersion as String = "0"
dim BetaVersion as String = "b1"

dim theCommand, theResult as string
dim userHome as String = DoShellCommand("echo $HOME")
userHome = Trim(ShellEncode(userHome))

dim Architecture as integer = 16
'9 universal
'16 intel
'24 arm

dim basePath as string = userHome + "/Documents/Development/Mail\ Archiver/"

'delete old apps and dmg
theCommand = "osascript " + basePath + "code\ current/ide\ communicator/delete\ old\ builds.scpt"
theResult = DoShellCommand(theCommand)

'scheduler: : only for normal, pro and pro admin
if MaxVersion = "0" or MaxVersion = "1" or MaxVersion = "3" then
	openfile(basePath + "code\ current/max\ scheduler.xojo_xml_project")
	ConstantValue("App.kMaxVersion") = MaxVersion
	if ConstantValue("App.kMaxVersion") = "0" then
		PropertyValue("App.Application Identifier") = "com.mothsoftware.mailarchiverx-helper"
		PropertyValue("App.MacOSXAppName") = "Mail Archiver X Scheduler"
	elseif ConstantValue("App.kMaxVersion") = "1" then
		PropertyValue("App.Application Identifier") = "com.mothsoftware.mailarchiverxpro-helper"
		PropertyValue("App.MacOSXAppName") = "Mail Archiver X Pro Scheduler"
	elseif ConstantValue("App.kMaxVersion") = "3" then
		PropertyValue("App.Application Identifier") = "com.mothsoftware.mailarchiverxproadmin-helper"
		PropertyValue("App.MacOSXAppName") = "Mail Archiver X Pro Admin Scheduler"
	else
		print ConstantValue("App.kMaxVersion")
	end if
	makeVersion(MajorVersion, MinorVersion, BugVersion, BetaVersion)
	if BuildApp(Architecture) = "" then
		return
	else
		DoCommand "SaveFile"
		DoCommand("CloseWindow")
	end if
end if

Thanks Trixie, I must have a bug in my code somewhere. I just created a blank project again and now it works. Programmers everyday life! :wink:

BTW, is there a reason Call BuildApp(16) produces two folders? An empty folder _macOS 64 bit and the regular folder macOS 64 bit.

@Beatrix_Willius: Is there a way to set the output folder via IDE Scripting for a single project?

Instead of Call BuildApp, try Print BuildApp. That’ll show a dialog with the built path if the compile was successful.

That’s an artifact of the build process and a bug. It’ll be fixed in a future version of Xojo.

1 Like

Thanks. But i‘m not able to set the output folder manually?

I don’t think so. I copy everything around with ditto.

@Greg_O_Lone/@Beatrix_Willius, could you please give me a working sample for Print(CurrentBuildLocation)? Mine doesn’t work. Thanks.

OpenFile("PATH TO MY PROJECT FILE")
Call BuildApp(16, False)
Print(CurrentBuildLocation)

Greg said to use

CurrentBuildLocation doesn’t make sense here.

1 Like