Chris,
nothing not to like, simply no clue
Anyway, following Kevin's/your suggestion:
Code: Select all
FOREACH x AS FileInfo IN aFiles
VAR NewFileName :=Path.GetFileNameWithoutExtension(x:FullName)
VAR NewFullFilename := x:DirectoryName+ NewFileName + "_a" + x:Extension
VAR acLines := File.ReadAllLines(x:Fullname)
FOREACH cLine AS STRING IN acLines
IF cLine:Contains("NA=") .and. cLine:Length > 4
? cLine
? cLine:Replace(cS4P_Dolli, cPfad_S4P)
ENDIF
NEXT
File.WriteAllLines(NewFullFilename, acLines)
NEXT
Works, as it changes the content of some of the lines and creates a copy of the sourcefile with modified name.
ONLY one fault, the modified lines don't make it into the new file, there i find the old ones.
?
Thx for your patience
EDIT: Found it. The "inmutable" string thing got me - i.e. after the ? cLine:Replace() this result gets dropped.
So:
Code: Select all
FOREACH x AS FileInfo IN aFiles
VAR NewFileName :=Path.GetFileNameWithoutExtension(x:FullName)
VAR NewFullFilename := x:DirectoryName+ NewFileName + "_a" + x:Extension
VAR acLines := File.ReadAllLines(x:Fullname)
FOR VAR i := 1 UPTO acLines:Length
IF acLines[i]:Contains("NA=") .and. acLines[i]:Length > 4
VAR cNewLine:= acLines[i]:Replace(cS4P_Dolli, cPfad_S4P)
acLines[i]:= cNewLine
ENDIF
NEXT
File.WriteAllLines(NewFullFilename, acLines)
NEXT
RETURN TRUE
Works as it should. Note: Verrry sloppy code, not to be copied without adding necessary exeption handling etc. For me (that's the usual excuse) it suffices, as i'll have to use it in exactly one place maybe 5 times a year