Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indy component issue after compile

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
So I have a Time Clock program that we built that has been having some issues, so I looked and found that some of the queries were inserting into DB2 Logicals (which is like an Indexed table). So I changed the queries to insert and use the Physical files. That was the only change to the program.

Now this section of code fails every time:
Code:
function TForm_MainClockIt.ServerDateTime: TDateTime;
begin
  //Result:= Now;       // unremark this to get time from local pc instead of
  //Exit;               // from the server.

  // NOTE:  this function will always return 0 if Delphi IDE has not been updated
  // with later version of the Indy components.  (no change is needed on the
  // user PCs).  See comments at the top of this unit.    rgh

  Try
    Result:= IdSNTP1.DateTime;
    IdSNTP1.Active:= False;
  Except
    IdSNTP1.Active:= False;
    Beep;
    MessageDlg('Can''t get correct time from Server.' + #13 +
               'Try restarting the program, or' + #13 +
               'notify your Supervisor.', mtWarning, [mbOk], 0);
    Application.Terminate;
  End;

  if Result = 0
  then
    begin
      Beep;
      Result:= Now;
      MessageDlg('Server time is not available.' + #13#13 +
                 'Notify Information Technology.', mtWarning, [mbOk], 0);
    end;

end;
and I get the message 'Server time is not available. Notify Information Technology'.

I can see that Result has a value BEFORE the Except statement. But as soon as it gets to IdSNTP1.Active Result is reset to 0. Now this code has worked in previous versions and I'm not sure what I've done that's broken it!

I used the GetVersion property of the component and it says 8.0.25. I dropped a new IdSNTP component on the form and it also has the same Version, so I don't think that's the issue.

Any help appreciated!

Thanks,
Leslie
 
When does IdSNTP1.Active get True? (I may be blind, but I can't find it)
 
I can't find it anywhere either!

Which is why i'm surprised it works in the first place!

But even when I add Active := true it doesn't change anything....

Leslie
 
no longer an issue, i've been told that I can just get the local PC time since we've implemented a group policy that doesn't allow users to change the local time.

thanks for looking!

leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top