Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Compiler seems to refuse to execute a single line of code (TDateTime related?)

Posted on 2004-10-23
Medium Priority
Last Modified: 2010-04-05
This is how my code looks (the second method has been simplified significantly in my attempt to solve this problem myself):

procedure TPrintClippingLabels.PopulateDates(
  ASearchInfo: TKey);
  iI:        integer;
  aDateList: TClippingLabelDateList;
  //  Fill in the dateComboBox with dates corresponding to the chosen media
  aDateList := TConnection.GetInstance.GetClippingLabelDates(ASearchInfo);

  {Make an improvised index of mediaID/Date so the date can be retrieved in
  TDateTime format}
  SetLength(aRegistrations, High(aDateList) + 1);
  for iI := Low(aDateList) to High(aDateList) do begin
    with aRegistrations[iI] do begin
      MediaID := ASearchInfo;
      RegistrationDate := ADateList[iI];

and where my little improvised index is used:

procedure TPrintClippingLabels.UpdateAmount(AMedia: TKey;
  ADate: string);
  iI: integer;
  dTrueDate: TDateTime;
  sDateConversionHolder: string;
  bMediaAlike: boolean;
  bDateAlike: boolean;
  //  Update FUI.lblAmount with the correct amount of labels to be printed

  // Find the TDateTime corresponding to the string retrieved from the GUI
  for iI := Low(aRegistrations) to High(aRegistrations) do

    dTrueDate := aRegistrations[iI].RegistrationDate;



and here are the type definitions of the custom datatypes:

  TClippingLabelInfoList = array of TClippingLabelInfo;
  TKey = type integer;
  TRegistration = record  //  aRegistrations is a unit-wide variable of this type
    MediaID: TKey;
    RegistrationDate: TDateTime;

The idea is that I store list of ID's (integer) and  TDateTimes in aDateList so that, when the date has been presented to the user and he's chosen a single date (it has been passed through the DateTimeToString procedure to make it presentable in a combobox), I can compare the stored values of aDateList (also passed through DateTiemToString) to the text coming from the ComboBox of the GUI and thereby ascertain which TDateTime that corresponds to the text passed from the GUI.

Now my problem is, when I'm stepping through my program the line dTrueDate := aRegistrations[iI].RegistrationDate; is not executed! The compiler seems to just skip the line, no eror message or anything! I've tried everything I could think of at least twice, to no avail and I'm about ready to start breaking stuff!

I hope this is enough of the code for you guys to help me, otherwise just ask and I'll post whatever you need!

By the way I'm using Delphi 5 pro on a windows XP pro machine.

Any help would be greatly appreciated!

Question by:Xenix
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 17

Accepted Solution

mokule earned 2000 total points
ID: 12390743
It is skip because of optimization.
It is local variable not used anywhere.
LVL 17

Expert Comment

ID: 12390762
You should either make it global or use in assignment ( as right argument) or as a procedure call argument.

The same is for example with a procedure which is not called anywhere in the program.
The code for such a procedure is not generated at all.

Notice that there is no blue dot on left margin in an editor pane for these lines of code.

Author Comment

ID: 12392141
Annoying as it is to have spend so much time trying to solve a problem that wasn't REALLY there, you are right!

As soon as I ignored the problem and continued with my code the problem solved itself, aparently I had no clue as to how the compiler does optimization.
Not that I would do it when the program is to be compiled finally, but there is an option somewhere in the IDE to switch off optimization, right?

Author Comment

ID: 12392144
Oh, and by the way, thanks so much for your help!

You saved both windows and furniture in my apartment :)

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question