Example: Creating Lookups Using Form Functions

Locked
COBS Tech Support
Site Admin
Posts: 101
Joined: Sat May 15, 2021 9:57 am

Example: Creating Lookups Using Form Functions

Post by COBS Tech Support »

The following script demonstrates how to include look-up lists using the Form***() CBS functions.

Code: Select all

Declare aTable Type Array
Declare aHeader Type Array
aTable := { { "TEST1", "TEST2", FALSE }, { "TEST3", "TEST4", TRUE } }
aHeader := { { "Header 1", 10, 1 }, { "Header 2", 10, 1 }, { "Tick", 4, 3 } }

* The Lookup function should have nPasteFrom specified when used with an Array
* Lookup(aTable,1,, "Test Title",, aHeader)
Declare cLook Type Character
cLook := 'Lookup(aTable,1,, "Test Title",, aHeader)'
FormCreate()

* This lookup button will have a script error after it is clicked the second time
FormAdd("Test No. 1", "", 25, "LookUp Test 1", , cLook)

* This lookup button will work okay after being clicked more than once
* The Headers array is given explicitly in the LookUp script, rather than passing in a CBS Array variable name
cLook := 'Lookup({ { "TEST1", "TEST2", FALSE }, { "TEST3", "TEST4", TRUE } }, 1, , "Test Title", , { { "Header 1", 10, 1 }, { "Header 2", 10, 1 }, { "Tick", 4, 3 } })'
FormAdd("Test No. 2", "", 25, "LookUp Test 2", , cLook)
FormShow()
Locked