%CHECKR(comparator : base {: start})
%CHECKR は、ストリング・コンパレーター の中に現れない文字を含むストリング 基底 の、末尾の位置を戻します。基底 のすべての文字が コンパレーター にも現れていれば、関数は 0 を戻します。
検査は開始位置から始められ、コンパレーター・ストリングに含まれていない文字が見付かるまで、左方へと続けられます。 開始位置のデフォルトの値は、ストリングの末尾です。
1 番目のパラメーターのタイプは、文字、図形、UCS-2、固定または可変長でなければなりません。2 番目 のパラメーターは、1 番目のパラメーターと同じタイプである必要があります。 3 番目のパラメーターが指定されている場合、それは、小数点以下の桁数がゼロである非浮動数値でなければなりません。
詳細については、ストリング命令または 組み込み関数を参照してください。
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+.... *--------------------------------------------- * If a string is padded at the end with some * character other than blanks, the characters * cannot be removed using %TRIM. * %CHECKR can be used for this by searching * for the last character in the string that * is not in the list of "pad characters". *--------------------------------------------- D string1 s 50a varying D inz('My *dog* Spot.* @ * @ *') D string2 s 50a varying D inz('someone@somewhere.com') D padChars C ' *@' /free %len(string1) = %checkr(padChars:string1); // %len(string1) is set to 14 (the position of the last character // that is not in "padChars"). // string1 = 'My *dog* Spot.' %len(string2) = %checkr(padChars:string2); // %len(string2) is set to 21 (the position of the last character // that is not in "padChars"). // string2 = 'someone@somewhere.com' (the string is not changed) /end-free
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+.... *------------------------------------------------------ * A string contains a numeric value, but it might * be surrounded by blanks and asterisks and might be * preceded by a currency symbol. *------------------------------------------------------ D string s 50a varying inz('$****12.345*** ') /free // Find the position of the first character that is not one of ' $*' numStart = %CHECK (' $*' : string); // = 6 // Find the position of the last character that is not one of ' *' numEnd = %CHECKR (' *' : string); // = 11 // Extract the numeric string string = %SUBST(string : numStart : numEnd - numStart + 1); // = '12.345' /end-free
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.