IBM Books

Net.Data 參考手冊


字組函數

這些函數藉由修改字組或字組集來支援字串函數。Net.Data 將字組解譯為一個以空白做分隔的字串, 或者一個在兩端均具有空白的字串。這裡是幾個範例:


字串值 字組數
one two three 3
one , two , three 5
Part 2: Internet Sales Grow 5

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 支援, 無須這個變數。

下列函數是 Net.Data 支援的字組函數:

DTW_DELWORD


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

目的

傳回輸入字串的子字串。由字組 n 開始起 length 個字組會被刪除。

格式

@DTW_DELWORD(stringIn, n, length, stringOut)

@DTW_DELWORD(stringIn, n, stringOut)

@DTW_rDELWORD(stringIn, n, length)

@DTW_rDELWORD(stringIn, n)


表 61. DTW_DELWORD 參數
資料類型 參數 使用 說明
字串 stringIn IN 一個變數或文字字串。
整數 n IN 要被刪除的第一個字組的位置。
整數 length IN 要刪除的字組數目。預設值是刪除從 nstringIn 尾端的所有字組。 選用性的參數。
字串 stringOut OUT 包含 stringIn 已修改格式的 變數。

範例

範例 1

@DTW_DELWORD("Now is the time", "5", result)

範例 2

@DTW_DELWORD("Now is the time", "2", result)

範例 3

@DTW_DELWORD("Now is the time", "2", "2", result)

範例 4

@DTW_rDELWORD("Now is the time.", "3")

DTW_SUBWORD


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

目的

傳回輸入字串的子字串。子字串由字組 n 開始,一直到 length 所指定的的字組數目。

格式

@DTW_SUBWORD(stringIn, n, length, stringOut)

@DTW_SUBWORD(stringIn, n, stringOut)

@DTW_rSUBWORD(stringIn, n, length)

@DTW_rSUBWORD(stringIn, n)


表 62. DTW_SUBWORD 參數
資料類型 參數 使用 說明
字串 stringIn IN 一個變數或文字字串。
整數 n IN 子字串之第一個字組的字組位置。如果這個值大於在 stringIn 中的字組數目, 則將會傳回一個空值。
整數 length IN 在子字串中的字組數目。如果這個值大於從 nstringIn 尾端的字組數目, 則將會傳回一直到 stringIn 尾端的所有字組。 預設值是傳回所有從 nstringIn 尾端的字組。
字串 stringOut OUT 一個包含由 nlength 所指定之 stringIn 子字串的變數。

範例

範例 1

@DTW_SUBWORD("Now is the   time", "5", result)

範例 2

@DTW_SUBWORD("Now is the   time", "2", result)

範例 3

@DTW_SUBWORD(Now is the   time", "2", "2", result)

範例 4

@DTW_rSUBWORD("Now is the   time", "3")

DTW_WORD


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

目的

從所指定之輸入字串的位置中傳回一個單一字組。

格式

@DTW_WORD(stringIn, n, stringOut)

@DTW_rWORD(stringIn, n)


表 63. DTW_WORD 參數
資料類型 參數 使用 說明
字串 stringIn IN 一個變數或文字字串。
整數 n IN 所要傳回字組的位置。 如果這個值大於在 stringIn 中的字組數目, 則將會傳回一個空值。
字串 stringOut OUT 包含位於字組位置 n 之字組的變數。

範例

範例 1

@DTW_WORD("Now is the time", "3", result)

範例 2

@DTW_WORD("Now is the time", "5", result)

範例 3

@DTW_rWORD("Now is the time", "4")

DTW_WORDINDEX


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

目的

傳回輸入字串中第 n 個字組中第一個字元 的字元位置。

格式

@DTW_WORDINDEX(stringIn, n, stringOut)

@DTW_rWORDINDEX(stringIn, n)


表 64. DTW_WORDINDEX 參數
資料類型 參數 使用 說明
字串 stringIn IN 一個變數或文字字串。
整數 n IN 所要索引之字組的字組位置。 如果這個值大於在輸入字串中的字組數目,則將會傳回 0。
字串 stringOut OUT 一個包含 stringIn 之第 n 個字組之字元位置的變數。

範例

範例 1

@DTW_WORDINDEX("Now is the time", "3", result)

範例 2

@DTW_WORDINDEX("Now is the time", "6", result)

範例 3

@DTW_rWORDINDEX("Now is the time", "2")

DTW_WORDLENGTH


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

目的

傳回輸入字串中第 n 個字組的 長度。

格式

@DTW_WORDLENGTH(stringIn, n, stringOut)

@DTW_rWORDLENGTH(stringIn, n)


表 65. DTW_WORDLENGTH 參數
資料類型 參數 使用 說明
字串 stringIn IN 一個變數或文字字串。
整數 n IN 您想要知道的字組長度之字組位置。 如果這個值大於在輸入字串中的字組數目,則將會傳回 0。
字串 stringOut OUT 一個包含在 stringIn 中之第 n 個字組長度的變數。

範例

範例 1

@DTW_WORDLENGTH("Now is the time", "1", result)

範例 2

@DTW_rWORDLENGTH("Now is the time", "6")

DTW_WORDPOS


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

目的

傳回在另一個字串中,某一個字串第一次出現的字組號碼。 多重空白將以一個單一空白來看待,以供比較。對比較而言,是會區分大小寫的。

格式

@DTW_WORDPOS(stringIn1, stringIn2, n, stringOut)

@DTW_WORDPOS(stringIn1, stringIn2, stringOut)

@DTW_rWORDPOS(stringIn1, stringIn2, n)

@DTW_rWORDPOS(stringIn1, stringIn2)


表 66. DTW_WORDPOS 參數
資料類型 參數 使用 說明
字串 stringIn1 IN 一個變數或文字字串。
字串 stringIn2 IN 一個所要搜尋的變數或文字字串。
整數 n IN stringIn2 中要開始進行搜尋的字組位置。如果這個值大於在 stringIn2 中的字組數目, 則將會傳回 0。預設值是從 stringIn2 的開頭進行搜尋。
字串 stringOut OUT stringIn1stringIn2 中之的字組位置。

範例

範例 1

@DTW_WORDPOS("the", "Now is the time", result)

範例 2

@DTW_WORDPOS("The", "Now is the time", result)

範例 3

@DTW_WORDPOS("The", "Now is the time", "5", result)

範例 4

@DTW_WORDPOS("is  the", "Now is     the time", result)

範例 5

@DTW_rWORDPOS("be", "To be or not to be", "3")

DTW_WORDS


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

目的

傳回在字串中的字組數目。

格式

@DTW_WORDS(stringIn, stringOut)

@DTW_rWORDS(stringIn)


表 67. DTW_WORDS 參數
資料類型 參數 使用 說明
字串 stringIn IN 一個變數或文字字串。
字串 stringOut OUT 一個包含在 stringIn 中之字組數目的變數。

範例

範例 1

@DTW_WORDS("Now is the time", result)

範例 2

@DTW_rWORDS(" ")


[ 頁面頂端 | 前一頁 | 下一頁 | 目錄 | 索引 ]