home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Demos / Component Software / FileFlex 2.0.3.sit / FileFlex 2.0.3 / Unsupported & Undocumented / RESTGUID / RESTGUID.DIR / 00003.ls < prev    next >
Encoding:
Text File  |  1996-07-23  |  4.3 KB  |  126 lines

  1. on doUniqList indexID, byNameField, outputList
  2.   global stateDB, restDB, fullstateDEX, stateDEX, cuisineDEX, specialtyDEX, abbrevstateDEX
  3.   set DBResult to DBSelect(restDB)
  4.   checkFail(DBResult, "Error selecting restaurant data file.")
  5.   set DBResult to DBSelectIndex(indexID)
  6.   checkFail(DBResult, "Error selecting index file.")
  7.   set DBResult to DBTop()
  8.   checkFail(DBResult, "Error moving to top of database.")
  9.   set lastFound to EMPTY
  10.   set resultList to EMPTY
  11.   repeat while 1 = 1
  12.     set theName to DBGetFieldByName(byNameField)
  13.     if indexID = stateDEX then
  14.       set DBResult to DBSelect(stateDB)
  15.       checkFail(DBResult, "Error selecting state data file.")
  16.       set DBResult to DBSelectIndex(fullstateDEX)
  17.       checkFail(DBResult, "Error selecting full state index file.")
  18.       set theExpr to DBBuildSeekExpr(abbrevstateDEX, theName)
  19.       set DBResult to DBSeek(theExpr)
  20.       if DBResult = 3 then
  21.         set theName to "<unknown state>"
  22.       else
  23.         set theName to DBGetFieldByName("FULLNAME")
  24.       end if
  25.       set DBResult to DBSelect(restDB)
  26.       checkFail(DBResult, "Error selecting restaurant data file.")
  27.       set DBResult to DBSelectIndex(indexID)
  28.       checkFail(DBResult, "Error selecting index file.")
  29.     end if
  30.     if theName <> lastFound then
  31.       if resultList <> EMPTY then
  32.         put RETURN after resultList
  33.       end if
  34.       set lastFound to theName
  35.       put theName after resultList
  36.     end if
  37.     set DBResult to DBSkip(1)
  38.     if DBResult = 3 then
  39.       put resultList into field outputList
  40.       exit
  41.     end if
  42.   end repeat
  43. end
  44.  
  45. on resetQuery
  46.   global byCuisineVal, bySpecialtyVal, byStateVal
  47.   set byCuisineVal to EMPTY
  48.   set bySpecialtyVal to EMPTY
  49.   set byStateVal to EMPTY
  50.   put EMPTY into field "specialtyList"
  51.   put EMPTY into field "cuisineList"
  52.   put EMPTY into field "stateList"
  53.   put EMPTY into field "query expression"
  54.   put EMPTY into field "info"
  55.   put EMPTY into field "matchList"
  56.   set the hilite of member "by specialty" to 0
  57.   set the hilite of member "by cuisine" to 0
  58.   set the hilite of member "by state" to 0
  59.   set the hilite of member "reservations accepted" to 0
  60.   set the hilite of member "valet parking available" to 0
  61.   set the hilite of member "credit cards accepted" to 0
  62.   set the hilite of member "handicap access available" to 0
  63.   set the hilite of member "find by criteria" to 0
  64.   set the hilite of member "find all" to 1
  65.   set the loc of sprite 24 to point(21, 113)
  66.   updateStage()
  67. end
  68.  
  69. on buildQueryExpr
  70.   global byStateVal, bySpecialtyVal, byCuisineVal, restDB, stateDB, abbrevstateDEX
  71.   set singleQuote to "'"
  72.   set theExpr to EMPTY
  73.   if byStateVal <> EMPTY then
  74.     if theExpr <> EMPTY then
  75.       put " .AND. " after theExpr
  76.     end if
  77.     set DBResult to DBSelect(stateDB)
  78.     checkFail(DBResult, "Error selecting state data file.")
  79.     set DBResult to DBSelectIndex(fullstateDEX)
  80.     checkFail(DBResult, "Error selecting state abbreviation index.")
  81.     set seekExpr to DBBuildSeekExpr(fullstateDEX, byStateVal)
  82.     set DBResult to DBSeek(seekExpr)
  83.     set abbrevstate to DBGetFieldByName("ABBREV")
  84.     put "STATE = " & singleQuote & abbrevstate & singleQuote after theExpr
  85.     set DBResult to DBSelect(restDB)
  86.     checkFail(DBResult, "Error selecting restaurant data file.")
  87.   end if
  88.   if byCuisineVal <> EMPTY then
  89.     if theExpr <> EMPTY then
  90.       put " .AND. " after theExpr
  91.     end if
  92.     put "CUISINE = " & singleQuote & byCuisineVal & singleQuote after theExpr
  93.   end if
  94.   if bySpecialtyVal <> EMPTY then
  95.     if theExpr <> EMPTY then
  96.       put " .AND. " after theExpr
  97.     end if
  98.     put "SPECIALITY = " & singleQuote & bySpecialtyVal & singleQuote after theExpr
  99.   end if
  100.   if the hilite of member "Reservations accepted" = 1 then
  101.     if theExpr <> EMPTY then
  102.       put " .AND. " after theExpr
  103.     end if
  104.     put "RESERVE = .T." after theExpr
  105.   end if
  106.   if the hilite of member "Credit cards accepted" = 1 then
  107.     if theExpr <> EMPTY then
  108.       put " .AND. " after theExpr
  109.     end if
  110.     put "CREDITCARD = .T." after theExpr
  111.   end if
  112.   if the hilite of member "Valet parking available" = 1 then
  113.     if theExpr <> EMPTY then
  114.       put " .AND. " after theExpr
  115.     end if
  116.     put "VALET = .T." after theExpr
  117.   end if
  118.   if the hilite of member "Handicap access available" = 1 then
  119.     if theExpr <> EMPTY then
  120.       put " .AND. " after theExpr
  121.     end if
  122.     put "ACCESS = .T." after theExpr
  123.   end if
  124.   put theExpr into field "query expression"
  125. end
  126.