// ABTRUNCATE.SPT // // Converts old Russell 2K playback files back to the new 1 decimal // place format // // // As of Aug 8 2005, AB playback files mysteriously changed format to // truncate pennies column of price. All older files no longer // work correctly // This script will truncate a zero from the price and update the file // // Written by David Gerdes Sep 11, 2005 (Alias dpg) // This is only my 2nd ESPL program so forgive the clumsy coding. // Use at your own risk // This script searches for files named AB*.txt in directory // C:\ensign\playback and will modify those it finds meet the // change criteria // Backup all files in C:\ensign\playback before running to be safe // LIMITATIONS // for hack value, assumes AB price value is > 100 and < 1000 // This script will do the wrong thing if those conditions are // not true. var filename: string; var s: string; var dir: string; var t: string; var v: real; var x: real; var tmpfile: string; begin dir := 'C:\ensign\Playback\'; tmpfile := 'xxtmp.txt'; filename:=FindFirst(dir + 'AB*.txt'); while (length(filename)>0) do begin //writeln(filename); OpenFile (dir + filename, eReset); // read only s := ReadFile; //writeln(s); t := GetToken(2, s); t := GetToken(1, t, ':'); if (IsNumeric (t,v)) then begin if (v > 10000) then begin // Change # in S here s := 'Price ' + VartoStr (v / 10) + ':' + #10; x := v / 10; while not EOF do begin s := s + ReadFile + #10; end; CloseFile; writeln ('Modifying ' + filename + " " + VartoStr(v) + ' => ' + VartoStr(x)); DeleteFile (dir + filename); OpenFile (dir + filename, eRewrite); WriteFile (s); end; end; CloseFile; filename:=FindNext; end; FindClose; writeln (''); writeln ('Done'); end;