Multiline String, Dequeue First
Multiline String, Dequeue First
Removes the first line from the multiline string. One line less than the original string. By placing in a loop flow or in a recursive workflow, data list can be processed sequentially.
Configs
  • A: Set Multiline String *#{EL}
  • B: Select STRING DATA that stores extracted First Line (update) *
  • C: Select STRING DATA that stores Modified Multiline (update) *
Script (click to open)
// GraalJS Script (engine type: 2)
/*
NOTES
- Blank lines in multiline string "A" are deleted in advance.
- An error will occur, if the multiline string "A" is empty.
NOTE-ja
- 複数行文字列A内の空行(改行コードのみの行)は、あらかじめ削除されます
- 複数行文字列Aが空文字列の場合(となる場合)、エラーとなります
*/

//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){ 

//// == Config Retrieving / 工程コンフィグの参照 ==
const strOriginal       = configs.get( "StrConfA" ) + "";     // required
const strPocketTarget   = configs.getObject( "SelectConfB" ); // required
const strPocketModified = configs.getObject( "SelectConfC" ); // required

let strOriginal2 = strOriginal.replace(/^\n/gm, "") 
if( strOriginal2 === "" ){
  throw new Error( "\n AutomatedTask ConfigError:" +
                   " Config {A:Multiline} is empty \n" );
}


//// == Data Retrieving / ワークフローデータの参照 ==
// (nothing)


//// == Calculating / 演算 ==
let arrModified = strOriginal2.split("\n");
engine.log( " AutomatedTask Original length: " + arrModified.length );
let strTarget   = arrModified.shift();
let strModified = arrModified.join("\n");
if( strModified === "" ){
  engine.log( " AutomatedTask Modified: (empty)" );
}

//// == Data Updating / ワークフローデータへの代入 ==
engine.setData( strPocketTarget, strTarget );
engine.setData( strPocketModified, strModified );


} //////// END "main()" /////////////////////////////////////////////////////////////////


/*
APPENDIX
- Error Log sample1 (Empty or LFcode only)
    - AutomatedTask ConfigError: Config {A:Multiline} is empty
*/

Download

2020-10-15 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/multiline-string-dequeue-first/
The Addon-import feature is available with Professional or Enterprise edition.

Notes

  • Blank lines in multiline string “A” are deleted in advance.
  • An error will occur, if the multiline string “A” is empty.

Capture

Removes the first line from the multiline string. One line less than the original string. By placing in a loop flow or in a recursive workflow, data list can be processed sequentially.

Appendix

  • Error Log sample1 (Empty or LFcode only)
    • AutomatedTask ConfigError: Config {A:Multiline} is empty

See also

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: