15. September 2015 00:33
function ExtractAddonFromNAVtransFile
{
param (
[parameter(Mandatory=$true)]
[string] $NAVTranslationFile)
$WorkingFolder = (get-item $NAVTranslationFile).Directory
$ExtractedFileName =
[System.IO.Path]::GetFileNameWithoutExtension($NAVTranslationFile) +"AddonExtr" +
[System.IO.Path]::GetExtension($NAVTranslationFile)
$OutPathFile = "$WorkingFolder\$ExtractedFileName"
if (Test-path $OutPathFile) {Remove-item $OutPathFile}
write-host $ExtractedFileName
foreach ($line in [System.IO.File]::ReadLines($NAVTranslationFile,[System.Text.Encoding]::GetEncoding(850)))
{
$ObjectTypeOneChar = $line.Substring(0,1)
[int]$PosDash = $line.IndexOf("-")
[int]$PosColon = $line.IndexOf(":")
$lineStart = $line.Substring(0,$PosColon)
$RawObjectID = $line.Substring(0,$posDash-1)
$ObjectID = $line.Substring(1,$posDash-1)
$line2 = $line.Substring($posDash+1)
$CaptionTypeOneChar = $line2.Substring(0,1)
[int]$PosDash2 = $line2.IndexOf("-")
$RawFieldOrTextID = $line.Substring($posDash + 1,$PosDash2)
if ($ObjectTypeOneChar -ne 'M')
{[int]$FieldOrTextID = $line.Substring($posDash + 2,$PosDash2 - 1)}
else
{[int]$FieldOrTextID = 1}
[bool]$IsAction = ($RawFieldOrTextID -eq "P55242")
if ($ISAction)
{
# Addon page actions in standard pages
[int]$ActionID = 1
$line3 = $line2.Substring($posDash2+1)
[int]$PosDash3 = $line3.IndexOf("-")
$RawActionID = $line3.Substring(0,$PosDash3-1)
if ($ObjectTypeOneChar -ne 'M')
{$ActionID = $line3.Substring(1,$PosDash3 - 1)}
else
{$ActionID = 1}
}
[bool]$IsAddonFieldText = (($FieldOrTextID -ge 5157800) -and ($FieldOrTextID -lt 5158100)) -or (($FieldOrTextID -ge 5483200) -and ($FieldOrTextID -lt 5483299))
[bool]$IsAddonObject = (($ObjectID -ge 5157800) -and ($ObjectID -lt 5158100)) -or (($ObjectID -ge 5483200) -and ($ObjectID -lt 5483299))
[bool]$IsAddonAction = (($ActionID -ge 5157800) -and ($ActionID -lt 5158100)) -or (($ActionID -ge 5483200) -and ($ActionID -lt 5483299))
[bool]$IsSourceCode = ($CaptionTypeOneChar -eq 'V')
[bool]$IsComment = ($lineStart.IndexOf("-X") -gt 0)
[bool]$IsCaption = ($lineStart.IndexOf("-A") -gt 0)
[bool]$IsMenu = ($ObjectTypeOneChar -eq 'M')
[bool]$IsModifiedStandard1 = $Collection1 -contains $line.Substring(0,8)
[bool]$IsModifiedStandard2 = $Collection2 -contains $line.Substring(0,9)
[bool]$IsModifiedStandard = ($IsModifiedStandard1 -or $IsModifiedStandard2)
if (-not$IsSourceCode -and -not$IsComment -and$IsCaption)
{
if (-$IsAddonFieldText -or -$IsAddonObject -or$IsAddonAction -or$IsMenu)
{
Write-host $line
[System.IO.File]::Appendalltext($OutPathFile,$line,[System.Text.Encoding]::GetEncoding(850))
[System.IO.File]::AppendAllText($OutPathFile,[Environment]::NewLine);
}
}
}
}
15. September 2015 17:34
-or ($CaptionTypeOneChar -eq 'U')
16. September 2015 10:04
$Collection0 = @("T85-F6-")
$Collection1 = @("T296-F4-","T298-F4-","T300-F9-")
$Collection2 = @("T300-F13-")
[bool]$IsModifiedStandard0 = $Collection0 -contains $line.Substring(0,7)
[bool]$IsModifiedStandard1 = $Collection1 -contains $line.Substring(0,8)
[bool]$IsModifiedStandard2 = $Collection2 -contains $line.Substring(0,9)
[bool]$IsModifiedStandard = ($IsModifiedStandard0 -or $IsModifiedStandard1 -or $IsModifiedStandard2)
if (-$IsAddonFieldText -or -$IsAddonObject -or $IsModifiedStandard) …
function ExtractAddonFromNAVtransFile2
{
param (
[parameter(Mandatory=$true)]
[string] $NAVTranslationFile)
$WorkingFolder = (get-item $NAVTranslationFile).Directory
$ExtractedFileName =
[System.IO.Path]::GetFileNameWithoutExtension($NAVTranslationFile) +"AddonExtr" +
[System.IO.Path]::GetExtension($NAVTranslationFile)
$OutPathFile = "$WorkingFolder\$ExtractedFileName"
if (Test-path $OutPathFile) {Remove-item $OutPathFile}
write-host $ExtractedFileName
$Collection0 = @("T85-F6-")
$Collection1 = @("T296-F4-","T298-F4-","T300-F9-")
$Collection2 = @("T300-F13-")
foreach ($line in [System.IO.File]::ReadLines($NAVTranslationFile,[System.Text.Encoding]::GetEncoding(850)))
{
$ObjectTypeOneChar = $line.Substring(0,1)
[int]$PosDash = $line.IndexOf("-")
[int]$PosColon = $line.IndexOf(":")
$lineStart = $line.Substring(0,$PosColon)
$RawObjectID = $line.Substring(0,$posDash-1)
$ObjectID = $line.Substring(1,$posDash-1)
$line2 = $line.Substring($posDash+1)
$CaptionTypeOneChar = $line2.Substring(0,1)
[int]$PosDash2 = $line2.IndexOf("-")
$RawFieldOrTextID = $line.Substring($posDash + 1,$PosDash2)
if ($ObjectTypeOneChar -ne 'M')
{[int]$FieldOrTextID = $line.Substring($posDash + 2,$PosDash2 - 1)}
else
{[int]$FieldOrTextID = 1}
[bool]$IsAction = ($RawFieldOrTextID -eq "P55242")
if ($ISAction)
{
# Addon page actions in standard pages
[int]$ActionID = 1
$line3 = $line2.Substring($posDash2+1)
[int]$PosDash3 = $line3.IndexOf("-")
$RawActionID = $line3.Substring(0,$PosDash3-1)
if ($ObjectTypeOneChar -ne 'M')
{$ActionID = $line3.Substring(1,$PosDash3 - 1)}
else
{$ActionID = 1}
}
[bool]$IsAddonFieldText = (($FieldOrTextID -ge 5157800) -and ($FieldOrTextID -lt 5158100)) -or (($FieldOrTextID -ge 5483200) -and ($FieldOrTextID -lt 5483299))
[bool]$IsAddonObject = (($ObjectID -ge 5157800) -and ($ObjectID -lt 5158100)) -or (($ObjectID -ge 5483200) -and ($ObjectID -lt 5483299))
[bool]$IsAddonAction = (($ActionID -ge 5157800) -and ($ActionID -lt 5158100)) -or (($ActionID -ge 5483200) -and ($ActionID -lt 5483299))
[bool]$IsSourceCode = ($CaptionTypeOneChar -eq 'V')
[bool]$IsComment = ($lineStart.IndexOf("-X") -gt 0)
[bool]$IsCaption = ($lineStart.IndexOf("-A") -gt 0)
[bool]$IsMenu = ($ObjectTypeOneChar -eq 'M')
[bool]$IsModifiedStandard0 = $Collection0 -contains $line.Substring(0,7)
[bool]$IsModifiedStandard1 = $Collection1 -contains $line.Substring(0,8)
[bool]$IsModifiedStandard2 = $Collection2 -contains $line.Substring(0,9)
[bool]$IsModifiedStandard = ($IsModifiedStandard0 -or $IsModifiedStandard1 -or $IsModifiedStandard2)
if (-not$IsSourceCode -and -not$IsComment -and$IsCaption)
{
if (-$IsAddonFieldText -or -$IsAddonObject -or $IsModifiedStandard -or$IsAddonAction -or$IsMenu)
{
Write-host $line
[System.IO.File]::Appendalltext($OutPathFile,$line,[System.Text.Encoding]::GetEncoding(850))
[System.IO.File]::AppendAllText($OutPathFile,[Environment]::NewLine);
}
}
}
}
16. September 2015 16:02
[bool]$IsMenu = ($ObjectTypeOneChar -eq 'M')
21. September 2015 14:17
[int]$PosColon = $line.IndexOf(":")
$lineStart = $line.Substring(0,$PosColon-1)
[bool]$IsComment = ($line.IndexOf("-X") -gt 0)
[bool]$IsCaption = ($line.IndexOf("-A") -gt 0)
[bool]$IsComment = ($lineStart.IndexOf("-X") -gt 0)
[bool]$IsCaption = ($lineStart.IndexOf("-A") -gt 0)