Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 19th, 2005, 11:45 AM   #31
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
Quote:
Originally Posted by DaWei
Stop and think about what you're doing, and stop and think about providing useful information in your posts.

Sounds like proper operation to me....
darn these trick questions....
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Old Aug 19th, 2005, 12:09 PM   #32
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 47
Rep Power: 0 gj15987 is on a distinguished road
Quote:
Originally Posted by DaWei
Stop and think about what you're doing, and stop and think about providing useful information in your posts.

Sounds like proper operation to me....
Yes I was just showing that the outer if works.

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;
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 12:50 PM   #33
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Aug 19th, 2005, 1:00 PM   #34
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 47
Rep Power: 0 gj15987 is on a distinguished road
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
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 1:27 PM   #35
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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);
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 19th, 2005, 2:12 PM   #36
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 47
Rep Power: 0 gj15987 is on a distinguished road
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?! lol

Thanks again.

Last edited by gj15987; Aug 19th, 2005 at 2:40 PM.
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 3:13 PM   #37
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 47
Rep Power: 0 gj15987 is on a distinguished road
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.
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 3:24 PM   #38
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Aug 19th, 2005, 4:02 PM   #39
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 47
Rep Power: 0 gj15987 is on a distinguished road
Hehe, no really i've learned alot and I don't think I'll give up actually. I was just getting too frustrated.
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 4:33 PM   #40
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 47
Rep Power: 0 gj15987 is on a distinguished road
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.
gj15987 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:20 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC