Crystal Reports for Rational Application Developer 設計工具指南

While ... Do 迴圈範例 (Crystal 語法)

以下的範例會搜尋輸入字串中出現的第一個數字。假如找到數字,會傳回它在字串中的位置,否則會傳回 –1。在此範例中,將輸入字串明確地設定為字串常數,但是也可以將它設定為等於字串型別資料庫欄位。例如,輸入字串「The 7 Dwarves」時,公式會傳回 5,也就是數字 7 的位置。
Local StringVar inString := "The 7 Dwarves";
Local NumberVar strLen := Length (inString);
Local NumberVar result := -1;
Local NumberVar i := 1;
While i <= strLen And result = -1 Do
(
Local StringVar c := inString [i];
If NumericText (c) Then
result := i;
i := i + 1;
);
result




Business Objects, SAP 子公司
http://www.taiwan.businessobjects.com/
支援服務
http://www.taiwan.businessobjects.com/support/
產品說明文件網站
http://support.businessobjects.com/documentation/