Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Debugger/Local Variables View    [ Add a report in this area ]  
Report #:  80974   Status: Closed
DateTime evaluator doesn't work properly in Local Variables view
Project:  Delphi Build #:  14.0.3593.25826
Version:    14.0 Submitted By:   Tom Brunberg
Report Type:  Basic functionality failure Date Reported:  1/8/2010 4:32:20 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   274371
Resolution: Fixed (Resolution Comments) Resolved in Build: : 15.0.3770.29988
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
It appears that a line, in the Local Variables view, that once has displayed a DateTime value (at least if it is 0.0) gets 'sticky', and when tracing in to subroutines the DateTime presentation remains on that line, even if the variable that should be on the line changes in type and value.

If the Local Variables view is turned off and on, the correct representation of the current variable is shown.
Steps to Reproduce:
New VCL application with a button and a memo.
In project options select:
Build configuration - Debug
Optimization - False
Use debug .dcus - True
In the buttons onclick write the following and build. Then set a breakpoint at the begin and press F9 to run.

procedure TForm1.Button1Click(Sender: TObject);
var
  dt: TDateTime;
  bb: boolean;
begin  // Breakpoint here
  bb := TryStrToDate('5.9.2009',dt);
  Memo1.Lines.Add(BoolToStr(bb,true));
  Memo1.Lines.Add(FormatDateTime('d-mmm-yyyy',dt));
end;

Press F8 once so the 'begin' is executed and look at the Local variables:

Name Value
Self ($BACE10, 'Form1', 0, $BC2...
Sender ()
dt 30.12.1899
bb False

It looks as expected, dt has a value of 0.0 therefore the base date is shown.

Press F7 to trace into 'TryStrToDate' and press F8 once to execute the 'begin'

function TryStrToDate(const S: string; out Value: TDateTime): Boolean;
var
  Pos: Integer;
begin
  Pos := 1;  // execution pointer here
  Result := ScanDate(S, Pos, Value) and (Pos > Length(S));
end;

Local variables show:

Name Value
S '5.9.2009'
Value 30.12.1899
Result 30.12.1899
Pos 13

Value is as expected, but Result is shown as it would be a DateTime variable, allthough it is a boolean

Press F8 once to execute the Pos := 1 statement
and F7 to trace into ScanDate and then a few times F8
to the line:
  if not (ScanNumber(S, Pos, N1, L1) and ...
{code:delphi}
function ScanDate(const S: string; var Pos: Integer;
  var Date: TDateTime): Boolean; overload;
var
  DateOrder: TDateOrder;
  N1, N2, N3, Y, M, D: Word;
  L1, L2, L3, YearLen: Byte;
...
begin
  Y := 0;
...
  if not (ScanNumber(S, Pos, N1, L1) and ...

Local variables shows:

Name Value
S '5.9.2009'
Pos 30.12.1899
Date 30.12.1899
Result False
DateOrder doDMY
...

Pos is not as expected.

Now, press F7 to trace into ScanNumber, and a few times F8 until the line
  ScanBlanks(S, Pos);

function ScanNumber(const S: string; var Pos: Integer;
  var Number: Word; var CharCount: Byte): Boolean;
var
  I: Integer;
  N: Word;
begin
  Result := False;
  CharCount := 0;
  ScanBlanks(S, Pos);  // execution pointer here

Local variables show:

Name Value
S '5.9.2009'
Pos 30.12.1899
Number 30.12.1899
CharCount 0
Result False
...


Pos and Number are shown as if they were DateTimes allthough they are not.

Workarounds
Turn off and on the Local Variables view
Attachment
None
Comments

None

Server Response from: ETNACODE01