MapSubstring 指令碼函數是用於將任何運算式的部分對應到先前載入的對應表。對應會區分大小寫且不反覆運算,並會從左至右對應子字串。
語法:
MapSubstring('map_name', expression)
傳回的資料類型: 字串
引數:
| 引數 | 描述 | 
|---|---|
| map_name | 之前在 mapping load 或 mapping select 陳述式中讀取的對應表格名稱。該名稱必須以一般單引號括住。 警告備註若您在巨集擴展變數中使用此函數,並參考不存在的對應表格,則函數叫用會失敗,且不會建立欄位。 | 
| expression | 應由子字串對應其結果的運算式。 | 
範例:
在此範例中,我們載入產品型號清單。每一個型號都具有一組由複合代碼描述的屬性。搭配使用對應表格與 MapSubstring,我們可以將屬性代碼展開為描述。
map2:
mapping LOAD * 
Inline [
AttCode, Attribute
R, Red
Y, Yellow
B, Blue
C, Cotton
P, Polyester
S, Small
M, Medium
L, Large
] ;
Productmodels:
LOAD *,
MapSubString('map2', AttCode) as Description
Inline [
Model, AttCode
Twixie, R C S
Boomer, B P L
Raven, Y P M
Seedling, R C L
SeedlingPlus, R C L with hood
Younger, B C with patch
MultiStripe, R Y B C S/M/L 
] ;
// We don't need the AttCode anymore
Drop Field 'AttCode';
                
產生的表格如下所示:
| Model | Description | 
|---|---|
| Twixie | Red Cotton Small | 
| Boomer | Blue Polyester Large | 
| Raven | Yellow Polyester Medium | 
| Seedling | Red Cotton Large | 
| SeedlingPlus | Red Cotton Large with hood | 
| Younger | Blue Cotton with patch | 
| MultiStripe | Red Yellow Blue Cotton Small/Medium/Large |