home *** CD-ROM | disk | FTP | other *** search
- on BatchIndex
- global mpath, gWorld, gMakerNum
- set the itemDelimiter to "."
- set gWorld to item 1 of the movieName
- set the itemDelimiter to ","
- set mpath to the pathName & gWorld & ":"
- set fileList to []
- repeat with i = 1 to the maxinteger
- set n to getNthFileNameInFolder(mpath, i)
- if n = EMPTY then
- exit repeat
- end if
- set num to the number of chars in n
- if char num - 3 to num of n = ".txt" then
- append(fileList, n)
- end if
- end repeat
- put "filelist = " && fileList
- set num to count(fileList)
- repeat with i = 1 to num
- set tmpname to getAt(fileList, i)
- put "batch indexing " && tmpname
- set the itemDelimiter to "."
- set tmpname to item 1 of tmpname
- set the itemDelimiter to ","
- set gMakerNum to NameToNum(tmpname)
- set err to MakeIndex(getAt(fileList, i))
- if err = -1 then
- set tmpnum to the number of lines in field "BatchErrors" + 1
- put "Index Error: " && getAt(fileList, i) into line tmpnum of field "BatchErrors"
- end if
- end repeat
- end
-
- on MakeIndex fname
- global index, MainIndex, mpath, gMakerNum, gMakerName, gName, gWorld
- put "indexing: " && fname
- set the itemDelimiter to "."
- set gWorld to item 1 of the movieName
- set the itemDelimiter to ","
- set gName to line gMakerNum of field "makernumlist"
- set thenam to fname
- if the paramCount = 1 then
- set myObj to FileIO(mnew, "read", mpath & fname)
- else
- set myObj to FileIO(mnew, "?read", "TEXT")
- end if
- if not objectp(myObj) then
- alert("problem opening " && fname)
- abort()
- else
- set fname to myObj(mFileName)
- set the itemDelimiter to ":"
- set fname to item the number of items in fname of fname
- set the itemDelimiter to "."
- set fname to item 1 of fname
- set the itemDelimiter to ","
- put "Getting indexes for: " & fname
- set tmpfile to myObj(mReadFile)
- set tmpfilecopy to tmpfile
- set the itemDelimiter to "@"
- set inum to the number of items in tmpfile
- set the itemDelimiter to ","
- set offset to 0
- set a to 0
- set index to EMPTY
- set first to 1
- repeat with i = 1 to inum
- set the itemDelimiter to "@"
- set tmp to item i of tmpfile
- set the itemDelimiter to ","
- if (i = inum) and (the number of chars in tmp < 3) then
- exit repeat
- end if
- if first then
- set tmpart to line 1 of tmp
- set first to 0
- else
- set tmpart to line 2 of tmp
- end if
- if the number of chars in tmpart > 4 then
- put "error. article number is wrong."
- return -1
- else
- set art to word 1 of tmpart
- end if
- set a to offset + a
- if index = EMPTY then
- put art & ":" & a into item 1 of index
- else
- put art & ":" & a into item the number of items in index + 1 of index
- end if
- set offset to the number of chars in tmp + 1
- end repeat
- myObj(mdispose)
- set num to the number of lines in field ("CuttingIndex" & gWorld)
- set fname to gName
- put fname & ":" & index
- set i to Bsearch(fname, "CuttingIndex" & gWorld)
- if i then
- delete line i of field ("CuttingIndex" & gWorld)
- end if
- set index to fname & "," & index
- if line 1 of field ("CuttingIndex" & gWorld) = EMPTY then
- put index into line 1 of field ("CuttingIndex" & gWorld)
- else
- put index into line the number of lines in field ("CuttingIndex" & gWorld) + 1 of field ("CuttingIndex" & gWorld)
- end if
- sortlines("CuttingIndex" & gWorld)
- set fname to "CU" & gMakerNum & ".TXT"
- set myObj to FileIO(mnew, "write", mpath & fname)
- put "writing: " && fname
- myObj(mWriteString, tmpfilecopy)
- myObj(mdispose)
- return 0
- end if
- end
-