{"id":240,"date":"2004-07-14T03:27:37","date_gmt":"2004-07-13T19:27:37","guid":{"rendered":"http:\/\/foxpro.ntsl119.com\/scr\/?p=240"},"modified":"2007-11-09T04:58:34","modified_gmt":"2007-11-08T20:58:34","slug":"workblogs-otimetotal","status":"publish","type":"post","link":"https:\/\/foxpro.ntsl119.com\/scr\/archives\/240","title":{"rendered":"workBLOGS . oTimeTotal"},"content":{"rendered":"<p>A little something something.<\/p>\n<p>It&#8217;s already <font face=\"Tahoma, Verdana, sans-serif\">2:40<\/font>AM, I&#8217;m done with a couple of Reports and I&#8217;m still online trying to annoy a VB<font face=\"Tahoma, Verdana, sans-serif\">6<\/font>-lovin&#8217;-former classmate of mine.<\/p>\n<p>To give you an overview of this late-night-to-early-morning little quest of mine, I&#8217;ll start with the target task. The objective is to add those TimeTotal and FeeTotal amounts in the reports that deals on the usage of the internet\/computer.<\/p>\n<p>So it&#8217;s something like this:<\/p>\n<table width=\"435\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\">\n<tr bgcolor=\"#CCCCCC\">\n<td><font face=\"Tahoma, Verdana, sans-serif\">&nbsp;NAME<\/font><\/td>\n<td>\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">TIME       IN <\/font><\/div>\n<\/td>\n<td>\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">TIME       OUT <\/font><\/div>\n<\/td>\n<td>\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">TIME       TOTAL <\/font><\/div>\n<\/td>\n<td>\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">TOTAL       FEE <\/font><\/div>\n<\/td>\n<\/tr>\n<tr bgcolor=\"#CCCCCC\">\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr bgcolor=\"#CCCCCC\">\n<td width=\"128\"><font face=\"Tahoma, Verdana, sans-serif\">&nbsp;Richelle<\/font><\/td>\n<td width=\"74\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">09:19:03<\/font><\/div>\n<\/td>\n<td width=\"73\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">11:05:45<\/font><\/div>\n<\/td>\n<td width=\"73\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">01:46:42<\/font><\/div>\n<\/td>\n<td width=\"75\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">44.17<\/font><\/div>\n<\/td>\n<\/tr>\n<tr bgcolor=\"#CCCCCC\">\n<td width=\"128\"><font face=\"Tahoma, Verdana, sans-serif\">&nbsp;Marv<\/font><\/td>\n<td width=\"74\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">17:32:25<\/font><\/div>\n<\/td>\n<td width=\"73\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">18:57:49<\/font><\/div>\n<\/td>\n<td width=\"73\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">01:25:24<\/font><\/div>\n<\/td>\n<td width=\"75\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">35.42<\/font><\/div>\n<\/td>\n<\/tr>\n<tr bgcolor=\"#CCCCCC\">\n<td width=\"128\"><font face=\"Tahoma, Verdana, sans-serif\">&nbsp;Teresa<\/font><\/td>\n<td width=\"74\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">20:27:22<\/font><\/div>\n<\/td>\n<td width=\"73\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">21:15:05<\/font><\/div>\n<\/td>\n<td width=\"73\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">00:47:43<\/font><\/div>\n<\/td>\n<td width=\"75\">\n<div align=\"center\"><font face=\"Tahoma, Verdana, sans-serif\">19.58<\/font><\/div>\n<\/td>\n<\/tr>\n<tr bgcolor=\"#CCCCCC\">\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr bgcolor=\"#CCCCCC\">\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<td>&nbsp;<\/td>\n<td>\n<div align=\"center\"><strong><font face=\"Tahoma, Verdana, sans-serif\">cTotalTime<\/font><\/strong><\/div>\n<\/td>\n<td>\n<div align=\"center\"><strong><font face=\"Tahoma, Verdana, sans-serif\">nTotalFee<\/font><\/strong><\/div>\n<\/td>\n<\/tr>\n<\/table>\n<p>This is just part of the data and at <font face=\"Tahoma, Verdana, sans-serif\">2<\/font>AM I&#8217;m not sure if they&#8217;re the right numbers so tone down that meticulous geek in you, I just want to present an overview.<\/p>\n<p>Generating nTotalFee is easy using VisualFoxpro&#8217;s Report Tool\/Designer. You simply create a variable, let&#8217;s say oTotalFee, store the value of the database field (USAGE.FeeTotal), set the initial value to <font face=\"Tahoma, Verdana, sans-serif\">0<\/font> and click the SUM part on the Calculate frame. You can set the variable to reset at the end of the page or at the end of the report. Just that and hardworkin&#8217; VFP will do the things automatically for you in the background while your report is being generated.<\/p>\n<p>The trickier part is the cTotalTime since it is a character (well I made it that way months ago probably to make things harder for me in the future). &#8216;<font face=\"Tahoma, Verdana, sans-serif\">01:00:00<\/font>&#8216; + &#8216;<font face=\"Tahoma, Verdana, sans-serif\">00:00:25<\/font>&#8216; is equal to &#8216;<font face=\"Tahoma, Verdana, sans-serif\">01:00:0000:00:25<\/font>&#8216; and not &#8216;<font face=\"Tahoma, Verdana, sans-serif\">01:00:25<\/font>&#8216;. I tried another couple of barfed-out-rushed patch solutions which in the end didn&#8217;t work.<\/p>\n<p>That was when I remembered that there&#8217;s a CTOT() function. But CTOT() needs additional characters such as CTOT(&#8220;<font face=\"Tahoma, Verdana, sans-serif\">2000-10-24T13:30:00<\/font>&#8220;) and the other time\/date-related functions I found were of no use, well at least in this situation. Besides I was secretly praying that none of these reserved functions would work so that I can have an excuse to do things the &#8216;old school&#8217; way.<\/p>\n<p>But before that I was even considering the lame approach of simply dividing nTotalFee with the RatePerHour and a little TimeConversion() algorithm to derive cTotalTime&#8230; a sort of a short circuit cheat.  But that my friend, is not the way things are done especially when I&#8217;m in the mood to punish myself. <\/p>\n<p>So choosing the &#8216;right&#8217; path, I entered the following manipulation inside the variable part: <\/p>\n<blockquote><p><font face=\"Tahoma, Verdana, sans-serif\">(val(substr(usage.timetotal,   1, 2))*3600) + <br \/>(val(substr(usage.timetotal, 4, 2))*60) +<br \/>(val(substr(usage.timetotal, 7, 2)))<br \/><\/font><\/p><\/blockquote>\n<p>\nIn the report, a field control is added to store this code:<\/p>\n<blockquote><p><font face=\"Tahoma, Verdana, sans-serif\">NUMTOSTR(alltrim(str(int(oTotalTime\/3600))),   2) + &#8216;:&#8217; + <br \/>NUMTOSTR(alltrim(str(int((oTotalTime%3600)\/60))), 2) + &#8216;:&#8217; + <br \/>NUMTOSTR(alltrim(str((oTotalTime%3600)%60)), 2)<\/font><\/p><\/blockquote>\n<p>\nNumToStr is a function I use to convert a number to a character field with additional &#8216;pads&#8217;. Something like NumToStr(<font face=\"Tahoma, Verdana, sans-serif\">97, 5<\/font>) would yield &#8216;<font face=\"Tahoma, Verdana, sans-serif\">00097<\/font>&#8216;. It is quite useful too in IDNumber\/Code formatting and other related functions.<\/p>\n<p>So with that&#8230; the quest was completed. <\/p>\n<p>Perhaps there are better solutions for this but for now this will do, donkey. It gives you a little taste of how things are done the &#8216;good-old-school&#8217; way.  Ah well at least a step above the older assembly\/machine code approach.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A little something something. It&#8217;s already 2:40AM, I&#8217;m done with a couple of Reports and I&#8217;m still online trying to annoy a VB6-lovin&#8217;-former classmate of mine. To give you an overview of this late-night-to-early-morning little quest of mine, I&#8217;ll start with the target task. The objective is to add those TimeTotal and FeeTotal amounts in [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10],"tags":[],"class_list":["post-240","post","type-post","status-publish","format-standard","hentry","category-visual-foxpro","category-workblog"],"_links":{"self":[{"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/posts\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/comments?post=240"}],"version-history":[{"count":0,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/posts\/240\/revisions"}],"wp:attachment":[{"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/media?parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/categories?post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/foxpro.ntsl119.com\/scr\/wp-json\/wp\/v2\/tags?post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}