下列的函數是由 Net.Data 所支援的 標準字串函數組:
OS/390、OS/2、Windows NT 與 UNIX 的 MBCS 支援: 您可以使用 DTW_MBMODE 架構值來指定字組與字串函數的多位元組字集(MBCS)支援。請在 Net.Data 起始設定檔案中設定這個值; 預設值是不支援。 您可以在 Net.Data 巨集檔中, 經由設定 DTW_MBMODE 變數來置換起始設定檔案中的值。請參閱 Net.Data 管理及程式設計手冊中的架構變數部分, 與DTW_MBMODE以取得有關詳細資訊。
OS/400 的 MBCS 支援:自動提供 DBCS 支援, 無須這個變數。
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
指定一個輸入變數給輸出變數。 您亦可以使用這個函數在巨集中變更變數。
格式
@DTW_ASSIGN(stringOut, stringIn)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringOut | OUT | 包含與 stringIn 相同文字字串 的變數。 |
| 字串 | stringIn | IN | 一個變數或文字字串。 |
範例
範例 1:
@DTW_ASSIGN(RC, "0")
範例 2:
@DTW_ASSIGN(string1, string2)
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
連接兩個字串。
格式
@DTW_CONCAT(stringIn1, stringIn2, stringOut)
@DTW_rCONCAT(stringIn1, stringIn2)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn1 | IN | 一個變數或文字字串。 |
| 字串 | stringIn2 | IN | 一個變數或文字字串。 |
| 字串 | stringOut | OUT | 包含字串 'stringIn1stringIn2' 的變數,其中 string1 與 string2 相連。 |
範例
範例 1:
@DTW_CONCAT("This", " is a test.", result)
範例 2:
@DTW_CONCAT(string1, "1-2-3", result)
範例 3:
@DTW_rCONCAT("This", " is a test.")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
將所指定字串中第 n 個字元起 length 個子字串刪除。
格式
@DTW_DELSTR(stringIn, n, length, stringOut)
@DTW_DELSTR(stringIn, n, stringOut)
@DTW_rDELSTR(stringIn, n, length)
@DTW_rDELSTR(stringIn, n)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn | IN | 一個變數或文字字串。 |
| 整數 | n | IN | 要開始刪除子字串的字元位置。如果 n 大於 stringIn 的長度, 則 stringOut 會被設定為 stringIn 的值。 |
| 整數 | length | IN | 所要刪除之子字串的長度。預設值是刪除所有字元,直到 stringIn 的尾端。 |
| 字串 | stringOut | OUT | 包含 stringIn 已修改格式的 變數。 |
範例
範例 1:
@DTW_DELSTR("abcde", "3", "2", result)
範例 2:
@DTW_rDELSTR("abcde", "4", "1")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
將一個字串插入至另一個字串中第 n 個字元之後開始的位置。
格式
@DTW_INSERT(stringIn1, stringIn2, n, length, pad, stringOut)
@DTW_INSERT(stringIn1, stringIn2, n, length, stringOut)
@DTW_INSERT(stringIn1, stringIn2, n, stringOut)
@DTW_INSERT(stringIn1, stringIn2, stringOut)
@DTW_rINSERT(stringIn1, stringIn2, n, length, pad)
@DTW_rINSERT(stringIn1, stringIn2, n, length)
@DTW_rINSERT(stringIn1, stringIn2, n)
@DTW_rINSERT(stringIn1, stringIn2)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn1 | IN | 被插入 stringIn2 的變數或文字字串。 |
| 字串 | stringIn2 | IN | 一個變數或文字字串。 |
| 整數 | n | IN | 字元位置是在 stringIn2 中, 其後插入 stringIn1。如果 n 大於 stringIn2 的長度,則將會使用填補字元,pad 來填補不足的字元。預設值是在 stringIn2 的開頭插入。 |
| 整數 | length | IN | 所要插入之 stringIn1 字元數目。 如果這個參數大於 stringIn1 的長度, 則將會以填補字元,pad 來填滿字串。 預設值是 stringIn1 的長度。 |
| 整數 | pad | IN | 如同 n 與 length 的說明,填補字元。預設 pad 字元是空白。 |
| 字串 | stringOut | OUT | 一個包含有插入部分或所有 stringIn1 的修改後之 stringIn2。 |
範例
範例 1:
@DTW_INSERT("123", "abc", result)
範例 2:
@DTW_INSERT("123", "abc", "5", result)
範例 3:
@DTW_INSERT("123", "abc", "5", "6", result)
範例 4:
@DTW_INSERT("123", "abc", "5", "6", "/", result)
範例 5:
@DTW_rINSERT("123", "abc", "5", "6", "+")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
傳回在另一個字串中,某一個字串最後一次出現的位置, 從第 n 個字元開始往回算(從右到左)。
格式
@DTW_LASTPOS(stringIn1, stringIn2, n, position)
@DTW_LASTPOS(stringIn1, stringIn2, position)
@DTW_rLASTPOS(stringIn1, stringIn2, n)
@DTW_rLASTPOS(stringIn1, stringIn2)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn1 | IN | 一個在 stringIn2 中被搜尋的變數或文字字串。 |
| 字串 | stringIn2 | IN | 一個變數或文字字串。 |
| 整數 | n | IN | 位於 stringIn2 中開始搜尋 stringIn1 的字元位置。預設值是從最後一個字元開始搜尋, 並往前掃描(從右至左)。 |
| 整數 | position | OUT | 在 stringIn2 中出現 最後一個 stringIn1 的位置。 如果找不到的話,將會傳回 0。 |
範例
範例 1:
@DTW_LASTPOS(" ", "abc def ghi", result)
範例 2:
@DTW_LASTPOS(" ", "abc def ghi", "10", result)
範例 3:
@DTW_rLASTPOS(" ", "abc def ghi", "7")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
傳回字串的長度。
格式
@DTW_LENGTH(stringIn, length)
@DTW_rLENGTH(stringIn)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn | IN | 一個變數或文字字串。 |
| 整數 | length | OUT | 包含 stringIn 中字元數目的符號。 |
範例
範例 1:
@DTW_LENGTH("abcdefgh",
result)
範例 2:
@DTW_rLENGTH("")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
傳回一個全部都是小寫的字串。
格式
@DTW_LOWERCASE(stringIn, stringOut)
@DTW_rLOWERCASE(stringIn)
@DTW_mLOWERCASE(stringMult1, stringMult2, ..., stringMultn)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn | IN | 一個有大小寫字元之變數或 文字字串。 |
| 字串 | stringOut | OUT | 一個包含所有都是小寫字元之 stringIn 的變數。 |
| 字串 | stringMult | INOUT |
|
範例
範例 1:
@DTW_LOWERCASE("This", stringOut)
範例 2:
@DTW_rLOWERCASE(string1)
範例 3:
@DTW_mLOWERCASE(string1, string2, string3)
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
傳回在另一個字串中,某一字串第一次出現的位置, 使用向後搜尋形式。
格式
@DTW_POS(stringIn1, stringIn2, n, nOut)
@DTW_POS(stringIn1, stringIn2, nOut)
@DTW_rPOS(stringIn1, stringIn2, n)
@DTW_rPOS(stringIn1, stringIn2)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn1 | IN | 一個所要搜尋的變數或文字字串。 |
| 字串 | stringIn2 | IN | 一個所要搜尋的變數或文字字串。 |
| 整數 | n | IN | 在 stringIn2 中開始進行搜尋的字元位 置。 預設值是開始在 stringIn2 的第一個字元進行搜尋。 |
| 整數 | nOut | OUT | 一個包含在 stringIn2 中第一個出現 stringIn1之位置的變數。 如果找不到的話,將會傳回 0。 |
範例
範例 1:
@DTW_POS("day", "Saturday", result)
範例 2:
@DTW_POS("a", "Saturday", "3", result)
範例 3:
@DTW_rPOS(" ", "abc def ghi", "5")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
將輸入字串反轉。
格式
@DTW_REVERSE(stringIn, stringOut)
@DTW_rREVERSE(stringIn)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn | IN | 一個要反轉的變數或文字字串。 |
| 字串 | stringOut | OUT | 一個包含 stringIn 之反轉格式的變數。 |
範例
範例 1:
@DTW_REVERSE("This is it.", result)
範例 2:
@DTW_rREVERSE(string1)
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
除去在輸入字串中的前導空白、尾隨之空白,或兩者。
格式
@DTW_STRIP(stringIn, option, stringOut)
@DTW_STRIP(stringIn, stringOut)
@DTW_rSTRIP(stringIn, option)
@DTW_rSTRIP(stringIn)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn | IN | 一個變數或文字字串。 |
| 字串 | option | IN | 指定要從 stringIn 中所除去的空白。 預設值是 B。
|
| 字串 | stringOut | OUT | 一個已依選項所指定除去空白之 stringIn 的變數。 |
範例
範例 1:
@DTW_STRIP(" day ",
result)
範例 2:
@DTW_STRIP(" day ", "T", result)
範例 3:
@DTW_rSTRIP(" a day ", "L")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
將輸入字串的子字串,與選用的填補字元一起傳回。
格式
@DTW_SUBSTR(stringIn, n, length, pad, stringOut)
@DTW_SUBSTR(stringIn, n, length, stringOut)
@DTW_SUBSTR(stringIn, n, stringOut)
@DTW_rSUBSTR(stringIn, n, length, pad)
@DTW_rSUBSTR(stringIn, n, length)
@DTW_rSUBSTR(stringIn, n)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn | IN | 一個所要搜尋的變數或文字字串。 |
| 整數 | n | IN | 子字串的第一個字元位置。 預設值是從 stringIn 的開頭開始 |
| 整數 | length | IN | 子字串的字元數目。 預設值是其餘的字串。 |
| 字串 | pad | IN | 如果 n 大於 stringIn 的長度, 或如果 length 長於 stringIn 時, 將會使用的填補字元。預設值是空白。 |
| 字串 | stringOut | OUT | 一個包含 stringIn 之子字串的變數。 |
範例
範例 1:
@DTW_SUBSTR("abc", "2",
result)
範例 2:
@DTW_SUBSTR("abc", "2", "4", result)
範例 3:
@DTW_SUBSTR("abc", "2", "4", ".", result )
範例 4:
@DTW_rSUBSTR("abc", "2", "6", ".")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
使用輸入和輸出轉換表格、 tableI 和 tableO 轉換輸入字串中的字元。如果 tableI、 tableO 和 default 字元不在參數列示中, 則將會把 stringIn 轉換為大寫。如果 tableI 和 tableO 都在列示中, 則將會搜尋 tableI 中輸入字串的每一個字元, 並將其轉換為在 tableO 中的相符字元。如果有一個 tableI 中的字元, 在 tableO 沒有對應的字元,則會使用 default 字元來代替。
格式
@DTW_TRANSLATE(stringIn, tableO, tableI, default, stringOut)
@DTW_TRANSLATE(stringIn, tableO, tableI, stringOut)
@DTW_TRANSLATE(stringIn, tableO, stringOut)
@DTW_TRANSLATE(stringIn, stringOut)
@DTW_rTRANSLATE(stringIn, tableO, tableI, default)
@DTW_rTRANSLATE(stringIn, tableO, tableI)
@DTW_rTRANSLATE(stringIn, tableO)
@DTW_rTRANSLATE(stringIn)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn | IN | 一個變數或文字字串。 |
| 字串 | tableO | IN | 使用作為轉換表格的變數或文字字串。請使用空值 ("") 來指定 tableI 或 default; 否則這個參數將是可選用的。 |
| 字串 | tableI | IN | 一個將在 stringIn 中被搜尋的變數或文字字串。請使用空值 ("") 來指定 default; 否則這個參數將是可選用的。 |
| 字串 | default | IN | 所使用的預設字元。 預設值是空白。 |
| 字串 | stringOut | OUT | 一個包含 stringIn 轉換結果的變數。 |
範例
範例 1:
@DTW_TRANSLATE("abbc",
result)
範例 2:
@DTW_TRANSLATE("abbc", "R", "bc", result)
範例 3:
@DTW_rTRANSLATE("abcdef", "12", "abcd", ".")
範例 4:
@DTW_rTRANSLATE("abbc", "", "", "")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
目的
傳回大寫字體的字串。
格式
@DTW_UPPERCASE(stringIn, stringOut)
@DTW_rUPPERCASE(stringIn)
@DTW_mUPPERCASE(stringMult1, stringMult2, ..., stringMultn)
值
| 資料類型 | 參數 | 使用 | 說明 |
|---|---|---|---|
| 字串 | stringIn | IN | 一個有大小寫字元之變數或 文字字串。 |
| 字串 | stringOut | OUT | 一個包含所有都是大寫字元之 stringIn的變數。 |
| 字串 | stringMult | INOUT |
|
範例
範例 1:
@DTW_UPPERCASE("Test",
result)
範例 2:
@DTW_rUPPERCASE(string1)
範例 3:
@DTW_mUPPERCASE(string1, string2, string3)