home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 1997 June / Personal_Computer_World_Jun_97.iso / dxrs / refpcw06.dxr / 00059_REFUpdateDatabase.ls < prev    next >
Encoding:
Text File  |  1997-03-24  |  10.6 KB  |  340 lines

  1. on REFUpdateDatabase
  2.   global searchdata, pageselect, recordsfound, selectiveoptions, REFDatabaseSpriteInfo
  3.   repeat with g = 13 to 15
  4.     if rollOver(g) and the mouseDown then
  5.       if getAt(selectiveoptions, g - 12) = 1 then
  6.         setAt(selectiveoptions, g - 12, 0)
  7.         set the castNum of sprite g to getAt(getAt(REFDatabaseSpriteInfo, g + 3), 1) - 1
  8.         repeat while the mouseDown
  9.         end repeat
  10.         next repeat
  11.       end if
  12.       setAt(selectiveoptions, g - 12, 1)
  13.       set the castNum of sprite g to the castNum of sprite g + 1
  14.       repeat while the mouseDown
  15.       end repeat
  16.     end if
  17.   end repeat
  18.   if pageselect > 0 then
  19.     if rollOver(36) and the mouseDown and (pageselect > 1) then
  20.       set pageselect to pageselect - 1
  21.       buildresultlist()
  22.       displaylist()
  23.     end if
  24.     if rollOver(37) and the mouseDown and (pageselect < (integer(recordsfound / 12) + 1)) then
  25.       set pageselect to pageselect + 1
  26.       buildresultlist()
  27.       displaylist()
  28.     end if
  29.   end if
  30. end
  31.  
  32. on PerformSearch
  33.   global resultlist, category, supplier, product, platform, depth, issue, page, contact, selectiveoptions, searchdata
  34.   repeat with g = 27 to 34
  35.     set the locH of sprite g to 2000
  36.   end repeat
  37.   updateStage()
  38.   if searchdata = EMPTY then
  39.     beep()
  40.     put "ENTER SEARCH WORD" into field "category"
  41.     set the locH of sprite 27 to 30
  42.     put " " into field "supplier"
  43.     put " " into field "product"
  44.     put " " into field "platform"
  45.     put " " into field "depth"
  46.     put " " into field "issue"
  47.     put " " into field "page"
  48.     put " " into field "contact"
  49.     updateStage()
  50.     exit
  51.   end if
  52.   set resultlist to list()
  53.   set category to list()
  54.   set supplier to list()
  55.   set product to list()
  56.   set platform to list()
  57.   set depth to list()
  58.   set issue to list()
  59.   set page to list()
  60.   set contact to list()
  61.   makeuppercase()
  62.   if getAt(selectiveoptions, 1) = 1 then
  63.     categorycheck()
  64.   end if
  65.   if getAt(selectiveoptions, 2) = 1 then
  66.     manufacturercheck()
  67.   end if
  68.   if getAt(selectiveoptions, 3) = 1 then
  69.     productcheck()
  70.   end if
  71.   if resultlist = EMPTY then
  72.     beep()
  73.     put "NO MATCH FOUND" into field "category"
  74.     set the locH of sprite 27 to 30
  75.     put "Page 0 of  0" into field "pagexofy"
  76.     put " " into field "supplier"
  77.     put " " into field "product"
  78.     put " " into field "platform"
  79.     put " " into field "depth"
  80.     put " " into field "issue"
  81.     put " " into field "page"
  82.     put " " into field "contact"
  83.     updateStage()
  84.   else
  85.     buildresultlist()
  86.     displaylist()
  87.   end if
  88. end
  89.  
  90. on categorycheck
  91.   global searchdata
  92.   set querystring to "UPPER(PRODUCT_CA)='" & searchdata & "'"
  93.   DBQuery(querystring)
  94.   if the result = 0 then
  95.     set resultfound to 1
  96.     repeat while resultfound = 1
  97.       updatelist()
  98.       DBSkip(1)
  99.       if the result <> 0 then
  100.         set resultfound to 0
  101.       end if
  102.     end repeat
  103.   end if
  104. end
  105.  
  106. on manufacturercheck
  107.   global searchdata
  108.   set querystring to "UPPER(MANUFACTUR)='" & searchdata & "'"
  109.   put " QUERY STRING ", querystring
  110.   DBQuery(querystring)
  111.   if the result = 0 then
  112.     set resultfound to 1
  113.     repeat while resultfound = 1
  114.       updatelist()
  115.       DBSkip(1)
  116.       if the result <> 0 then
  117.         set resultfound to 0
  118.       end if
  119.     end repeat
  120.   end if
  121. end
  122.  
  123. on productcheck
  124.   global searchdata
  125.   set querystring to "UPPER(PRODUCT)='" & searchdata & "'"
  126.   DBQuery(querystring)
  127.   if the result = 0 then
  128.     set resultfound to 1
  129.     repeat while resultfound = 1
  130.       updatelist()
  131.       DBSkip(1)
  132.       if the result <> 0 then
  133.         set resultfound to 0
  134.       end if
  135.     end repeat
  136.   end if
  137. end
  138.  
  139. on updatelist
  140.   global resultlist, fieldName, fieldlengths, recordsfound, pageselect
  141.   add(resultlist, [0, 0, 0, 0, 0, 0, 0, 0, 0])
  142.   repeat with j = 1 to count(fieldnames)
  143.     set fname to getAt(fieldnames, j)
  144.     set flength to getAt(fieldlengths, j)
  145.     DBGetFieldByName(fname)
  146.     set fieldcontent to the result
  147.     if fname = "ISSUE" then
  148.       if (value(chars(fieldcontent, 5, 6)) < 1) or (value(chars(fieldcontent, 5, 6)) > 12) then
  149.         nothing()
  150.       else
  151.         set months to list("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
  152.         set monthnumber to value(chars(fieldcontent, 5, 6))
  153.         set newmonthtext to getAt(months, monthnumber) && chars(fieldcontent, 3, 4)
  154.         set fieldcontent to newmonthtext
  155.       end if
  156.     end if
  157.     set datalength to the number of chars in fieldcontent
  158.     if datalength < flength then
  159.       repeat with g = 1 to flength - datalength
  160.         set fieldcontent to fieldcontent & " "
  161.       end repeat
  162.     end if
  163.     if datalength > flength then
  164.       set fieldcontent to chars(fieldcontent, 1, flength)
  165.     end if
  166.     setAt(getAt(resultlist, count(resultlist)), j, fieldcontent)
  167.   end repeat
  168.   set recordsfound to count(resultlist)
  169.   if recordsfound > 12 then
  170.     set pageselect to 1
  171.     set the locH of sprite 36 to 330
  172.     set the locH of sprite 37 to 395
  173.   end if
  174. end
  175.  
  176. on buildresultlist
  177.   global resultlist, category, supplier, product, depth, issue, page, contact, pageselect, recordsfound
  178.   repeat with g = 2 to 9
  179.     set the locH of sprite (g + 25) to 2000
  180.   end repeat
  181.   updateStage()
  182.   set category to list()
  183.   set supplier to list()
  184.   set product to list()
  185.   set depth to list()
  186.   set issue to list()
  187.   set page to list()
  188.   set contact to list()
  189.   if pageselect > 0 then
  190.     if (pageselect * 12) < recordsfound then
  191.       repeat with g = (pageselect * 12) - 12 + 1 to pageselect * 12
  192.         add(category, getAt(getAt(resultlist, g), 1) & ":" & getAt(getAt(resultlist, g), 2))
  193.         add(supplier, getAt(getAt(resultlist, g), 3))
  194.         add(product, getAt(getAt(resultlist, g), 4))
  195.         add(depth, getAt(getAt(resultlist, g), 6))
  196.         add(issue, getAt(getAt(resultlist, g), 7))
  197.         add(page, getAt(getAt(resultlist, g), 8))
  198.         add(contact, getAt(getAt(resultlist, g), 9))
  199.       end repeat
  200.     else
  201.       repeat with g = (pageselect * 12) - 12 + 1 to recordsfound
  202.         add(category, getAt(getAt(resultlist, g), 1) & ":" & getAt(getAt(resultlist, g), 2))
  203.         add(supplier, getAt(getAt(resultlist, g), 3))
  204.         add(product, getAt(getAt(resultlist, g), 4))
  205.         add(depth, getAt(getAt(resultlist, g), 6))
  206.         add(issue, getAt(getAt(resultlist, g), 7))
  207.         add(page, getAt(getAt(resultlist, g), 8))
  208.         add(contact, getAt(getAt(resultlist, g), 9))
  209.       end repeat
  210.     end if
  211.   else
  212.     repeat with g = 1 to recordsfound
  213.       add(category, getAt(getAt(resultlist, g), 1) & ":" & getAt(getAt(resultlist, g), 2))
  214.       add(supplier, getAt(getAt(resultlist, g), 3))
  215.       add(product, getAt(getAt(resultlist, g), 4))
  216.       add(depth, getAt(getAt(resultlist, g), 6))
  217.       add(issue, getAt(getAt(resultlist, g), 7))
  218.       add(page, getAt(getAt(resultlist, g), 8))
  219.       add(contact, getAt(getAt(resultlist, g), 9))
  220.     end repeat
  221.   end if
  222. end
  223.  
  224. on displaylist
  225.   global category, supplier, product, depth, issue, page, contact, recordsfound, pageselect
  226.   set display to EMPTY
  227.   put EMPTY into field "category"
  228.   repeat with g = 1 to count(category)
  229.     set display to display & getAt(category, g) & RETURN
  230.   end repeat
  231.   put display into field "category"
  232.   set the textSize of member "category" to 9
  233.   set the boxType of member "category" to #fixed
  234.   if the machineType > 200 then
  235.     set the textFont of member "category" to "arial"
  236.   else
  237.     set the textFont of member "category" to "geneva"
  238.   end if
  239.   set display to EMPTY
  240.   put EMPTY into field "supplier"
  241.   repeat with g = 1 to count(supplier)
  242.     set display to display & getAt(supplier, g) & RETURN
  243.   end repeat
  244.   put display into field "supplier"
  245.   set the textSize of member "supplier" to 9
  246.   set the boxType of member "supplier" to #fixed
  247.   if the machineType > 200 then
  248.     set the textFont of member "supplier" to "arial"
  249.   else
  250.     set the textFont of member "supplier" to "geneva"
  251.   end if
  252.   set display to EMPTY
  253.   put EMPTY into field "product"
  254.   repeat with g = 1 to count(product)
  255.     set display to display & getAt(product, g) & RETURN
  256.   end repeat
  257.   put display into field "product"
  258.   set the textSize of member "product" to 9
  259.   set the boxType of member "product" to #fixed
  260.   if the machineType > 200 then
  261.     set the textFont of member "product" to "arial"
  262.   else
  263.     set the textFont of member "product" to "geneva"
  264.   end if
  265.   set display to EMPTY
  266.   put EMPTY into field "depth"
  267.   repeat with g = 1 to count(depth)
  268.     set display to display & getAt(depth, g) & RETURN
  269.   end repeat
  270.   put display into field "depth"
  271.   set the textSize of member "depth" to 9
  272.   set the boxType of member "depth" to #fixed
  273.   if the machineType > 200 then
  274.     set the textFont of member "depth" to "arial"
  275.   else
  276.     set the textFont of member "depth" to "geneva"
  277.   end if
  278.   set display to EMPTY
  279.   put EMPTY into field "issue"
  280.   repeat with g = 1 to count(issue)
  281.     set display to display & getAt(issue, g) & RETURN
  282.   end repeat
  283.   put display into field "issue"
  284.   set the textSize of member "issue" to 9
  285.   set the boxType of member "issue" to #fixed
  286.   if the machineType > 200 then
  287.     set the textFont of member "issue" to "arial"
  288.   else
  289.     set the textFont of member "issue" to "geneva"
  290.   end if
  291.   set display to EMPTY
  292.   put EMPTY into field "page"
  293.   repeat with g = 1 to count(page)
  294.     set display to display & getAt(page, g) & RETURN
  295.   end repeat
  296.   put display into field "page"
  297.   set the textSize of member "page" to 9
  298.   set the boxType of member "page" to #fixed
  299.   if the machineType > 200 then
  300.     set the textFont of member "page" to "arial"
  301.   else
  302.     set the textFont of member "page" to "geneva"
  303.   end if
  304.   set display to EMPTY
  305.   put EMPTY into field "contact"
  306.   repeat with g = 1 to count(contact)
  307.     set display to display & getAt(contact, g) & RETURN
  308.   end repeat
  309.   put display into field "contact"
  310.   set the textSize of member "contact" to 9
  311.   set the boxType of member "contact" to #fixed
  312.   if the machineType > 200 then
  313.     set the textFont of member "contact" to "arial"
  314.   else
  315.     set the textFont of member "contact" to "geneva"
  316.   end if
  317.   if pageselect > 0 then
  318.     put "Page" && pageselect && "of " && integer(recordsfound / 12) + 1 into field "pagexofy"
  319.   else
  320.     put "Page 1 of 1" into field "pagexofy"
  321.   end if
  322.   repeat with g = 2 to 9
  323.     set the locH of sprite (g + 25) to getAt(getAt(REFDatabaseSpriteInfo, g), 2)
  324.   end repeat
  325.   updateStage()
  326. end
  327.  
  328. on makeuppercase
  329.   global searchdata
  330.   repeat with g = 1 to the number of chars in searchdata
  331.     put charToNum(char g of searchdata)
  332.     if (charToNum(char g of searchdata) > 96) and (charToNum(char g of searchdata) < 123) then
  333.       set currentasciivalue to charToNum(char g of searchdata)
  334.       set currentasciivalue to currentasciivalue - 32
  335.       put numToChar(currentasciivalue) into char g of searchdata
  336.     end if
  337.   end repeat
  338.   put "new word: " & searchdata
  339. end
  340.