// (c) 2019, Questetra, Inc. (the MIT License)
//////// START "main()" ////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const dataIdA = configs.get( "conf_DataIdA" ) + ""; // config required
const cellStr = configs.get( "conf_CellStr" ) + "";
const dataIdC = configs.get( "conf_DataIdC" ) + ""; // config required
if( cellStr === "" ){
engine.log( " AutomatedTask StringWarning:" +
" CellStr is empty" );
}
//// == Data Retrieving / ワークフローデータの参照 ==
if( engine.findDataByNumber( dataIdA ) === null ){
throw new Error( "\n AutomatedTask UnexpectedStringError:" +
" String {A} is null \n" );
}
const inputTsv = (engine.findDataByNumber( dataIdA ) + "").trim();
if( inputTsv == "" ){
throw new Error( "\n AutomatedTask UnexpectedStringError:" +
" String {A} is empty \n" );
}
//// == Calculating / 演算 ==
let outputTsv = "";
const arrInputTsv = inputTsv.split("\n");
engine.log( " AutomatedTask MultilineString:" +
" String {A} as TSV, number of lines " + arrInputTsv.length );
const arrHeaderCells = arrInputTsv[0].split("\t");
engine.log( " AutomatedTask SinglelineString:" +
" TSV Header, number of cells " + arrHeaderCells.length );
for (let i=0; i < arrInputTsv.length; i++){
const arrCells = arrInputTsv[i].split("\t");
if( arrCells.length !== arrHeaderCells.length ){
throw new Error( "\n AutomatedTask UnexpectedStringError:" +
" String {A} as TSV, number of delimiters in each row must be same: Row " + i + "\n");
}
outputTsv += arrInputTsv[i] + "\t" + cellStr;
if( i !== arrInputTsv.length - 1 ){
outputTsv += "\n";
}
}
//// == Data Updating / ワークフローデータへの代入 ==
engine.setDataByNumber( dataIdC, outputTsv );
} //////// END "main()" ////////