home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / database / 8880 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  3.7 KB

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!olivea!spool.mu.edu!umn.edu!dell32.ortta.umn.edu!durai
  2. From: durai@ortta.umn.edu (Durai Venkatasubramanian)
  3. Newsgroups: comp.databases
  4. Subject: Re: Foxpro 2.0 Index Searches
  5. Message-ID: <durai.113.726420096@ortta.umn.edu>
  6. Date: 7 Jan 93 15:21:37 GMT
  7. References: <thomasd.62.726343853@tps.COM>
  8. Sender: news@news2.cis.umn.edu (Usenet News Administration)
  9. Organization: U of Mn
  10. Lines: 80
  11. Nntp-Posting-Host: dell32.ortta.umn.edu
  12.  
  13. In article <thomasd.62.726343853@tps.COM> thomasd@tps.COM (Thomas W. Day) writes:
  14.  
  15. >1) How do you do a multiple field indexed SEEK?  Meaning, I have an index 
  16. >that was created using three (3) fields, now I want to seek data on those 
  17. >fields.  Everything I try seems to bring back EOF without locating any 
  18. >related data.  A single field search (the first field of the index) works 
  19. >OK, but that's all I've managed.  Until I get this right, I'm doing all my 
  20. >data searches with LOCATE and they are slow.
  21.  
  22. Make sure the seek expression and the index expression are of the same type.
  23. For example, if you indexed character+date+number, 
  24.              you should seek char+dtoc(date)+str(num,xx).
  25.  
  26. >2) If I create several indexes, how do I keep them all current?  Are they 
  27. >all automatically updated if they are opened with SELECTs?  Or do I have to 
  28. >REINDEX after a change is made in the database with one index and then a 
  29. >search is required on a different index?
  30.  
  31. If you created compact index files (.cdx), the index files are automatically 
  32. opened (updated) whenever you open the database file.  I have found this 
  33. very useful.  All I have to do is to remember the order.
  34.  
  35. >3) Can you recommend an after-market book that details data search methods?
  36.  
  37. 1. Using Foxpro2: Slater & Arnold, Que   <good>
  38. 2. Foxpro Handbook: Tom Rettig, Bantam  <old, but lots of good tips>
  39. 3. Foxpro Programming: Olympia & Cathy, Addison Wesley  <okay>
  40. 4. Foxpro Code Book: Griver, Business One, <so so>
  41. 5. Exploring Foxpro: Martin Fox, Future Communications <stay away>
  42. 6. Foxpro2 Developers Guide: Winchell et al, M&T, <okay>
  43.  
  44. <..xxx...> my opinion 
  45.  
  46. >4) Is there a reasonable way to perform math functions on 4-digit time 
  47. >data?  The data is derived by the TIME() function but is stored 
  48. >in a character field as 99:99 (hour:minute) character data.  What I want to 
  49. >do is subtract two fields stored this way in each record and obtain the 
  50. >average time between each of these fields.  Obviously, 15:01-14.58 should 
  51. >equal something other than 00:43.  Is there a convert-text-to-time (CTOT?) 
  52. >function?
  53.  
  54. You can find out the numeric equivalent of hrs, mts, secs (from data out of 
  55. the time() function).
  56. hrs =  val(substr(time(), 1, 2)
  57. mts =  val(substr(time(), 4, 2)
  58. secs = val(substr(time(), 7, 2)
  59.  
  60. The following udfs, are from Tom Rettig's Foxpro Handbook (page 779):
  61.  
  62. function stots
  63. * syntax: stots(N seconds);
  64.   action: convert numeric seconds into time string;
  65.   return: time string in the format hh:mm:ss
  66. parameters seconds
  67. if seconds <= 0
  68.  return "00:00:00"
  69. else
  70.  return strtran(str(int(mod(seconds/3600,24)),2)+":"+;
  71.                 str(int(mod(seconds/60,60)),2)+":"+;
  72.                 str(int(mod(seconds,60)),2)," ","0")
  73. endif
  74. *eof
  75.  
  76. function tstos
  77. * syntax: tstos(time string);
  78.   action: convert time string to numeric seconds;
  79.   return: N seconds
  80. parameters timestring
  81. if not (between(substr(timestring,1,2),"00","23") and ;
  82.         between(substr(timestring,4,2),"00","59") and ;
  83.         between(substr(timestring,7,2),"00","59") and ;
  84.         substr(timestring,3,1) == ":" ;
  85.         substr(timestring,6,1) == ":" ;
  86.    return 0  && invalid time string
  87. else
  88.    return val(substr(timestring,1,2))*3600 + ;
  89.           val(substr(timestring,4,2))*60 + ;
  90.           val(substr(timestring,7,2))
  91. endif
  92. *eof
  93.