Input output commands


DoShellCommand(command As String, timeout As Integer = 3000, ByRef resultcode As Integer) As String

Runs a shell command or shell script.

The Shell environment is configured with these variables:

  • IDE_PATH: Path to the folder containing the IDE

  • PROJECT_PATH: Path to the folder containing the current project

  • PROJECT_FILE: Path to the actual project file

The command is run synchronously and returns the output as the result. The timeout is in milliseconds.

Run the Mac code sign shell command:

Var command As String
command = "codesign -f --deep -s ""Developer ID Application: YourName"" ""YourXojoApp.app"""
Var result As String
result = DoShellCommand(command)

EnvironmentVariable(value As String)

EnvironmentVariable(Assigns value As String)

Gets and sets the value of an environment variable.

On Mac, displays the HOME environment variable:

Print EnvironmentVariable("HOME")

ExportLocalizableValues(lang As String, savepath As String) As Boolean

Exports the specified language lang as a locale file to the specified location at savePath.

The lang names can be a name in the languages that are as presented in the popup menus in the IDE for exporting.

The savePath to the destination is a native path and so is platform specific. The destination file will be created or overwritten if it already exists.

The save can fail if the path to the destination does not exist or the language is not in the list of known languages the IDE supports.

If ExportLocalizableValues("english", "/Users/username/Desktop/english.xojo_locale") Then
  Print "success"
Else
  Print "fail"
End If

LoadText(nativePath As String) As String

Loads the contents of the file at nativePath into a String.

Var data As String = LoadText("C:\\Test.txt")

OpenFile(filePath As String)

Attempts to open a project file using the specified path, which can be either a native or shell path.

Open the file at the path:

OpenFile("c:\\projects\\IDEScriptTest.xojo_binary_project")

RunScript(scriptName As String)

Runs the passed script, found in the Scripts folder, either next to the IDE or next to the frontmost project file.

Run "CommentScript":

RunScript("CommentScript")

SaveText(nativePath As String, astring As String) As Boolean

Writes the contents of aString to the file at nativePath.

Call SaveText("C:\\Test.txt", "Hello, World!")