home *** CD-ROM | disk | FTP | other *** search
/ Stickerpedia Stickerbook / Stickerbook.iso / pc / DATA / objects.cxt / 00082_Script_oDataScreenBaby < prev   
Text File  |  2003-03-19  |  10KB  |  364 lines

  1. --¨
  2. oDataScreenBaby
  3.  
  4.  
  5. global  oDataBase
  6. global  oDataScreen
  7. global  oMarvin
  8. global  gDisplayDebugSortOrder
  9.  
  10.  
  11.  
  12.  
  13. on new me 
  14.   return me
  15. end
  16.  
  17.  
  18.  
  19.  
  20.  
  21. on reshuffleSimple me, kwp
  22.   put "kwp" && kwp
  23.   theKW = kwp[1] 
  24.   
  25.   if theKW = "k99" then
  26.     theKW = kwp[2] 
  27.   end if
  28.   
  29.   if theKW = "k99" then
  30.     put "nˆ nˆ"
  31.     exit
  32.   else
  33.     reshuffle me, kwp
  34.   end if
  35.   
  36. end
  37.  
  38.  
  39.  
  40.  
  41.  
  42. on reshuffleMultiple me, listOfKWPs
  43.   startTimer
  44.   numOfShuffles = listOfKWPs.count
  45.   -- repeat with pointer = 1 to numOfShuffles
  46.   --  thisKWP = listOfKWPs[pointer]
  47.   thisKWP = listOfKWPs[1]
  48.   reshuffle me, thisKWP
  49.   -- end repeat
  50.   -- put "reshuffleMultiple" && the timer/60
  51. end
  52.  
  53.  
  54.  
  55. on reshuffle me, selectedKWPID
  56.   
  57.   put "reshuffle"
  58.   -- startTimer
  59.   
  60.   selectedKWPID = kwpLstToKWPStr(oDatabase, selectedKWPID)
  61.   -- increase hit counters:
  62.   -- sort order is based on the frequency with which which the second keyword has been hit:
  63.   
  64.   oDatabase.pKWPairHits[selectedKWPID] = (oDatabase.pKWPairHits[selectedKWPID]) + 1
  65.   
  66.   secondKeyWord = "k" & selectedKWPID.char[1..2]
  67.   numberOfHitsSecondKeyWord = oDatabase.pKWHits[secondKeyWord] 
  68.   
  69.   put "secondKeyWord" && secondKeyWord
  70.   put "numberOfHitsSecondKeyWord" && numberOfHitsSecondKeyWord
  71.   
  72.   oDatabase.pKWHits[secondKeyWord]  = numberOfHitsSecondKeyWord + 1
  73.   
  74.   tempHitList = [:]
  75.   
  76.   -- go through 'pKWHits' and use values as probs and vice versa
  77.   
  78.   numOfEntries =  oDatabase.pKWHits.count
  79.   
  80.   put "numOfEntries" && numOfEntries
  81.   
  82.   repeat with pointer = 1 to numOfEntries
  83.     tempHitList.addProp(oDatabase.pKWHits[pointer], (oDatabase.pKWHits.getPropAt(pointer)))
  84.   end repeat
  85.   
  86.   sort tempHitList
  87.   
  88.   put "tempHitList" && tempHitList
  89.   
  90.   -- put "tempHitList: " & tempHitList
  91.   
  92.   sortOrderOfSingleKeyWordsList = invertPropertyListSortOrder(oMarvin, tempHitList)
  93.   
  94.   put "sortOrderOfSingleKeyWordsList" && sortOrderOfSingleKeyWordsList
  95.   
  96.   
  97.   -- put "XXX" && XXX
  98.   
  99.   -- now kWPs must be resorted according to these preferences.
  100.   -- First of all, take the top keywords and find keyword pairs which start with them:
  101.   
  102.   -- put the timer /60.0
  103.   
  104.   topBananas = []
  105.   
  106.   
  107.   
  108.   repeat with pointer = 1 to oDataScreen.pNumOfTopBananas
  109.     
  110.     thisKW = sortOrderOfSingleKeyWordsList[pointer]
  111.     
  112.     addThisListToTopBananas = []
  113.     
  114.     -- first of all we will try and find a kwp which isn't visited yet:
  115.     
  116.     if oDatabase.pNumOfKWPairs > oDatabase.pKWPSortOrder.count then 
  117.       maxValue = oDatabase.pKWPSortOrder.count
  118.     else
  119.       maxValue = oDatabase.pNumOfKWPairs
  120.     end if
  121.     -- selectedKWPID =  selectedKWP)
  122.     repeat with n = 1 to maxValue
  123.       thisKWPID   = oDatabase.pKWPSortOrder[n]
  124.       if getKeyWordPairState (me, thisKWPID) = #std then
  125.         if ("k" & thisKWPID.char[1..2]) = thisKW then
  126.           addThisListToTopBananas.add(thisKWPID)
  127.           exit repeat
  128.         end if
  129.       end if
  130.     end repeat
  131.     
  132.     
  133.     if not addThisListToTopBananas.count then
  134.       --      repeat with n = 1 to oDatabase.pNumOfKWPairs
  135.       repeat with n = 1 to maxValue
  136.         thisKWPID   = oDatabase.pKWPSortOrder[n]
  137.         if ("k" & thisKWPID.char[1..2]) = thisKW then
  138.           addThisListToTopBananas.add(thisKWPID)
  139.           exit repeat
  140.         end if
  141.       end repeat
  142.     end if
  143.     
  144.     
  145.     
  146.     numOfItems = addThisListToTopBananas.count
  147.     repeat with bananaItems = 1 to numOfItems  
  148.       topBananas.add(addThisListToTopBananas[bananaItems])
  149.     end repeat
  150.     
  151.   end repeat
  152.   
  153.   
  154.   -- put "Banana shuffling" && the timer /60.0
  155.   
  156.   
  157.   -- check whether the selected keyword is contained in pNumOfTopBananas
  158.   -- and make sure it is in position 1
  159.   
  160.   
  161.   topBananasContainsSelectedKWP = getPos(topBananas, selectedKWPID)
  162.   if topBananasContainsSelectedKWP then
  163.     topBananas.deleteAt(topBananasContainsSelectedKWP)
  164.     topBananas.addAt(1, selectedKWPID)
  165.   else
  166.     topBananas.deleteAt(topBananas.count)
  167.     topBananas.addAt(1, selectedKWPID)
  168.   end if
  169.   
  170.   -- now delete the keyWord pairs which are contained in 'topBananas' from 
  171.   -- 'pKWPSortOrder' (wherever they are); 
  172.   
  173.   
  174.   
  175.   repeat with pointer = 1 to topBananas.count
  176.     posInList = getPos(oDatabase.pKWPSortOrder, topBananas[pointer])
  177.     if posInList then oDatabase.pKWPSortOrder.deleteAt(posInList)
  178.   end repeat
  179.   
  180.   -- create a tempList to hold the future, updated pKWPSortOrder list, where these top KWPs will be placed at the begining, after the chosen KW
  181.   tempList = [:]
  182.   
  183.   localNumOfTopBananas = topBananas.count
  184.   put "oDataScreen.pNumOfTopBananas" && oDataScreen.pNumOfTopBananas
  185.   put "localNumOfTopBananas" && localNumOfTopBananas
  186.   
  187.   repeat with pointer = 1 to  localNumOfTopBananas
  188.   -- repeat with pointer = 1 to  oDataScreen.pNumOfTopBananas
  189.     tempList.addProp(symbol(string(pointer)), topBananas[pointer])
  190.   end repeat
  191.   
  192.   -- now to the kwps which didn't make it into TopBananas, which we will now add to the tempList:
  193.   remainingKWPs = oDatabase.pKWPSortOrder.count
  194.   
  195.   repeat with pointer = 1 to remainingKWPs
  196.     tempList.addProp(symbol(string(pointer+ oDataScreen.pNumOfTopBananas)), oDatabase.pKWPSortOrder[pointer])
  197.   end repeat
  198.   
  199.   -- now all we have to do is put the contents of tempList into pKWPSortOrder, and dispose of tempList:
  200.   oDatabase.pKWPSortOrder = void
  201.   oDatabase.pKWPSortOrder = tempList.duplicate()
  202.   tempList = void
  203.   
  204.   put "oDatabase.pKWPSortOrder" && oDatabase.pKWPSortOrder
  205.   
  206.   if gDisplayDebugSortOrder then
  207.     -- show status info:
  208.     member("statusKWHits").text = listToText (oMarvin, oDatabase.pKWHits)
  209.     member("statusKWSortOrder").text = listToText (oMarvin, oDatabase.pKWPSortOrder)
  210.   end if  
  211.   
  212. end
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221. on indexToKeyWordPair me, indexScreenSelection
  222.   
  223.   retval = void
  224.   
  225.   if indexScreenSelection contains ":" then
  226.     saveDelimiter = the itemdelimiter
  227.     the itemdelimiter = ":"
  228.     set firstItem = item 1 of indexScreenSelection
  229.     set secondItem = item 2 of indexScreenSelection
  230.     retVal = [firstItem, secondItem]
  231.   else
  232.     -- retVal = ["Religion","Customs, Traditions & Festivals"]
  233.   end if
  234.   return retval
  235. end
  236.  
  237.  
  238. on getKeyWordPairState me, whichKeyWordPair
  239.   retVal = ""
  240.   if oDataBase.pKWPairHits[whichKeyWordPair] then
  241.     -- KWP was visited
  242.     retVal = #vtd
  243.   else
  244.     -- KWP has not been visited
  245.     retVal = #std
  246.   end if
  247.   return retVal
  248. end
  249.  
  250.  
  251.  
  252.  
  253.  
  254. on printRecord me, showDetails
  255.   
  256.   --pPrinting = 1
  257.   
  258.   printList = []
  259.   
  260.   case the frameLabel of
  261.     "book":
  262.       bookTextMbrNumber = 1
  263.       repeat with pointer = 1 to oDataScreen.pCurNumOfBookAssets
  264.         mbrType     = member(oDataScreen.pBookAssetList[pointer], "database").type
  265.         case mbrType of
  266.           #bitmap:
  267.             printList.add( member (oDataScreen.pBookAssetList.getAt(pointer), "database") )
  268.             
  269.           #text, #field:
  270.             fieldMember          = member(("printBookText" && string(bookTextMbrNumber)), "database")
  271.             fieldMember.text     = member(oDataScreen.pBookAssetList.getPropAt(pointer), "text").text
  272.             fieldMember.fontSize = member(oDataScreen.pBookAssetList.getPropAt(pointer), "text").fontSize
  273.             bookTextMbrNumber = bookTextMbrNumber + 1
  274.             printList.add( fieldMember )
  275.         end case
  276.       end repeat
  277.       
  278.     "timeline":
  279.       TLTextMbrNumber = 1
  280.       repeat with pointer = 1 to oDataScreen.pCurNumOfTLAssets
  281.         mbrType     = member(oDataScreen.pTLAssetList[pointer], "database").type
  282.         case mbrType of
  283.           #bitmap:
  284.             printList.add( member (oDataScreen.pTLAssetList.getAt(pointer), "database") )
  285.             
  286.           #text, #field:
  287.             fieldMember          = member(("printBookText" && string(TLTextMbrNumber)), "database")
  288.             fieldMember.text     = member(oDataScreen.pTLAssetList.getPropAt(pointer), "text").text
  289.             fieldMember.fontSize = member(oDataScreen.pTLAssetList.getPropAt(pointer), "text").fontSize
  290.             TLTextMbrNumber = TLTextMbrNumber + 1
  291.             printList.add( fieldMember )
  292.         end case
  293.       end repeat
  294.       
  295.       
  296.     "standard":
  297.       fieldMember          = member("printBookText 1", "database")
  298.       fieldMember.text     = member("importText", "database").text
  299.       
  300.       printList.add(member("importPictureBasic", "database")) 
  301.       printList.add(fieldMember) 
  302.       
  303.     "sino":
  304.       fieldMember          = member("printBookText 1", "database")
  305.       fieldMember.text     = member("importText", "database").text
  306.       
  307.       printList.add(member("importPictureBasic", "database")) 
  308.       printList.add(member("importSino", "database"))
  309.       printList.add(fieldMember) 
  310.       
  311.     "video":
  312.       
  313.       fieldMember          = member("printBookText 1", "database")
  314.       fieldMember.text     = member("importText", "database").text
  315.       
  316.       printList.add(member ("importPictureBasic", "database")) 
  317.       printList.add(fieldMember) 
  318.       
  319.     "audio":
  320.       
  321.       fieldMember          = member("printBookText 1", "database")
  322.       fieldMember.text     = member("importText", "database").text
  323.       
  324.       printList.add(member ("importPictureBasic", "database")) 
  325.       printList.add(fieldMember) 
  326.       
  327.       
  328.       
  329.   end case
  330.   
  331.   if showDetails then
  332.     customalert string(printList)
  333.   else
  334.     print printList
  335.   end if
  336.   
  337.   
  338. end
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345. on getBookPicV me, whichMember
  346.   
  347.   return ((whichMember.height)/2) + 3
  348.   
  349. end
  350.  
  351.  
  352.  
  353.  
  354. on getBasicPicV me, whichMember
  355.   -- this handler does some terribly clever things which are so smart that I forgot them five minutes later. But they work!
  356.   return ((whichMember.height)/2) + (160-((whichMember.height)/2)+13)
  357. end
  358.  
  359.  
  360. on getSinoPicV me, whichMember
  361.   -- the correct position for a sino record is 360 from left and so that the top is at 333, and the bottom is at 361
  362.   return ((whichMember.height)/2) + (160-((whichMember.height)/2)+13)
  363. end
  364.