IDE Script
From REALbasicWiki
Contents |
[edit] Description
Simple scripting functionality in the IDE powered by RBScript.
The IDE has its own script editor. You can either record, or write scripts manually. While recording, any scriptable action you do in the IDE is added to the editor as RBScript code. In order for saved scripts to appear in the IDE Scripts submenu, they must be stored in a folder called "Scripts" that can be either in the same folder as the IDE or the same folder as the current project.
[edit] Commands
- Beep
Plays the system beep.
- BuildApp( Target as Integer ) As String
Builds the application for the passed platform. Returns the shell path to the built item (or empty string on error). Target constants: kTargetCarbonPEF = 1, kTargetCarbonMachOPowerPC = 2, kTargetWin32 = 3, kTargetLinuxGTK = 4, kTargetCarbonMachOi386 = 6, kTargetCarbonMachOUniversal = 8
- BuildLanguage As String
Gets or sets the current build language.
- BuildLinux As Boolean
Gets or sets whether to build for the Linux platform.
- BuildMacClassic As Boolean
Gets or sets whether to build for the Mac OS classic platform. REALbasic 2007 Release 4 and above no longer build for Mac OS "Classic".
- BuildMacMachO As Boolean
Gets or sets whether to build a Mach-O Macintosh application.
- BuildMacMachOUniversal As Boolean
Gets or sets whether to build a Mach-O Macintosh Universal Binary application.
- BuildMacPEF As Boolean
Gets or sets whether to build a PEF Macintosh application.
- BuildRegion As String
Gets or sets the region code to be used in the built application.
- BuildWin32 As Boolean
Gets or sets whether to build for the Windows platform.
- Clipboard As String
Gets or sets the contents of the copy/paste buffer, a.k.a. "clipboard."
- DoCommand( cmdName as String )
Executes the passed command. You can use the IDE script editor to record commands. Every command has a unique name which is used as the argument.
- DoShellCommand( cmd as String, timeout as Integer ) As String
Executes the passed shell command. The shell environment is set up with the following variables: IDE_PATH point to the directory containing the IDE. PROJECT_PATH point to the directory containing the frontmost project. PROJECT_FILE point to the actual project file. The command is executed in synchronous (blocking) mode, and returns any output as the result. The default value for timeout is 3000.
- EndOfLine As String
Returns the default line ending for the platform on which the application is running. This is also the line separator in source code text, i.e., that returned by Text and SelText.
- Location As String
Gets or sets the current location of the project, as shown in the Location field in the Main Toolbar. A script can use this both to see its current location and to navigate to another part of the project.
- OpenFile( path as String )
Attempts to open a REALbasic project file specified by the passed path. This can be either a native or shell path.
- ProjectItem As String
Returns the name of the project item that is currently being edited or is selected in the IDE tab bar.
- ProjectShellPath As String
Gets the shell path to the project file. If the project is not saved, it returns an empty string.
- PropertyValue( propName as String )
Gets or sets the value of a project name property. The propName argument may be just the property name, in which case the property is found on the current project item Or it may be the name of a project item plus the property name, separated by a dot. You may also use the special keyword "App" to refer to the blessed Application subclass, even if that is not actually named App. The following are all valid property references: "Width", "Window1.Width", "App.MajorVersion".
- 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.
- SelectWindow( windowTitle as String )
Brings the passed window to the front. If there is more than one window named windowTitle, then the one closest to the front is the one brought to the front.
- SelectWindow( Index as Integer )
Brings a window to the front identified by its current index in the Window list (see the WindowCount and WindowTitle functions).
- SelLength As Integer
Gets or sets the length in characters of the current selection in the current Code Editor, assuming that there is a selection.
- SelStart As Integer
Gets or sets the offset of the selection or insertion point in the current Code Editor.
- SelText As String
Gets or sets the selected text in the current Code Editor. Note that after assigning to SelText, the selection will be empty and positioned right after the inserted text.
- Speak( text as String, Interrupt as Boolean )
Speaks the passed text via the system's speech synthesis engine. The default value of Interrupt is False. If interrupt is set to True, then it interrupts any previous speech. Otherwise, it waits for the previous speech to finish. This is the same behavior as the built-in Speak command.
- Sublocations( baseLocation as String )
Returns all the locations within the given base location as a space-delimited String. For example, if baseLocation is "App", then this might return "App.Activate App.CancelClose App.Close" (and so on). The set of locations returned should be the same ones suggested by autocompletion in the Location field within the IDE. If baseLocation is an empty string, then this returns the set of project items in the frontmost project.
- Text As String
Gets or sets the entire text of the current Code Editor.
- WindowCount As Integer
Returns the number of windows in the IDE.
- WindowTitle(index as Integer) As String
Returns the title of a window indicated by the passed Index in the window list. An index of zero is the frontmost window.
[edit] Discussion
[edit] Examples
The following script greets you with a MsgBox
Print "Hello world!"
The following script sets the application name to Program.exe, and build the application for windows
DoCommand "BuildSettings"
PropertyValue("App.Windows.AppName")="Program.exe"
BuildWin32=True
DoCommand "BuildApp"
