All components have the following built in functions and variables:
AddListener(Name): this function adds the specified message name to the list of messages this component will generate an OnMessage event for. All messages are forced lowercase. See the next topic for more information.
ComponentName: (read-only) this variable returns the name of the component. This is most useful inside of a component actions or events.
CreateProperty(Name, Initial Value, [Group = "Misc"], [Description], [Edit Type])
CreateStringProperty(Name, Initial Value, [Group = "Misc"], [Description = ""], [Edit Type = "string"], [Options], [OptionData]): these two functions create a user property for the component. The only difference is the data type of the resulting property, number or string. A user property is a property that like the built in ones, will persist inside the DAQFactory .ctl document, so will be saved when you do File - Save (or call System.SaveDocument()). The property acts just like a local variable with the exception of the persistence and the ability to edit the property from the Properties control bar. Name must be a valid variable name. Initial Value is the value assigned to the property when it is first created. Once the property is saved with the document, the initial value, and for that matter, this whole function call, is ignored, as the document loading will create the variable and initialize it. Group determines which group the property will appear under in the Properties control bar. Description is currently unused, but in the future will offer a description of the property in the Properties control bar. Edit Type is one of the following strings and determines what sort of editor will be presented to the user in the Properties bar:
•"color" - a color
•"double" - any floating point value
•"integer" - any integer
•"pinteger" - a positive integer
•"pzinteger" - a positive or 0 integer
•"string" - a string
•"bool" - true or false
•"date" - date only
•"time" - time of day only
•"datetime" - date and time
•"font" - a font from the system. A drop down list is presented. Returns a string with the name of the font.
•"file" - a file path. A button with an ellipses is presented that opens a file selection window.
•"options" - allows you to specify a list of options that the user can select from. The options should be a semicolon list as the Options parameter of the CreateProperty() function. You can also optionally present a semicolon list of data to be returned when the corresponding option is selected. If you do not specify the OptionData, the selected Option itself is returned.
GetFocus(): returns true (1) if the component has focus. This usually only applies to components like the edit box.
MoveBy(OffsetX, OffsetY): this moves the component by the given pixel offsets in the X and Y directions. X is left and right with + values going to the right. Y is up and down, with + values going down. The size of the component is not changed.
MoveTo(X, Y): this moves the component to a particular location on the screen without changing its size. 0,0 is the top left corner of the page.
Position: this is an array of 4 values (either a 1 dimensional array of 4 values, or a 2 x 2 array) in the order left, top, right, bottom and define the position of the component on the screen. Some components ignore the bottom and right coordinates.
SetFocus(): this sets the focus to the current component. This usually only applies to components like the edit box the take user focus. This, along with GetFocus() can be used to allow navigation among components using keys such as tab. See the setFocus.ctl sample in the samples folder.
RedoLoadEvent(): this causes the OnLoad event to run again and is usually just used during development to test your OnLoad event script.
Invalidate(): this triggers a redraw of the screen at the location of the component. This is typically done when the component changes state and you don't want to wait for the full page to refresh.
SimKeyPress(character): this sends triggers either the OnChar or OnKeyUp event of the component with the given character. This is mainly designed for creating on screen keyboards and keypads. Character is a string. If you provide a single character in the string, OnChar is triggered with that character. If you provide one of the following strings, OnKeyUp will be triggered with the appropriate key code: "left", "right" "up", "down", "home", "end", "delete", "backspace", "enter", "insert". Note that some components, like the edit box components, process this events on their own without you having to handle the event. So doing component.myEditBox.SimKeyPress("A") will actually add a capital A at the cursor of the edit box.
The following three functions are identical to their global counterparts described in the sequence chapter, except they run in the locale of the component and will automatically terminate if the component is deleted:
StartLocalThread(Function, [Name = ""], [Priority = 3])
StopLocalThread(Name)
GetLocalThreadStatus(Name)