home *** CD-ROM | disk | FTP | other *** search
- on BatchReadCaptions world
- global gMakerNum, gWorld
- set gWorld to world
- set mpath to the pathName & world & ":"
- 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 = ".CAP" then
- append(fileList, n)
- end if
- end repeat
- set num to count(fileList)
- set tmperrlist to []
- repeat with i = 1 to num
- set fname to getAt(fileList, i)
- set the itemDelimiter to "."
- set gMakerNum to item 1 of fname
- set the itemDelimiter to ","
- put "batch reading captions " && fname
- set gMakerName to char 1 to the number of chars in fname - 4 of fname
- set err to ReadCaptions(world & ":" & fname)
- if err = -1 then
- add(tmperrlist, fname)
- end if
- end repeat
- end
-
- on ReadNewCaptions
- global gMakerName, mpath, gWorld
- puppetSound("click")
- updateStage()
- set fname to gWorld & ":" & NameToNum(gMakerName) & ".CAP"
- set err to ReadCaptions(fname)
- if err = -1 then
- alert("problem loading caption for:" & fname)
- go(2)
- end if
- go("database")
- end
-
- on ReadCaptions fname
- global myObj, gMakerNum
- set mypath to the pathName & fname
- set myObj to FileIO(mnew, "read", mypath)
- if not objectp(myObj) then
- alert("couldnt open " && mypath)
- return -1
- end if
- put "gmakernum = " & gMakerNum
- set scast to the number of cast (gMakerNum & ".cap")
- set the text of field scast to myObj(mReadFile)
- set the name of cast scast to gMakerNum & ".cap"
- put "done " && fname
- myObj(mdispose)
- return 0
- end
-
- on saveNewParse
- global gChapters, gArticles, gCaptions, gTitles, gDates, gName, gMakerName, gnuggets, mpath, gMakerNum
- set tmptxt to EMPTY
- put "set gChapters = " && gChapters into line 1 of tmptxt
- put "set gArticles = " && gArticles into line 2 of tmptxt
- put "set gDates = " && gDates into line 3 of tmptxt
- set tmplist to []
- add(tmplist, gName)
- put "set gName = getat(" & tmplist & ",1)" into line 4 of tmptxt
- put gTitles into line 5 of tmptxt
- put gnuggets into line 6 of tmptxt
- put "saving: " && gMakerNum && gName
- if gMakerNum = 0 then
- alert("Error finding number of " && gName)
- abort()
- else
- set mypath to mpath & gMakerNum & ".CAP"
- set myObj to FileIO(mnew, "write", mypath)
- if not objectp(myObj) then
- alert("problem writing to " && mypath)
- abort()
- end if
- set i to the number of cast gMakerNum && "script"
- if i > 0 then
- set captiontxt to EMPTY
- set the text of field i to tmptxt
- set the itemDelimiter to "@"
- set numchap to the number of items in gCaptions
- set the itemDelimiter to ","
- repeat with j = 1 to numchap
- set the itemDelimiter to "@"
- set tmpcap to item j of gCaptions
- set the itemDelimiter to "#"
- set numart to the number of items in tmpcap
- set the itemDelimiter to ","
- repeat with k = 1 to numart
- set the itemDelimiter to "#"
- set it to item k of tmpcap
- set the itemDelimiter to ","
- if k = numart then
- put it & RETURN & "@" & RETURN after captiontxt
- else
- put it & RETURN & "#" & RETURN after captiontxt
- end if
- set the itemDelimiter to ","
- end repeat
- end repeat
- if 0 then
- put captiontxt into field (i + 1)
- set the name of cast (i + 1) to gMakerName
- end if
- myObj(mWriteString, captiontxt)
- end if
- end if
- set tmptxt to EMPTY
- set txt to EMPTY
- myObj(mdispose)
- end
-
- on cleancast s, e
- repeat with i = s to e
- set the name of cast i to "a"
- set the text of field i to EMPTY
- end repeat
- end
-
- on ReadScript
- global gChapters, gArticles, gCaptions, gTitles, gDates, gName, gMakerName, gnuggets, gTotalChapters, tmpfile, mpath, gMakerNum
- set forcd to 0
- set fname to gMakerNum && "script"
- set cnum to the number of cast fname
- if not (cnum > 0) then
- alert("Problem loading" && fname && ". This means this persons script file must be re-indexed")
- unpuppet()
- if forcd = 1 then
- ReturnToWorld()
- else
- go(2)
- abort()
- end if
- else
- set tmptxt to the text of field cnum
- set tmpfile to tmptxt
- repeat with i = 1 to 4
- do(line i of tmptxt)
- end repeat
- set gTitles to line 5 of tmptxt
- set gCaptions to the text of cast (gMakerNum & ".CAP")
- set gnuggets to line 6 of tmptxt
- set gTotalChapters to count(gArticles)
- end if
- end
-
- on PrepareCasts next
- global tmplist
- set tmplist to []
- set flist to "Filenames"
- set num to the number of lines in field flist
- repeat with i = 1 to num
- set tmp to line i of field flist
- if notEmpty(tmp) then
- set mnum to NameToNum(tmp)
- add(tmplist, mnum)
- end if
- end repeat
- set flist to "Filenames2"
- set num to the number of lines in field flist
- repeat with i = 1 to num
- set tmp to line i of field flist
- if notEmpty(tmp) then
- set mnum to NameToNum(tmp)
- add(tmplist, mnum)
- end if
- end repeat
- put tmplist
- set num to count(tmplist)
- repeat with i = 1 to num
- set the name of cast next to getAt(tmplist, i) && "script"
- set next to next + 1
- end repeat
- repeat with i = 1 to num
- set the name of cast next to getAt(tmplist, i) & ".CAP"
- set next to next + 1
- end repeat
- end
-