Multiline String, Dequeue First

Multiline String, Dequeue First

Multiline String, Dequeue First
Removes the first line from a multiline string so there is one line less than the original string. By placing it in a loop or a recursive workflow the 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

The Addon-import feature is available with Professional edition.

Notes

  • Blank lines in the 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

1 thought on “Multiline String, Dequeue First”

  1. Pingback: Singleline TSV String, Extract Cell – Questetra Support

Leave a Reply

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

Scroll to Top

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading