Xbasic

FORM.VIEW Function

IN THIS PAGE

Syntax

as P = form.view(C layoutname [,C style [,C windowname [,C position_x [,C position_y [,* arguments ]]]]])

Arguments

layoutname

The name of the form to open. In the case where there are duplicate form names in the database, you can qualify the form name with the table name using this syntax: Form [email protected] Name. For example, if a database has a form called Customers for the Current_Customers and the Past_Customers tables, you can specify the form as: [email protected]_Customers, or [email protected]_Customers.

style

Optional. Default = "". Determines the mode of the form.

Determines the mode of the form.
"" (i.e. blank value) = Open the form as a standard modeless MDI window (same as if you double click on the form in the Control Panel)
"Popup" = Open the form as a popup window.
"Dialog"= Open the form as a modal dialog box.
If a form is opened using the "Popup" style, the following rules apply:
Xbasic does not pause, as it does in the case of "Dialog" style.
The window can be moved outside of the Alpha Anywhere frame.
Alpha Anywhere menus are not active (just like "Dialog" style).
The window is not modal. (unlike "Dialog" style).
The window is always on top of all other Alpha Anywhere windows.
When Alpha Anywhere opens the form it tries to name the window the same as the form name. If a previous instance of the form is already open, then Alpha Anywhere will assign a unique name to the window by adding a digit to the end of the form name. You can explicitly assign the window name by specifying the Window name.
windowname

Not applicable.

position_x

Optional. Default = "" (i.e. use setting defined in the Form Properties dialog). The horizontal position of the window. Possible values are:

"left"
"right"
"center"
"fill"
"pixel_coordinate"
position_y

Optional. Default = "" (i.e. use setting defined in the Form Properties dialog). The vertical position of the window. Possible values are:

"top"
"bottom"
"center"
"fill"
"pixel_coordinate"
arguments

*

Description

Load and show a form

The FORM.VIEWQUERIED() method, introduced in Version 5, is more versatile than the FORM.VIEW() method because it allows you to specify an optional filter/order expression to select which records are displayed in the browse window.
It is not required to create an object pointer to reference the new form window. For example the following code fragments show that you can address the form window either by the window name, or by an object pointer.
If you do not close the form at the end of your script, you will leave the underlying table(s) open.
'Using the window name:
:form.view("customers")
:customers.maximize()
'Using the object reference
f = :form.view("customers")
f.maximize()
... do things
f.close()

If you opened a form, but did not assign an object pointer at the time you opened the form, you can still get an object pointer reference to the form using the obj()command. For example:

:form.view("customer")
f = obj(":customer")
... do things
f.close()

To load the form into memory, without displaying it, use the FORM.LOAD() method.

Debugging Aid 

When a form loads, any OnInit and onactivate scripts that are defined for the form execute. This can make debugging an application tricky. By specifying a special keyword for the Style parameter, you can load the form without having the scripts execute. For example:

frm = form.load("customer", "SCRIPT_DISABLE_EXEC")
... do things
frm.close()

Examples 

This script opens the Customer form and then maximizes the form and adds a new record.

:form.view("customer")
:customer.maximize()
:customer.new_record()
:customer:last_name.value = "Smith"
:customer:first_name.value = "John"
:customer.commit()
... do things
:customer.close()

Limitations

Desktop applications only.

See Also