Form Examples

Example 1. Displaying a message box to confirm if users want to close the form.

//Display message box prompting user to confirm.

IF Form.MessageBox("Close", "Close this form?", MB_OKCANCEL) == IDOK

{

    Form.Close()

}

Note:

Example 2. Open child form while setting child form variables and parameters.

//Reset buffers.

Form.ResetChildData()

//Set query parameter for child.

Form.SetChildFormQueryParameter("pProductID", edProID)

//Set child variable.

Form.SetChildFormVariable("strProductName", edProName)

Form.OpenChildForm("Child")

Note:

Example 3. Open a file using a browse filename dialog.

//Open the filename browser dialog window.

strFilename = Form.ShowFileOpenDialog()

//If no file was selected, the method will return an empty string.

IF strFilename <> ""

{

    edTextField = File.LoadText(strFilename)

}

Note:

Example 4. Perform a synchronisation.

//Disable all sync rules.

Synchroniser.DisableAll()

//Enable

Synchroniser.EnableSyncRule("SyncAll", true)

//Perform synchronisation

Form.ShowSyncDialog(false)

Note:

Example 5. Show the first tab if password was successfully changed.

IF edtPassword <> edtConfirmPasswrd

{

    Form.MessageBox("Password", "Password entries are not the same.", MB_ICONEXCLAMATION)

}

ELSE

{

    Settings.SettingPassword = edtPassword

    Form.MessageBox("Password", "Password successfully changed. ", MB_ICONEXCLAMATION)

    edtPassword = ""

    edtConfirmPasswrd = ""

    Form.ShowTab(0)

}

Note:

Example 6. Prepare the form to create a new record.

IF blnFormNew

{

    Form.New()

}

Note:

Example 7. Automatically save the record before closing the form.

IF Form.SaveRecord() <> 0

{

    Form.MessageBox("Save", "Could not save customer details", MB_OK)

    Form.CancelOpen = true

}

Note:

Example 8. Check if it’s the last record before moving to the next record.

IF Form.IsLastRecord()

{

    Form.Close()

}

ELSE

{

    Form.MoveNext()

}

Note:

Example 9. Getting the child form variable.

IF Child.Result == 1

{

    IsAdmin = Form.GetChildFormVariable("IsAdmin")

    btnLogin = "Logout"

    IF IsAdmin

    {

        btnAdmin.Show()

    }

    btnCustomer.Show()

    btnCustomer.SetFocus()

}

Note:

Example 10. Using the Jump methods.

Pre-open expression

Form.SaveRecord()

Form.SetJumpColumn("BRAND", edtJumpBrand)

Form.SetJumpColumn("PACK", edtJumpPack)

 

Post-close expression

Form.Refresh()

Form.Jump()

Note:

Example 11. Using the Menu methods

Important Note : Submenu items can only enabled or disabled using the EnableMenuItemByIndex method. Further note that the EnableMenuItemByPosition method can only be used to enable/disable non-submenu items.

The below examples are based on two form menus :

Menu1 – User menu id = 0

               Item1 à index = 0, position = 0

               Item2 à index = 1, position = 1

               Item3 à index = 2, position = 2

 

Menu2 – User menu id = 1

               Menu2 Item  à index = 3, position = 0

               SubMenu  à index = N/A, position =1

                                Sub1 à index = 4, position = N/A

                                Sub2 à index = 5, position = N/A

               Menu2 Item3 à index = 6, position = 2 (i.e. SubMenu position =1)

Form.EnableMenuItemByIndex(1, 4, false)

Form.EnableMenuItemByIndex(1, 6, false)

Form.EnableMenuItemByIndex(0, 0, false)

Form.EnableMenuItemByIndex(0, 2, false)