User forms
Form controls
These are controls provided by RAS that you can place in a user form design (forms/<name>.form.json). They are built by combining labels, text boxes and buttons, for things MSForms does not have. The form holds an object of this class under the control's name (this.pbWork), and you operate it by reading and writing properties, like any other control.
Progress bar (ProgressBar)
{ "id": "pb", "name": "pbWork", "type": "ProgressBar", "caption": "Working", "value": 0,
"left": 12, "top": 12, "width": 240, "height": 24 }
When written, it becomes four labels (<name>_Track, <name>_Bar, <name>_Caption, <name>_Value). If the design does not specify the bar color (barColor), it is the system highlight color (vbHighlight).
File / folder picker (FilePicker)
{ "id": "fp", "name": "fpBook", "type": "FilePicker", "left": 12, "top": 12, "width": 240,
"title": "Select a workbook", "filters": [{ "description": "Excel workbooks", "extensions": "*.xlsx; *.xlsm" }] }
It becomes a text box <name>_Text that holds the path, with a button <name>_Button attached to its right. Pressing the button shows Application.FileDialog and puts the chosen path in the field. You can also type or paste into the field directly.
// forms/frmImport.ras
@on("fpBook.Change") // the field's event (typing, pasting, or choosing with the button)
function changed() {
this.btnOK.enabled = this.fpBook.path != "";
}
@on("btnOK.Click")
function ok() {
this.pbWork.caption = "Importing";
this.pbWork.value = 50;
this.close(this.fpBook.path); // the (first) path in the field
}
Reference
Class progressbar.ProgressBar
A progress bar. A form's ProgressBar control (this.pbUpload) is an object of this class,
operated by reading and writing its properties like any other control.
The top line shows caption (left) and the percentage (right; showValue), and the bar is below. If the bar color (barColor)
is not set in the design, it is the system highlight color (vbHighlight).
- #
get value(): double set value(v: double)
The current value (from
mintomax; values out of range are shown at the ends).- #
get min(): double set min(v: double)
The minimum value (default 0).
- #
get max(): double set max(v: double)
The maximum value (default 100).
- #
get fraction(): double
The progress (from 0 to 1).
- #
get text(): string
The percentage text shown at the right end (
"56%").- #
get caption(): string set caption(v: string)
The text shown at the top left.
- #
get showValue(): boolean set showValue(v: boolean)
Whether the percentage (
text) is shown at the right end.- #
get barColor(): int set barColor(v: int)
The color of the bar.
- #
get trackColor(): int set trackColor(v: int)
The color of the bar's background track.
- #
get foreColor(): int set foreColor(v: int)
The text color of
caption.- #
get valueColor(): int set valueColor(v: int)
The text color of the percentage.
- #
get barHeight(): double set barHeight(v: double)
The thickness of the bar (points).
- #
get visible(): boolean set visible(v: boolean)
Whether it is shown.
- #
get enabled(): boolean set enabled(v: boolean)
Whether the text is shown normally rather than dimmed (
falsedims it).- #
get left(): double set left(v: double)
Position of the left edge (points).
- #
get top(): double set top(v: double)
Position of the top edge (points).
- #
get width(): double set width(v: double)
Width (points).
- #
get height(): double set height(v: double)
Height (points; the text line and the bar together).
- #
get tag(): string set tag(v: string)
Any string (the
Tagof thecaptionlabel).- #
get controlTipText(): string set controlTipText(v: string)
The tip shown when the mouse hovers over it.
Class filepicker.FilePicker
A file or folder selection field. A form's FilePicker control (this.fpInput) is an object of this
class, operated by reading and writing its properties like any other control.
The dialog settings (dialogType, title, filters and so on) mean the same as in Application.FileDialog
and start from the values set in the design. Paths can also be typed or pasted into the field (the " added
by Explorer's "Copy as path" is removed when reading).
- #
dialogType: int = 3
The kind of dialog (
msoFileDialogOpen1,SaveAs2,FilePicker3,FolderPicker4). Default 3.- #
title: string = "" The title of the dialog (
""for the default title).The text of the dialog's OK button (
""for the default).- #
allowMultiSelect: boolean = false
Whether several files can be selected (when
dialogTypeis 1 or 3).- #
initialFileName: string = "" Where the dialog first opens when the field is empty (a file name or folder).
- #
initialView: int = 0
The view of the dialog (
msoFileDialogView…; 0 keeps the default).- #
filterIndex: int = 1
The file type selected first (from 1).
- #
browse(): string[]
Shows the dialog, puts the selected paths into the field and returns them. When canceled, the field is unchanged and an empty array is returned. When the field has a path, the dialog opens at that location.
- #
addFilter(description: string, extensions: string): void
Adds a file type (
addFilter("Excel workbooks", "*.xlsx; *.xlsm")). Used withdialogType1 and 3.- #
clearFilters(): void
Removes every file type (back to the dialog's default).
- #
get text(): string set text(v: string)
The text of the field (the path; separated by
;when there are several).- #
get paths(): string[]
The paths in the field as an array (split at
;or line breaks, with surrounding whitespace and"removed; an empty array when the field is empty).- #
get path(): string set path(v: string)
The first path in the field (
""if none). Assigning to it sets the field to that path.The text of the button (default
...).The width of the button (points).
- #
get visible(): boolean set visible(v: boolean)
Whether it is shown.
- #
get enabled(): boolean set enabled(v: boolean)
Whether it can be operated.
- #
get locked(): boolean set locked(v: boolean)
Whether direct editing of the field is prevented (the button can still be used to select).
- #
get left(): double set left(v: double)
Position of the left edge (points).
- #
get top(): double set top(v: double)
Position of the top edge (points).
- #
get width(): double set width(v: double)
Width (points, including the button).
- #
get height(): double set height(v: double)
Height (points).
- #
get tag(): string set tag(v: string)
Any string (the field's
Tag).- #
get controlTipText(): string set controlTipText(v: string)
The tip shown when the mouse hovers over it.
- #
setFocus(): void
Moves the focus to the field.