// GraalJS Script (engine type: 2)
//
// Notes:
// Counts consecutive spaces (including tabs and double-byte spaces) as one character.
// Use C if you do not want to count linefeed codes as characters.
// Use D if you do not want to count linefeed codes and spaces as characters.
//
// Notes (ja):
// 連続する空白(タブや全角空白も含む)は全体で1文字とカウントされます。
// 改行コードを文字数にカウントしたくない場合はCを使用してください。
// 改行コードと空白を文字数にカウントしたくない場合はDを使用してください。
//////// START "main()" ////////////////////////////////////////////////////////////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const strA = configs.get( "conf_StrA" ) + ""; // required
const dataIdB = configs.get( "conf_DataIdB" ) + ""; // not required
const dataIdC = configs.get( "conf_DataIdC" ) + ""; // not required
const dataIdD = configs.get( "conf_DataIdD" ) + ""; // not required
if( strA === "" ){
engine.log( " AutomatedTask StringWarning:" +
" Config {A} is empty" );
}
//// == Data Retrieving / ワークフローデータの参照 ==
// (nothing)
//// == Calculating / 演算 ==
const strB = strA.replace(/\s+/g," ");
const strC = strA.replace(/\r|\n/g, "").replace(/\s+/g," ");
const strD = strA.replace(/\s/g,"");
// Note) Tab and double byte space are included in "\s" (UTF-8)
// including space, tab, form feed, line feed, and other Unicode spaces.
const numB = strB.length;
const numC = strC.length;
const numD = strD.length;
//// == ワークフローデータへの代入 / Data Updating ==
if( dataIdB !== "" ){
engine.setDataByNumber( dataIdB, new java.math.BigDecimal( numB ) );
}
if( dataIdC !== "" ){
engine.setDataByNumber( dataIdC, new java.math.BigDecimal( numC ) );
}
if( dataIdD !== "" ){
engine.setDataByNumber( dataIdD, new java.math.BigDecimal( numD ) );
}
} //////// END "main()" ////////////////////////////////////////////////////////////////