FORM.LOAD Function
Syntax
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 Name@Table 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: Customers@Current_Customers, or Customers@Past_Customers.
- style
Optional. Default = "Dialog".
- Determines the mode of the form.
- >
- "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 = "center". The horizontal position of the window. Possible values are: "left" "right" "center" "fill" "pixel_coordinate"
- position_y
Optional. Default = "center". The vertical position of the window. Possible values are: "top" "bottom" "center" "fill" "pixel_coordinate"
- arguments
*
- ops
*
Description
The FORM.LOAD() method loads Form_Name into memory and returns an object pointer. The form window is hidden. To display the window, you must use the <FORM>.SHOW() method. Use the FORM.LOAD() method rather than the FORM.VIEW() or FORM.VIEWQUERIED() methods when you want to manipulate objects on the form, or set form properties, before making the form window visible.
Example
This script loads the Customer form into memory. It then sets the form's filter and order properties and then shows the form.
Form.load("customer") :customer:Tables:customer.filter_expression = "State_prov = 'MA' " :customer:Tables:customer.order_expression = "Company" :customer:Tables:customer.query() :customer.show() :customer.activate()
This script does the same as the previous script. It uses object pointers rather than the object name.
dim frm as P frm = Form.load("customer") frm:Tables:customer.filter_expression = "State_prov = 'MA' " frm:Tables:customer.order_expression = "Company" frm:Tables:customer.query() frm.show() frm.activate()
This script does the same as the above two scripts, but it uses the FORM.VIEWQUERIED() method.
filter = "State_prov = 'MA'" order = "Company" frm = Form.viewQueried("customer",filter,order)
Using the Dialog Style to Prepare a Form with Default Values
This technique allows you to prepare the form with default values before showing it to the user. Note : You must end with the <FORM>.CLOSE() method or you will eventually run out of sessions.
dim frm as P frm = form.load("DialogForm1","dialog") ' create a new record and set default values frm.New_Record() frm:Lastname.text = "Rabins" frm:Firstname.text = "Selwyn" ' now show the form frm.show() ' the user inputs values into the fields ' the user closes the form, but actually just hides it 'now, really close the form frm.close()
Using the Dialog Style to Capture User Input
This script shows how to use a form bound to a "dummy" table to capture user input. The form fields are based on local variables. You could achieve the same effect with an Xdialog form. Note : You must end with the <FORM>.CLOSE() method or you will eventually run out of sessions.
dim frm as P frm = form.load("DialogForm1", "dialog") ' show the form - script will pause and wait till user 'closes' the form frm.show() ' the user inputs values into the fields ' the user closes the form, but actually just hides it ' you can now read field values if you wish lastname = frm:lastname.text firstname = frm:firstname.txt 'now, really close the form frm.close()
Limitations
Desktop applications only.
See Also