# Input output commands

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                                                   | Parameters                                                                                                                                                                       | Returns                            | Shared |
|----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|--------|
| `DoShellCommand<ide_scripting_input_output_commands.doshellcommand>`                   | command As `String</api/data_types/string>`, timeout As `Integer</api/data_types/integer>` = 3000, `ByRef</api/language/byref>` resultCode As `Integer</api/data_types/integer>` | `String</api/data_types/string>`   |        |
| `EnvironmentVariable<ide_scripting_input_output_commands.environmentvariable>`         | variable As `String</api/data_types/string>`                                                                                                                                     | `String</api/data_types/string>`   |        |
|                                                                                        | variable As `String</api/data_types/string>`, `Assigns</api/language/assigns>` value As `String</api/data_types/string>`                                                         |                                    |        |
| `ExportLocalizableValues<ide_scripting_input_output_commands.exportlocalizablevalues>` | lang As `String</api/data_types/string>`, savePath As `String</api/data_types/string>`                                                                                           | `Boolean</api/data_types/boolean>` |        |
| `LoadText<ide_scripting_input_output_commands.loadtext>`                               | nativePath As `String</api/data_types/string>`                                                                                                                                   | `String</api/data_types/string>`   |        |
| `OpenFile<ide_scripting_input_output_commands.openfile>`                               | filePath As `String</api/data_types/string>`                                                                                                                                     |                                    |        |
| `RunScript<ide_scripting_input_output_commands.runscript>`                             | scriptName As `String</api/data_types/string>`                                                                                                                                   |                                    |        |
| `SaveText<ide_scripting_input_output_commands.savetext>`                               | nativePath As `String</api/data_types/string>`, aString As `String</api/data_types/string>`                                                                                      | `Boolean</api/data_types/boolean>` |        |

## Method descriptions

<div id="ide_scripting_input_output_commands.doshellcommand">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**DoShellCommand**(command As `String</api/data_types/string>`, timeout As `Integer</api/data_types/integer>` = 3000, `ByRef</api/language/byref>` resultCode As `Integer</api/data_types/integer>`) As `String</api/data_types/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 macOS code sign shell command:
>
> ``` xojo
> Var command As String
> command = "codesign -f --deep -s ""Developer ID Application: YourName"" ""YourXojoApp.app"""
>
> Var result As String
> result = DoShellCommand(command)
> ```

<div id="ide_scripting_input_output_commands.environmentvariable">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**EnvironmentVariable**(variable As `String</api/data_types/string>`) As `String</api/data_types/string>`

> Gets the value of the environment *variable* passed.
>
> On macOS, displays the HOME environment variable:
>
> ``` xojo
> Print(EnvironmentVariable("HOME"))
> ```

**EnvironmentVariable**(variable As `String</api/data_types/string>`, `Assigns</api/language/assigns>` value As `String</api/data_types/string>`)

> Sets the *value* of an environment *variable*.

<div id="ide_scripting_input_output_commands.exportlocalizablevalues">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**ExportLocalizableValues**(lang As `String</api/data_types/string>`, savePath As `String</api/data_types/string>`) As `Boolean</api/data_types/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.
>
> ``` xojo
> If ExportLocalizableValues("english", "/Users/username/Desktop/english.xojo_locale") Then
>   Print "success"
> Else
>   Print "fail"
> End If
> ```

<div id="ide_scripting_input_output_commands.loadtext">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**LoadText**(nativePath As `String</api/data_types/string>`) As `String</api/data_types/string>`

> Loads the contents of the file at *nativePath* into a String.
>
> ``` xojo
> Var data As String = LoadText("C:\\Test.txt")
> ```

<div id="ide_scripting_input_output_commands.openfile">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**OpenFile**(filePath As `String</api/data_types/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:
>
> ``` xojo
> OpenFile("c:\\projects\\IDEScriptTest.xojo_binary_project")
> ```

<div id="ide_scripting_input_output_commands.runscript">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**RunScript**(scriptName As `String</api/data_types/string>`)

> Runs the passed script, found in the Scripts folder, either next to the IDE or next to the frontmost project file.
>
> Run "CommentScript":
>
> ``` xojo
> RunScript("CommentScript")
> ```

<div id="ide_scripting_input_output_commands.savetext">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**SaveText**(nativePath As `String</api/data_types/string>`, aString As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> Writes the contents of *aString* to the file at *nativePath*.
>
> ``` xojo
> Call SaveText("C:\\Test.txt", "Hello, World!")
> ```
