r1 - 27 Dec 2005 - 07:47:59 - SooGuanYou are here: TWiki >  Main Web  >  ElixirEnsemble > ElixirEnsembleCookbook > DataSourceParameterLookup

Parameter Lookup

Ensemble now supports the ability for scripts to reference other GOs on the diagram.

This walk-through will work in the next auto-build:

Create a datasource called Countries with the following structure

Code,EN,FR
UK,United Kingdom,Le Royaume-Uni
SG,Singapore,Singapour
US,United States,Les Etats-Unis
MY,Malaysia,La Malaisie

I used TabularDataSource?, but you could use any kind you like.

Create a Composite DataSource? and drop Countries over it.

Create a datasource called Source with the following structure

Name,Location
Jon,UK
Shih Hor,SG

Drop Source onto the Composite and connect Source->Derivative->Result

Leave Countries unconnected

Open the Derivative and create a new field called Location (which overwrites the existing one) with the following value:

Countries.lookup("Code",Location,"EN");

View the result and you will see the Location changes from "UK" to "United Kingdom" because of the lookup.

You can always prompt the user for the language with:

Countries.lookup("Code",Location,"${Language#choice(EN,FR)#EN}");
The syntax of lookup is:
GOName.lookup(field1,value,field2);
It works with any GO, not just DataSources? (so you could perform an operation on Countries, before looking up the value). You can use this["My Long Go Name"] for graphic objects with complicated names.

It looks up the first record where field1 has value and returns the value of field2. Null will be returned if it is not found.

-- SooGuan - 27 Dec 2005

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback