lib/Str/Fmt.ps1
function Fmt-FixWdt { param( [int[]] [Parameter(Mandatory=$true)]$wdt, [object[]] $dta, [string] $qqStr=$null, [switch] $sqQuote) if($sqQuote) { $dta = Quote-Ay $dta '[]' } $wdt1 = $wdt | % { Fmt-QQ "{0,-?}" $_ } $ub = Ub $wdt1 $dta1 = (0..$ub) | % { $wdt1[$_] -f $dta[$_] } if($qqStr-eq $null) {$qqStr = Repeat '?' ($ub+1) } Fmt-QQ $qqStr $dta1 } function Fmt-QQ($qqStr,$ay) { $ay | % {$qqStr = Rpl-Sub $qqStr '?' $_ -cnt 1 }; $qqStr } function Fmt-Macro($macroStr,$hash) { return; $hash.Keys|%{Fmt-QQ $qqStr $_ $hash[$_] } } function FixWdt-FmtStr([int[]]$wdt,$qqStr=$null){ if(Is-Empty $qqStr) { $i=0 $ay = $wdt|% { "{$i,-$_}" $i+=1 } return $ay -join '' } $o=$qqStr $i=0 $wdt|% { $o = Rpl-Sub $o '?' "{$i,-$_}" -cnt 1 $i+=1 } $o -join '' } |