Files
comun/skills/roa-vfp-frx-report/scripts/frx_convert.ps1
2026-09-24 23:07:59 +03:00

21 lines
1.5 KiB
PowerShell

# frx_convert.ps1 - converteste un raport VFP .frx <-> .fr2 cu FoxBin2Prg (fara IDE).
# .frx -> .fr2 (BIN2PRG): textul editabil/diffabil. .fr2 -> .frx + .frt (PRG2BIN): regenerare
# dupa editarea textului. Extensia fisierului dat decide directia; verifica iesirea asteptata.
# Utilizare:
# powershell -File frx_convert.ps1 -Path Rapoarte\raport.frx # scrie raport.fr2
# powershell -File frx_convert.ps1 -Path Rapoarte\raport.fr2 # scrie raport.frx + .frt
param(
[Parameter(Mandatory=$true)][string]$Path,
[string]$Exe = 'D:\ROA\UTIL\foxbin2prg\FoxBin2Prg.EXE'
)
$ErrorActionPreference = 'Stop'
if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) { Write-Output ('frx_convert: nu gasesc ' + $Path); exit 2 }
if (-not (Test-Path -LiteralPath $Exe -PathType Leaf)) { Write-Output ('frx_convert: nu gasesc FoxBin2Prg ' + $Exe); exit 2 }
$ext = [IO.Path]::GetExtension($Path).ToLower()
if ($ext -eq '.frx') { $out = [IO.Path]::ChangeExtension($Path, '.fr2') }
elseif ($ext -eq '.fr2') { $out = [IO.Path]::ChangeExtension($Path, '.frx') }
else { Write-Output ('frx_convert: extensie neasteptata ' + $ext + ' (doar .frx/.fr2)'); exit 2 }
$p = Start-Process -FilePath $Exe -ArgumentList ('"' + $Path + '"') -Wait -WindowStyle Hidden -PassThru
if ($p.ExitCode -eq 0 -and (Test-Path -LiteralPath $out)) { Write-Output ('frx_convert: OK -> ' + $out); exit 0 }
Write-Output ('frx_convert: ESUAT (exit ' + $p.ExitCode + '), nu a aparut ' + $out); exit 1