home *** CD-ROM | disk | FTP | other *** search
/ Stickerpedia Stickerbook / Stickerbook.iso / pc / DATA / objects.cxt / 00061_Script_oAssetHQ < prev    next >
Text File  |  2003-03-19  |  25KB  |  743 lines

  1. --¨
  2. oAssetHQ
  3.  
  4.  
  5. global  oHQ
  6. global  oAssetHQ
  7. global  oFileIO
  8. global  oMarvin
  9. global  gPathDelim            -- "\" or ":" depending on the platform
  10. global  gCDPath
  11.  
  12.  
  13. property  pCallingSection       -- can be: #themes, #index, #introduction, #maps, #timeline, #bookmark
  14. property  pChosenSelection      -- can contain custom data, or default data, if user accesses datascreen for the first time
  15.  
  16.  
  17. property  pAssetPath            -- the pathname to the assets folder
  18.  
  19.  
  20. property  pPictureBasicList     -- Contains a list of all bitmap files in the assets\pictures\basic    folder
  21. property  pPictureBookList      -- Contains a list of all bitmap files in the assets\pictures\book     folder
  22. property  pPictureLargeList     -- Contains a list of all bitmap files in the assets\pictures\large    folder
  23. property  pPictureTimeLineList  -- Contains a list of all bitmap files in the assets\pictures\timeline folder
  24.  
  25. property  pIconList             -- Contains a list of all icon members in the 'icons' cast
  26.  
  27. property  pVideoList            -- Contains a list of all video files in the assets\video folder
  28. property  pAudioList            -- Contains a list of all audio files in the assets\audio folder
  29. property  pTextList             -- Contains a list of all text members in the 'text' cast
  30.  
  31. property  pAssetIndex           -- this list has an entry for every record as a property; the value assigned to it contains the assets associated to it
  32.  
  33. property  pIndexErrorLog        -- this variable contains a list of all erros that occur while trying to index the asset lists
  34.  
  35. property  pNumOfRecs            -- the number of records contained in the database, stored here once rather than doing lots of count(x)
  36.  
  37. property  pCurRecDetailsLst     -- If a record was selected, this list contains four properties
  38. ---------------------------------- #pictures, #au, #vi, #te
  39.  
  40.  
  41.  
  42. property  pImpMbrTxt            -- contains the member reference to the blank   text      member used for importfileInto
  43. property  pImpMbrPicBasic       -- contains the member reference to the blank   basic Picture   member used for importfileInto
  44. property  pImpMbrPicLarge       -- contains the member reference to the blank   large  Picture   member used for importfileInto
  45. property  pImpMbrPicSino        -- contains the member reference to the blank   sino Picture   member used for importfileInto
  46. property  pImpMbrVideo          -- contains the member reference to the blank   Video     member used for importfileInto
  47. property  pImpMbrAudio          -- contains the member reference to the blank   Audio     member used for importfileInto
  48. property  pImportMbrBookList    -- contains a list of member references for book picture import
  49. property  pCurRecord            -- the record number of the record currently being didplaued
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. on new me, updateMode
  57.   
  58.   addObject me
  59.   
  60.   pAssetPath          = gCDPath & "assets" & gPathDelim
  61.   pIndexErrorLog      = ""
  62.   pImpMbrTxt          =  member ("importText", "database")
  63.   pImpMbrPicBasic     =  member ("importPictureBasic", "database")
  64.   pImpMbrPicLarge     =  member ("importPictureLarge", "database")
  65.   pImpMbrPicSino      =  member ("importSino", "database")
  66.   pImpMbrVideo        =  member ("importvideo", "database")
  67.   pImpMbrAudio        =  member ("importaudio", "database")
  68.   pImportMbrBookList  = [member ("importPictureBook 1", "database"), member ("importPictureBook 2", "database"), member ("importPictureBook 3", "database"), member ("importPictureBook 4", "database")]
  69.   
  70.   
  71.   if updateMode = #update then
  72.     initImportMembers me
  73.     
  74.     -- uncomment the next to lines, when assets have changed:
  75.     makeAssetList me
  76.     createIndex me
  77.     writeAllListsToFile me
  78.     
  79.   else
  80.     getAllListsFromFile
  81.     
  82.     --fixAssetIndex me
  83.   end if
  84.   
  85.   return me  
  86.   
  87. end
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. on fixAssetIndex me
  96.   numOfEntries = pAssetIndex.count  
  97.   
  98.   -- repeat with n = 1 to 100
  99.   repeat with n = 1 to numOfEntries
  100.     theType = pAssetIndex[n][#type]
  101.     pics    = pAssetIndex[n][#details][#ba]
  102.     
  103.     
  104.     
  105.     
  106.     if theType = #sino then
  107.       if pics.count >= 2 then
  108.         secondPic = pics[2]
  109.         
  110.         --   put secondPic.char[8..11]
  111.         
  112.         if secondPic.char[8..11] = "sino" then
  113.           put "secondPic: " & secondPic
  114.         else
  115.           put "theType: " & theType
  116.           put "pics: " & pics
  117.           put "secondPic: " & secondPic
  118.         end if
  119.         
  120.       end if
  121.     end if
  122.     
  123.   end repeat
  124. end
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. on writeAllListsToFile me
  134.   
  135.   loFileIO = new(script "oFileIO")
  136.   
  137.   put "Writing pPictureBasicList.ini"
  138.   writeFile loFileIO, the pathname & "~lists:assethq:", "pPictureBasicList.ini",    string(pPictureBasicList)
  139.   put "Done"
  140.   
  141.   put "Writing pPictureBookList.ini"
  142.   writeFile loFileIO, the pathname & "~lists:assethq:", "pPictureBookList.ini",     string(pPictureBookList)
  143.   put "Done"
  144.   
  145.   put "Writing pPictureLargeList.ini"
  146.   writeFile loFileIO, the pathname & "~lists:assethq:", "pPictureLargeList.ini",    string(pPictureLargeList)
  147.   put "Done"
  148.   
  149.   put "Writing pPictureTimeLineList.ini"
  150.   writeFile loFileIO, the pathname & "~lists:assethq:", "pPictureTimeLineList.ini", string(pPictureTimeLineList)
  151.   put "Done"
  152.   
  153.   put "Writing pIconList.ini"
  154.   writeFile loFileIO, the pathname & "~lists:assethq:", "pIconList.ini",            string(pIconList)
  155.   put "Done"
  156.   
  157.   put "Writing pVideoList.ini"
  158.   writeFile loFileIO, the pathname & "~lists:assethq:", "pVideoList.ini",           string(pVideoList)
  159.   put "Done"
  160.   
  161.   put "Writing pAudioList.ini"
  162.   writeFile loFileIO, the pathname & "~lists:assethq:", "pAudioList.ini",           string(pAudioList)
  163.   put "Done"
  164.   
  165.   put "Writing pTextList.ini"
  166.   writeFile loFileIO, the pathname & "~lists:assethq:", "pTextList.ini",            string(pTextList)
  167.   put "Done"
  168.   
  169.   put "Writing pAssetIndex.ini - please wait, this may take some time"
  170.   writeFile loFileIO, the pathname & "~lists:assethq:", "pAssetIndex.ini",          string(pAssetIndex)
  171.   put "Done"
  172.   
  173.   
  174.   loFileIO = void
  175.   
  176.   put "Updating oAssetHQ - Finished"
  177.   
  178.   
  179.   tempText = oHQ.pVersionInfoList[2] && oHQ.pVersionInfoList[3] && "UPDATE on" && the long date & RETURN& RETURN
  180.   tempText = tempText && "New oAssetHQ list files saved:" && the long time
  181.   
  182.   member("updating log internal", "objects").text = tempText
  183.   
  184. end
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193. on getAllListsFromFile
  194.   
  195.   loFileIO = new(script "oFileIO")
  196.   
  197.   pPictureBasicList    = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pPictureBasicList.ini"))
  198.   pPictureBookList     = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pPictureBookList.ini"))
  199.   pPictureLargeList    = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pPictureLargeList.ini"))
  200.   pPictureTimeLineList = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pPictureTimeLineList.ini"))
  201.   pIconList            = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pIconList.ini"))
  202.   pVideoList           = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pVideoList.ini"))
  203.   pAudioList           = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pAudioList.ini"))
  204.   pTextList            = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pTextList.ini"))
  205.   pAssetIndex          = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pAssetIndex.ini"))
  206.   
  207.   loFileIO = void
  208.   
  209. end
  210.  
  211.  
  212.  
  213.  
  214.  
  215. on initImportMembers me
  216.   
  217.   
  218.   pImpMbrPicBasic.picture = member("importPictureBasicEmpty").picture
  219.   pImpMbrPicLarge.picture = member("importPictureLargeEmpty").picture
  220.   pImpMbrPicSino.picture  = member("importPictureSinoEmpty").picture  
  221.   
  222.   repeat with n = 1 to 4
  223.     pImportMbrBookList[n].picture = member("importPictureBook Empty").picture  
  224.     pImportMbrBookList[n].name    = "importPictureBook" && string(n)  
  225.   end repeat
  226.   
  227.   --  importFileInto pImpMbrVideo, pAssetPath  & "_video.mov"
  228.   --  importFileInto pImpMbrAudio, pAssetPath  & "_audio.mov"
  229.   
  230.   pImpMbrVideo.filename = pAssetPath  & "_video.mov"
  231.   pImpMbrAudio.filename = pAssetPath  & "_audio.mov"
  232.   
  233.   pImpMbrVideo.name = "importvideo"
  234.   pImpMbrVideo.pausedAtStart = 1
  235.   
  236.   pImpMbrAudio.name = "importaudio"
  237.   pImpMbrAudio.pausedAtStart = 1
  238.   
  239.   
  240.   member("importBookText 1", "database").text = " "
  241.   member("importBookText 2", "database").text = " "
  242.   member("importBookText 3", "database").text = " "
  243.   member("importBookText 4", "database").text = " "
  244.   member("importBookText 5", "database").text = " "
  245.   member("importBookText 6", "database").text = " "
  246.   member("importText", "database").text       = " "
  247.   member("importTextSino", "database").text   = " "
  248.   
  249. end
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257. on getBookPicture me, aFilename, aPosition
  258.   importBitmap me, (pImportMbrBookList[aPosition]), pAssetPath  & "pictures" & gPathDelim & "book" & gPathDelim & aFilename , ("importPictureBook" && string(aPosition))
  259. end
  260.  
  261. on getTLPicture me, aFilename, aPosition
  262.   importBitmap me, (pImportMbrBookList[aPosition]), (pAssetPath  & "pictures" & gPathDelim & "timeline" & gPathDelim & aFilename ), ("importPictureBook" && string(aPosition))
  263. end
  264.  
  265. on getTimeLinePicture me, aFilename
  266.   importBitmap me, pImpMbrPicBasic, (pAssetPath  & "pictures" & gPathDelim & "timeline" & gPathDelim & aFilename), "importPictureBasic" 
  267. end
  268.  
  269. on getBasicPicture me, aFilename
  270.   importBitmap me, pImpMbrPicBasic, (pAssetPath  & "pictures" & gPathDelim & "basic" & gPathDelim & aFilename ), "importPictureBasic"
  271. end
  272.  
  273. on getLargePicture me, aFilename
  274.   importBitmap me, pImpMbrPicLarge, (pAssetPath  & "pictures" & gPathDelim & "large" & gPathDelim & aFilename), "importPictureLarge"    
  275. end
  276.  
  277. on getSinoPicture me, aFilename
  278.   importBitmap me, pImpMbrPicSino, (pAssetPath  & "pictures" & gPathDelim & "basic" & gPathDelim & aFilename), "importSino"  
  279. end
  280.  
  281.  
  282.  
  283. on importBitmap me, theMember, pathAndFilename, originalMemberName
  284.   importFileInto theMember, pathAndFilename 
  285.   theMember.name = originalMemberName 
  286.   -- theMember.fileName = pathAndFilename
  287.   -- theMember.centerRegPoint = 1 
  288. end
  289.  
  290.  
  291.  
  292.  
  293.  
  294. on getVideo me, aFilename
  295.   -- importFileInto pImpMbrVideo, pAssetPath  & "video" & gPathDelim & aFilename 
  296.   pImpMbrVideo.fileName = pAssetPath  & "video" & gPathDelim & aFilename 
  297.   pImpMbrVideo.name = "importvideo"
  298.   pImpMbrVideo.pausedAtStart = 1
  299. end
  300.  
  301.  
  302. on getAudio me, aFilename
  303.   -- importFileInto pImpMbrAudio, pAssetPath  & "audio" & gPathDelim & aFilename 
  304.   pImpMbrAudio.fileName = pAssetPath  & "audio" & gPathDelim & aFilename 
  305.   pImpMbrAudio.name = "importaudio"
  306.   pImpMbrAudio.pausedAtStart = 1
  307. end
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317. on makeAssetList me
  318.   
  319.   
  320.   if gPathDelim = "\" then
  321.     -- yuck it's Windows:
  322.     pPictureBasicList    = baFileList( pAssetPath & "pictures" & gPathDelim & "basic" & gPathDelim, "*.jpg" )
  323.     -- updateProgressBar ("makeAssetList: Pictures")
  324.     
  325.     pPictureBookList     = baFileList( pAssetPath & "pictures" & gPathDelim & "book" & gPathDelim, "*.jpg" )
  326.     -- updateProgressBar ("makeAssetList: BookPictures")
  327.     
  328.     pPictureLargeList    = baFileList( pAssetPath & "pictures" & gPathDelim & "large" & gPathDelim, "*.jpg" )
  329.     -- updateProgressBar ("makeAssetList: Large Pictures")
  330.     
  331.     pPictureTimeLineList = baFileList( pAssetPath & "pictures" & gPathDelim & "timeline" & gPathDelim, "*.jpg" )
  332.     -- updateProgressBar ("makeAssetList: TimeLinePictures")
  333.     
  334.     pVideoList   = baFileList( pAssetPath & "video" & gPathDelim, "*.mov" )
  335.     -- updateProgressBar ("makeAssetList: Videos")
  336.     
  337.     pAudioList   = baFileList( pAssetPath & "audio" & gPathDelim, "*.mov" )
  338.     -- updateProgressBar ("makeAssetList: Audio files")
  339.     
  340.     
  341.   else
  342.     -- Mac:
  343.     pPictureBasicList    = baFileList( pAssetPath & "pictures" & gPathDelim & "basic" & gPathDelim, "" )
  344.     -- updateProgressBar ("makeAssetList: Pictures")
  345.     
  346.     pPictureBookList     = baFileList( pAssetPath & "pictures" & gPathDelim & "book" & gPathDelim, "" )
  347.     -- updateProgressBar ("makeAssetList: BookPictures")
  348.     
  349.     pPictureLargeList    = baFileList( pAssetPath & "pictures" & gPathDelim & "large" & gPathDelim, "" )
  350.     -- updateProgressBar ("makeAssetList: Large Pictures")
  351.     
  352.     pPictureTimeLineList = baFileList( pAssetPath & "pictures" & gPathDelim & "timeline" & gPathDelim, "" )
  353.     -- updateProgressBar ("makeAssetList: TimeLinePictures")
  354.     
  355.     
  356.     pVideoList           = baFileList( pAssetPath & "video" & gPathDelim, "" )
  357.     -- updateProgressBar ("makeAssetList: Videos")
  358.     
  359.     pAudioList           = baFileList( pAssetPath & "audio" & gPathDelim, "" )
  360.     -- updateProgressBar ("makeAssetList: Audio files")
  361.     
  362.   end if
  363.   
  364.   
  365.   --- text files and icon files are not external - they are already imported into the cast called "text" and 'icons' respectively:
  366.   
  367.   -- updateProgressBar ("makeAssetList: Captions")
  368.   
  369.   pTextList = []
  370.   
  371.   set lastMember = the number of members of castlib "text"
  372.   repeat with n = 1 to lastMember
  373.     memberType = member(n,"text").type
  374.     if memberType = #text or memberType = #field then
  375.       add pTextList, member(n,"text").name
  376.     end if
  377.   end repeat
  378.   
  379.   -- check whether text list contains incorrectly named files
  380.   result = checkIntegrityofTextFileNames(me, pTextList)
  381.   if result.count then
  382.     customAlert "There are some text files with incorrect names. See the message window for details."  
  383.     put result
  384.     halt
  385.   end if
  386.   
  387.   
  388.   
  389.   -- updateProgressBar ("makeAssetList: Icons")
  390.   
  391.   pIconList = []
  392.   
  393.   set lastMember = the number of members of castlib "icons"
  394.   repeat with n = 1 to lastMember
  395.     curMember = member(n,"icons")
  396.     if curMember.type  = #bitmap then
  397.       add pIconList, curMember.name
  398.     end if
  399.   end repeat
  400.   -- the first member is a blank "missing" icon:
  401.   pIconList.deleteAt(1) 
  402.   
  403.   -- updateProgressBar ("makeAssetList: sorting lists")
  404.   
  405.   
  406.   -- sort all lists:
  407.   sort pPictureBasicList
  408.   -- updateProgressBar ("makeAssetList: sorting pPictureBasicList")
  409.   
  410.   sort pPictureBookList
  411.   -- updateProgressBar ("makeAssetList: sorting pPictureBookList")
  412.   sort pPictureLargeList
  413.   -- updateProgressBar ("makeAssetList: sorting pPictureLargeList")
  414.   sort pPictureTimeLineList
  415.   -- updateProgressBar ("makeAssetList: sorting pPictureTimeLineList")
  416.   sort pIconList
  417.   -- updateProgressBar ("makeAssetList: sorting pIconList")
  418.   sort pVideoList
  419.   -- updateProgressBar ("makeAssetList: sorting pVideoList")
  420.   sort pAudioList
  421.   -- updateProgressBar ("makeAssetList: sorting pAudioList")
  422.   sort pTextList
  423.   -- updateProgressBar ("makeAssetList: sorting pTextList")
  424.   
  425.   
  426. end
  427.  
  428.  
  429.  
  430.  
  431. on checkIntegrityofTextFileNames me, theTextList
  432.   -- theTextList = typically this would be oAssetHQ.pTextList
  433.   -- there are two types of names for text files: "9853_1_basic_t" and "6551_5_time_t" 
  434.   -- time texts are only in the six thousand range
  435.   
  436.   numOfFiles   = theTextList.count
  437.   problemFiles = []
  438.   
  439.   repeat with curWord in theTextList 
  440.     
  441.     numOfChars = curWord.length 
  442.     
  443.     if not (numOfChars >= 13) then
  444.       problemFiles.add(curWord)
  445.     end if
  446.     
  447.   end repeat
  448.   
  449.   return problemFiles
  450. end
  451.  
  452.  
  453.  
  454. on createIndex me
  455.   
  456.   --  BytesAfter = the freebytes
  457.   
  458.   -- every record must a caption and an icon
  459.   -- presuming that icons for all records are available
  460.   -- this handler goes through the icon list and finds material with correlating numbers
  461.   
  462.   pAssetIndex = [:]
  463.   -- for now we take the icon lists as the measure - 
  464.   -- we may get a better source of record numbers from somewhere else at some other point
  465.   
  466.   -- updateProgressBar ("makeAssetList: creating index")
  467.   
  468.   pNumOfRecs = count(pIconList)
  469.   
  470.   repeat with n = 1 to pNumOfRecs
  471.     curRecord = pIconList[n].char[1..4]
  472.     foundDetails = getrecordDetails(me, curRecord)
  473.     addProp pAssetIndex, curRecord, foundDetails  
  474.   end repeat
  475.   
  476.   --  Bytesbefore = the freebytes 
  477.   --  
  478.   --  put "Bytesbefore: " & Bytesbefore
  479.   --  put "BytesAfter: " & BytesAfter
  480.   --  
  481.   --  put "Difference:" && (BytesAfter - Bytesbefore)/1024
  482.   
  483. end
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490. on getrecordDetails me, recordnumber
  491.   
  492.   numberOfFoundAssets = 0
  493.   -- make 0001 out of 1 etc:
  494.   -- if integerP(recordnumber) then recordnumber  = triplePad(oMarvin, recordnumber)
  495.   
  496.   -- initialise pCurRecDetailsLst, which will be the return value:
  497.   curDetailsList = [#ba:[], #bo:[], #la:[], #tl:[], #vi:[], #te:[], #au:[]]
  498.   
  499.   -- we will then search text, audio, video and pictures.
  500.   -- The result will go into 'currentFoundList' which gets re-initialised
  501.   -- after every search:
  502.   
  503.   currentFoundList   = []
  504.   
  505.   -- search pictureLists:
  506.   currentFoundList = searchAssetList (me, pPictureBasicList, recordnumber)
  507.   curDetailsList[#ba] = currentFoundList
  508.   numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
  509.   
  510.   currentFoundList = searchAssetList (me, pPictureBookList, recordnumber)
  511.   curDetailsList[#bo] = currentFoundList
  512.   numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
  513.   
  514.   currentFoundList = searchAssetList (me, pPictureLargeList, recordnumber)
  515.   curDetailsList[#la] = currentFoundList
  516.   numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
  517.   
  518.   currentFoundList = searchAssetList (me, pPictureTimeLineList, recordnumber)
  519.   curDetailsList[#tl] = currentFoundList
  520.   numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
  521.   
  522.   -- search audioList:
  523.   currentFoundList = searchAssetList (me, pAudioList, recordnumber)
  524.   curDetailsList[#au] = currentFoundList
  525.   numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
  526.   
  527.   -- search videoList:
  528.   currentFoundList = searchAssetList (me, pVideoList, recordnumber)
  529.   curDetailsList[#vi] = currentFoundList
  530.   numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
  531.   
  532.   -- search textList:
  533.   currentFoundList = searchAssetList (me, pTextList, recordnumber)
  534.   curDetailsList[#te] = currentFoundList
  535.   numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
  536.   
  537.   if numberOfFoundAssets then
  538.     -- determine the recordtype:
  539.     recType = determineRecType(me, recordnumber, curDetailsList)
  540.   else
  541.     curDetailsList = #noAssetsFound
  542.     recType        = #unkown
  543.   end if
  544.   
  545.   return [#type: recType, #details: curDetailsList] 
  546.   
  547. end
  548.  
  549.  
  550.  
  551.  
  552. on determineRecType me, recordnumber, curDetailsList
  553.   
  554.   retVal = #notFound  
  555.   typeIdentifier = value(recordnumber)
  556.   
  557.   
  558.   numOfBasicPics = curDetailsList[#ba].count
  559.   if numOfBasicPics then
  560.     -- we have some basic sized pictures
  561.     -- it can only be a standard record or an audio or video record
  562.     if curDetailsList[#au].count then
  563.       retVal = #audio
  564.     else if curDetailsList[#vi].count then
  565.       retVal = #video
  566.     else
  567.       -- now determine whether the record is standard or sino:
  568.       -- we assume it is standard
  569.       retVal = #standard
  570.       -- unless proved otherwise:
  571.       -- the theory is that sino pictures always occupy place two in the list
  572.       if numOfBasicPics > 1 then 
  573.         -- put  (curDetailsList[#ba][2]).char[8..11]
  574.         if (curDetailsList[#ba][2]).char[8..11] = "sino" then 
  575.           retVal = #sino
  576.         end if
  577.         --put "curDetailsList: " & curDetailsList
  578.       end if
  579.     end if
  580.     
  581.   else if (  (typeIdentifier >= 8000) and (typeIdentifier < 9000)  ) or curDetailsList[#bo].count  then
  582.     -- it's a Book entry
  583.     retVal = #book  
  584.   else if (  (typeIdentifier >= 6000) and (typeIdentifier < 7000)  ) or curDetailsList[#tl].count  then
  585.     -- it's a timeline entry
  586.     retVal = #timeLine  
  587.   end if
  588.   
  589.   if retVal = #notFound then
  590.     -- put recordnumber
  591.   end if
  592.   
  593.   return retVal
  594.   
  595. end
  596.  
  597.  
  598.  
  599.  
  600.  
  601. on searchAssetList me, whichList, recordnumber
  602.   currentFoundList = []
  603.   maxPointer       = count(whichList)
  604.   currentPointer   = findPosNear(whichList, recordnumber)
  605.   
  606.   if currentPointer > 0 and currentPointer <= maxPointer then
  607.     currentFoundTerm = whichList[currentPointer]
  608.     -- check wether this first found asset name is an exact match
  609.     -- or wether findposNear has simply returned three matching zeros:
  610.     if currentFoundTerm.char[1..4] = recordnumber then
  611.       -- found a record which matches exactly.
  612.       -- let's see wether there are more:
  613.       repeat while 1
  614.         -- add currentFoundList, currentFoundTerm
  615.         if currentFoundTerm.char[1..4] = recordnumber then
  616.           add currentFoundList, currentFoundTerm
  617.         else
  618.           exit repeat
  619.         end if
  620.         currentPointer       = currentPointer + 1
  621.         if currentPointer > maxPointer then
  622.           exit repeat
  623.         end if
  624.         currentFoundTerm = whichList[currentPointer]
  625.       end repeat
  626.     end if
  627.   end if
  628.   return currentFoundList
  629. end
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638. on checkintegrity me
  639.   
  640.   -- this hander checks whether the database, and asset information makes sense
  641.   
  642.   put "Checking integrity..."
  643.   
  644.   tempText = ""
  645.   
  646.   repeat with n = 1 to pNumOfRecs
  647.     curDetails = pAssetIndex[n][#details]
  648.     if listP(curDetails) then
  649.       if count (curDetails[#te]) = 0 then
  650.         recordNumber = pAssetIndex.getPropAt(n) 
  651.         if not recordNumber.char[1] = "6" then tempText = tempText & RETURN & recordNumber
  652.       end if
  653.     end if
  654.   end repeat
  655.   
  656.   if tempText <> "" then
  657.     pIndexErrorLog = pIndexErrorLog & RETURN & tempText
  658.     pIndexErrorLog = pIndexErrorLog & RETURN & "-------------------------------------"
  659.     pIndexErrorLog = pIndexErrorLog & RETURN & "Text files with no icons:" & RETURN
  660.   else
  661.     pIndexErrorLog = pIndexErrorLog & RETURN & "All Icons have captions: OK" & RETURN
  662.   end if
  663.   tempText = ""
  664.   
  665.   -- reverse lookup - go through text list and see whether there is an icon for every text file:
  666.   numOfTextMembers = pTextList.count
  667.   repeat with n = 1 to numOfTextMembers
  668.     curRec = pTextList[n].char[1..4]
  669.     if pAssetIndex.findPos(curRec) then
  670.       next repeat
  671.     else
  672.       if not curRec.char[1] = "6" then tempText = tempText & RETURN & curRec
  673.     end if
  674.   end repeat
  675.   
  676.   if tempText <> "" then
  677.     pIndexErrorLog = pIndexErrorLog & RETURN & tempText
  678.     pIndexErrorLog = pIndexErrorLog & RETURN & "-------------------------------------"
  679.     pIndexErrorLog = pIndexErrorLog & RETURN & "The type of the following records couldn't be determined:" & RETURN
  680.   else
  681.     pIndexErrorLog = pIndexErrorLog & RETURN & "All Text files have icons: OK" & RETURN
  682.   end if
  683.   tempText = ""
  684.   
  685.   -- now check whether there are any records where the type couldn't be determined:
  686.   repeat with n = 1 to pNumOfRecs
  687.     curType = pAssetIndex[n][#type]
  688.     --  put "curType: " & curType && "(" &  pAssetIndex.getPropAt(n)  & ")"
  689.     if curType = #notFound then
  690.       if not pAssetIndex.getPropAt(n).char[1] = "6" then tempText = tempText & RETURN & pAssetIndex.getPropAt(n) 
  691.     end if
  692.   end repeat
  693.   
  694.   if tempText <> "" then
  695.     pIndexErrorLog = pIndexErrorLog & RETURN & tempText
  696.   else
  697.     pIndexErrorLog = pIndexErrorLog & RETURN & "All record types could be determined: OK" & RETURN
  698.   end if
  699.   
  700.   
  701.   -- checking lists for duplicates:
  702.   tempText = ""
  703.   
  704.   
  705.   
  706.   result = checkListForDuplicates (oMarvin, pIconList)
  707.   if result.count then
  708.     tempText = tempText & "pIconList contains the following duplicates:" & RETURN & result
  709.   else
  710.     tempText = tempText & "pIconList: OK"& RETURN
  711.   end if
  712.   
  713.   
  714.   result = checkListForDuplicates (oMarvin, pTextList)
  715.   if result.count then
  716.     tempText = tempText & "pTextList contains the following duplicates:" & RETURN & result
  717.   else
  718.     tempText = tempText & "pTextList: OK"& RETURN
  719.   end if
  720.   
  721.   result = checkListForDuplicates (oMarvin, pAssetIndex)
  722.   if result.count then
  723.     tempText = tempText & "pAssetIndex contains the following duplicates:" & RETURN & result
  724.   else
  725.     tempText = tempText & "pAssetIndex: OK"& RETURN
  726.   end if
  727.   
  728.   pIndexErrorLog = pIndexErrorLog & RETURN & tempText
  729.   
  730.   put pIndexErrorLog
  731.   
  732. end
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739. on showProps me
  740.   showProps oHQ, me
  741. end
  742.  
  743.