Code:
ReadMasFile("c:\tmp\c\PST448046010029.dat")
test :=2
MsgBox, %InputBuffer%%test%
ExitApp
ReadMasFile(File)
{
Global InputBuffer, InputCounter
SsccCheck = 003
IfNotExist, %File%
{
MsgBox, 16,, Error reading MasFile : %File%, 5
ExitApp, 99
}
Loop, Read, %File%
{
Line := A_LoopReadLine
If InStr(A_LoopReadLine, SsccCheck,0, 3) And StrLen(A_LoopReadLine) = 19
{
StringTrimLeft, Tmp, Line, 3
Line = Line + SSCC(Tmp)
}
Else If InStr(A_LoopReadLine, SsccCheck,0, 3) And StrLen(A_LoopReadLine) = 21
{
StringMid, Tmp, Line, 0, 10
StringMid, Tmp1, Line, 12, StrLen(Line)
Line = Line + SSCC(Tmp) + Tmp1
}
If TransCounter <> 0
StringReplace, Line, Line, TransBuffer0%TransCounter%, TransBuffer1%TransCounter%
InputBuffer%InputCounter% := Line
InputCounter += 1
}
}
SSCC(Code)
{
Total := 0
Loop, 17
{
If Mod(A_Index, 2) = 0 ;Even
{
StringMid, Totala, Code , A_Index, 1
Total := (Totala * 1 )+ Total
}
Else ;Odd
{
StringMid, Totala, Code , A_Index, 1
Total := (Totala * 3) + Total
}
}
Plus10 := ((Total + 9) // 10) * 10
Return Plus10 - Total
}
Contents of .dat file :
ALBAPLEX
Sortengruppe
GC1
Kundenbarcode1
Kundenbarcode2
Kundenbarcode3
Kundenbarcode4
Kundenbarcode5
Standortbarcode1
0000448046010029
Standortbarcode2
etc.......
Andre