highend wrote:Optimal to build some formatted multi-line output!
Mind to post some small examples?
Still haven't got the time to get used to the heredoc syntax
Tia,
Highend
Just some
examples for my use of heredoc.
One is "stolen": the $batch= <<<WIN_CLI
All are
excerpts from scripts, and all are unrelated.
Some are rather new, others quite old.
Some with old syntax <<<..., others with new <<<#...
Some should be a bit optimized for use of the current syntax.
(This thread shows: last changes were just made by Don.)
In future
I will only use the new syntax <<<#... - it's more flexible, and creates exactly what you specify.
And for the optic I (will) prefer <<<#>>>
Here the samples:
Code: Select all
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
$isok = Confirm (<<<#>>>
Verify files to compare:
====--------------------
First File: $file1
Second File: $file2
Output File: $fileo
'Tab'-character = "$s"
EQ = "$eq"<tab>add key = "$add"
NEQ = "$neq"<tab>del key = "$del"
===> Is this OK?
#>>> ) ;
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
$batch= <<<WIN_CLI
cd /d "%~dp0"
start "" /wait /separate $unzip
REM del "$path\XYplorer.zip"
start "" /separate "$path\XYplorer.exe"
REM del "XYplorer.bat"
WIN_CLI;
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Some logic to change the (default!) layout of the toolbar.
// The $barchg= creates a list to change some strings:
// all (trimmed) strings left of "|" will be replaced by the strings right of "|"
Global $bar, $barchg; // curr Toolbar, ListOfChanges
$bar = GetKey( /* get curr Toolbar */ "Toolbar" , $s);
$barchg = <<<#>>>
mru |mru,refresh
del |del,ctb1
dp12 |dp12,syncscroll
|-,-,steps
#>>>; // ^^ Chg the (trimmed) left vals to the right vals, the last line appends.
Sub "_ReplaceInBar"; // (Parms: $bar, $barchg)
SetKey $bar , "Toolbar" , $s;
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
Text <<<#>>>
$Ptext
Anzahl Files renamed : $renamed
Anzahl Files skipped : $skipped
---
Anzahl Files gesehen : $seen
Anzahl Files ausgewählt: $selanz
List of renamed:
----------------
$fdone
List of skipped:
----------------
$fskip
#>>> , 860, 600, "'RenameSel GPX' $Pstat";
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
Text <<<#>>>
Script ended.
$nl<tab>Lines read,
$ns<tab>Sections found,
$nk<tab>Keys found,
$nne1<tab>Quoting differences (leading & trailing '"' native in File)
===============================
$nne2<tab>Real differences found.
===============================
#>>>;
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////