![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#31 | |
|
Professional Programmer
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4
![]() |
Quote:
__________________
-Steven "Is this a piece of your brain?" - Basil Fawlty |
|
|
|
|
|
|
#32 | |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
Quote:
I've followed it through many times and it seems fine to me, yet when i enter a valid employee ID it somehow freezes, and i can't figure out where it gets stuck in the loop. Here's how I interpret it if i enter a valid employee number and i already have a shift thats clocked in: (how i interpret it is in bold) procedure Tfrm_clock_In.btn_enterClick(Sender: TObject);
var
Today:TDateTime;
Executed:boolean;
begin
Executed:= false;
Today:= Date;
tbl_employees.Open;
tbl_employees.First;
Repeat
if strtoint(Edit_Employee_ID.text) = tbl_employeesEmployee_ID.value then // it will find the employee number in the employee table
begin
tbl_shift.Open;
tbl_shift.First;
repeat
if (strtoint(Edit_Employee_ID.text) = tbl_shiftEmployee_ID.value) and (tbl_shiftDate_.Value = Today) then // this is also true as its the only record i have in the shift table
begin
if Datetostr(tbl_shiftTime_Out.value)='' then // The time out field is blank so it will updaet the record and then set executed to true
begin
//sql to updae file with clock out time
showmessage('Clocked Out');
Executed:=true;
end
else Tbl_shift.Next;
end
else tbl_shift.Next;
Until (Executed=true) or (tbl_shift.Eof); //executed is now true so the loop finishes
end
else tbl_employees.Next;
Until (Executed=true) or (tbl_employees.Eof); // again executed is true so this loop also ends
end; |
|
|
|
|
|
|
#33 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Again, you're not saying everything. You can look at the logic and presume Executed is true because you've entered a valid ID and updated the record, set things appropriately, and should exit. What you're not confirming (in your posts) is that you actually followed those presumptive paths. Put some output statements in each alternative path ane SEE where you actually go. If it isn't where you expect, output some values so you can SEE why it took the path. Information is actually key to debugging. It's available in your variables at certain points and more is available in status returned by the functions you use.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#34 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
Ok, you've really baffled me! I'm sorry to sound so dumb! Output statements?! you mean basically output some text sayin what it should do? And what am I not saying in my posts?
Can you actually see my error and you're making me find it for myself?! lol |
|
|
|
|
|
#35 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
There's one thing you learn over time when you're coding: when you're debugging, output information EVERYWHERE. Any time you think you might need to know what a specific variable contains, put one of these in:
ShowMessage("Variable X: " + x); |
|
|
|
|
|
#36 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
Those output statements really work! thanks!
i've worked out where the errors are and I have corrected them.I now have a delphi question, Ooble? You seem to know delphi. I need the correct code to check that there is nothing in the time out field. I was using if timetostr(tbl_shiftTime_Out)='' then... This should convert the time to a string, and then if the string is equal to nothing then to execute the code (note: '' is 2 ' and not a ")...Even though delphi accepts it, it doesn't seem to work. I entered some data into the field and retyped the code to look for it and it works fine, so its just not the right code to check for nothing. EDIT... Sussed it, just changed it to if timetostr(tbl_shiftTime_Out.value)='00:00:00' Thanks so much for your help guys. I'd say thats the hardest part of the project out of the way now. But if i need anymore help I know where i come right?! lolThanks again. Last edited by gj15987; Aug 19th, 2005 at 1:40 PM. |
|
|
|
|
|
#37 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
OH. MY. GOD. This is pissing me off too much now.
It works with 1 employee and 1 shift. But for some reason when I add another employee it goes straight to clocking them in even if they should be clocking out. I'm not asking for help this time unless anyone really wants to cus I think I'll give up and do something simpler. I've learned all about getting out of loops and putting outputs into my code to see where its going so this hasn't been a total waste of time i spose. Also, with this method, it might find a record with a clock in and clock out, but there might be another record on the same day for that user where they have not clocked out but it wont get to that one cus of the previous record! ah well. |
|
|
|
|
|
#38 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
So don't exit when you see a completed shift if there's a possibility of a subsequent uncompleted one. For one thing, I doubt you're dealing with a million shift records. For another, you could sort the DB by time so that you always encounter later ones first, if they exist. As for what you perceive to be improper operation, stick with the debug statements. Why would you take a clock in path? The variables will tell you. We hope to hell you spose it hasn't been a waste of time for you, because if it has, it's been a waste of time for us, too.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#39 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
Hehe, no really i've learned alot and I don't think I'll give up actually. I was just getting too frustrated.
|
|
|
|
|
|
#40 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
Sorry for the double post. It wont let me edit my last post.
I'm going over to the delphi bit of the forums now because I need to know how to create an index. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|