You are not logged in.
Ugh, I forgot something on my previous script i edited it, please update it with the following
But this fixes it shouldn't be related with what you were talking about
const backup_file = 'C:\names_backup.txt'; var BackupLines, Pair, OldNames, NewNames: TStringsArray; I: Integer; Init, Cancel: Boolean; begin if (Cancel) then Exit; if (not Init) then begin Init := True; If (not WideFileExists(backup_file)) then begin WideShowMessage('Backup file not found on the especified path, ' + 'please check it again.') Cancel := True; Exit; end; // #13#10 => Carriage Return + Line Feed BackupLines := WideSplitString(FileReadContent(backup_file), #13#10); SetLength(OldNames, Length(BackupLines)); SetLength(NewNames, Length(BackupLines)); for I:=0 to Length(BackupLines)-1 do begin // #9 => Tabulation char Pair := WideSplitString(BackupLines[i], #9); if (Length(Pair) = 2) then begin OldNames[i] := Pair[0]; NewNames[i] := Pair[1]; end; end; SetLength(BackupLines, 0); end; FileName := ':: Name not found on the backup ::'; for I:=0 to Length(NewNames)-1 do begin If (NewNames[i] = FileName) then begin FileName := OldNames[i]; Break; end; end; end.
Weird ? I am using window XP , it doesn't work.The first code works but not above.
Did I make any mistake again ?
Offline
Weird ? I am using window XP , it doesn't work.The first code works but not above.
Did I make any mistake again ?
Damn it, I didn't pay attention to the comparison below, you were right it did not work.
Let's try again:
const
backup_file = 'C:\names_backup.txt';
var
OldNames, NewNames: TStringsArray;
Initialized, Cancel: Boolean;
procedure Initialize;
var BackupLines, Pair: TStringsArray; I: Integer;
begin
Initialized := True;
if (not WideFileExists(backup_file)) then
begin
WideShowMessage('Backup file not found on the especified path, ' +
'please check it again.')
Cancel := True;
Exit;
end;
// #13#10 => Carriage Return + Line Feed
BackupLines := WideSplitString(FileReadContent(backup_file), #13#10);
SetLength(OldNames, Length(BackupLines));
SetLength(NewNames, Length(BackupLines));
for I:=0 to Length(BackupLines)-1 do
begin
// #9 => Tabulation char
Pair := WideSplitString(BackupLines[i], #9);
if (Length(Pair) = 2) then
begin
OldNames[i] := Pair[0];
NewNames[i] := Pair[1];
end;
end;
SetLength(BackupLines, 0);
end;
function RecoverFromBackup(S: WideString): WideString;
var I: Integer;
begin
Result := ':: Name not found on the backup ::';
for I:=0 to Length(NewNames)-1 do
begin
If (NewNames[i] = S) then
begin
Result := OldNames[i];
Break;
end;
end;
end;
begin
if (Cancel) then Exit;
if (not Initialized) then Initialize();
FileName := RecoverFromBackup(FileName);
end.
If this software has helped you, consider getting your pro version. :)
Offline