property pLoadActiveListxyz
on new mexyz
 set pLoadActiveList = []xyz
 xyz
 return mexyz
end newxyz
xyz
xyz
on mCheckState mexyz
   if count(pLoadActiveList) > 0 thenxyz
     repeat with x = 1 to count(pLoadActiveList)xyz
       set myPara = getAt(pLoadActiveList,x)xyz
       set myID   = getAt(myPara,1)xyz
       set myURL  = getAt(myPara,2)xyz
       set myPath = getAt(myPara,3)xyz
       set myType = getAt(myPara,4)xyz
       set myStat = getAt(myPara,5)xyz
       set myDel  = FALSExyz
       xyz
       case myStat ofxyz
         1 :xyz
           mSetStatus(me,"Preloading")xyz
           case mCheckLoadDone(me,myID) ofxyz
             1 :xyz
               setAt(myPara,5,2)xyz
               setAt(pLoadActiveList,x,myPara)xyz
             2 :xyz
               netAbort(myID)xyz
               setAt(myPara,5,0)xyz
               set myDel = TRUExyz
           end casexyz
         2 :xyz
           mSetStatus(me,"Downloading")xyz
           mDownLoadNet(me,myURL,myPath)xyz
           set myID = getLatestNetID()xyz
           setAt(myPara,1,myID)xyz
           setAt(myPara,5,3)xyz
           setAt(pLoadActiveList,x,myPara)xyz
         3 :xyz
           case mCheckLoadDone(me,myID) ofxyz
             1 :xyz
               setAt(myPara,5,4)xyz
               setAt(pLoadActiveList,x,myPara)xyz
             2 :xyz
               netAbort(myID)xyz
               setAt(myPara,5,0)xyz
               set myDel = TRUExyz
           end casexyz
         4 :xyz
           case myType ofxyz
             1 :xyz
               -- Imagexyz
               mSetLoadFile(me,myPath)xyz
             2 :xyz
               -- Preferencesxyz
               mSetLoadPref(me,myPath)xyz
             3 :xyz
               -- Infotextxyz
               mSetLoadInfo(me,myPath)xyz
             4 :xyz
               -- Headerxyz
               mSetLoadHead(me,myPath)xyz
           end casexyz
           setAt(myPara,5,0)xyz
           set myDel = TRUExyz
       end casexyz
     end repeatxyz
     xyz
     if myDel thenxyz
       set x = 1xyz
       repeat while myDelxyz
         set myStat = getAt(getAt(pLoadActiveList,x),5)xyz
         if myStat = 0 thenxyz
           deleteAt(pLoadActiveList,x)xyz
         elsexyz
           set x = x + 1xyz
         end ifxyz
         if x > count(pLoadActiveList) thenxyz
           set myDel = FALSExyz
         end ifxyz
       end repeatxyz
     end ifxyz
     xyz
     if count(pLoadActiveList) < 1 AND NOT(the text of field "status" contains "Error") thenxyz
       mSetStatus(me,"-")xyz
     end ifxyz
   end ifxyz
 end mCheckStatexyz
 xyz
 xyz
 on mSetStatus me,newMsgxyz
   if word 1 of the text of field "status" <> word 1 of newMsg thenxyz
     set the text of field "status" to newMsgxyz
   end ifxyz
 end mSetStatusxyz
 xyz
 xyz
 on mAddLoadNet me,myURL,myPath,myType,mustNewxyz
   Global gLoadState,pLoadActiveList,gProxyIP,gProxyPortxyz
.   xyz
.   if count(pLoadActiveList) < 4 then xyz
.     if FileExists(the pathName & myPath) = 0 AND NOT(mustNew) thenxyz
.       if myType <> 2 thenxyz
.         set the text of field "state_Net" to "L"xyz
.       end ifxyz
.       set myPara = [0,myURL,myPath,myType,4]xyz
.       add(pLoadActiveList, myPara)xyz
.     elsexyz
.       if myType <> 2 thenxyz
.         set the text of field "state_Net" to "N"xyz
.       end ifxyz
.       if gProxyIP <> "" thenxyz
.         proxyserver(#http,gProxyIP,gProxyPort)xyz
.       end ifxyz
.       mPreLoadNet(me,myURL)xyz
.       set myID = getLatestNetID()xyz
.       set myPara = [myID,myURL,myPath,myType,1]xyz
.       add(pLoadActiveList, myPara)xyz
.     end ifxyz
.     xyz
.     return TRUExyz
.   elsexyz
.     return FALSExyz
.   end ifxyz
. end mAddLoadNetxyz
. xyz
. xyz
. on mPreLoadNet me,wichOne  xyz
.   xyz
.   set myError = preLoadNetThing(wichOne)xyz
. end mPreLoadNetxyz
. xyz
. xyz
. on mDownLoadNet me,wichURL,wichPathxyz
.   xyz
.   set myError = downLoadNetThing(wichURL,the pathName & wichPath)xyz
. end mDownLoadNetxyz
. xyz
. xyz
. on mSetLoadFile me,wichOnexyz
.   Global gGifObjxyz
.   xyz
.   set myError = FileExists(the pathName & wichOne)xyz
.   xyz
.   if myError = 0 thenxyz
.     mChangePict(gGifObj,wichOne)xyz
.   elsexyz
.     mFileUtilErr(me,myError)xyz
.   end ifxyz
. end mSetLoadFilexyz
. xyz
. xyz
. on mSetLoadHead me,wichOnexyz
.   Global gGifObjxyz
.   xyz
.   set myError = FileExists(the pathName & wichOne)xyz
.   if myError = 0 thenxyz
.     set the fileName of member "TheHead" to the pathName & wichOnexyz
.   elsexyz
.     mFileUtilErr(me,myError)xyz
.   end ifxyz
. end mSetLoadHeadxyz
. xyz
. xyz
. on mSetLoadPref me,wichOnexyz
.   Global gContent,gFirstTextList,gGifObjPath,gLimit,gFontObjxyz
.   xyz
.   set myError = FileExists(the pathName & wichOne)xyz
.   xyz
.   if myError = 0 thenxyz
.     set filePnt = new(xtra "fileio")xyz
.     openFile(filePnt,the pathName & wichOne,1)xyz
.     xyz
.     set myText = readFile(filePnt)xyz
.     closeFile(filePnt)xyz
.     set gContent = MakeListFromText(mChangeFontMap(gFontObj,KillUnixLF(myText)),"#",2,1,17)xyz
.     set myHead = GetStringTo(getAt(gFirstTextList,1),"#",TRUE)xyz
.     mAddLoadNet(me,gGifObjPath & myHead,"data" & gLimit & myHead,4,false)xyz
.     SetFieldValue()xyz
.   elsexyz
.     mFileUtilErr(me,myError)xyz
.   end ifxyz
. end mSetLoadPrefxyz
. xyz
. xyz
. on mSetLoadInfo me,wichOnexyz
.   Global gContent,gFontObjxyz
.   xyz
.   set myError = FileExists(the pathName & wichOne)xyz
.   if myError = 0 thenxyz
.     set filePnt = new(xtra "fileio")xyz
.     openFile(filePnt,the pathName & wichOne,1)xyz
.     xyz
.     set myText = mChangeFontMap(gFontObj,KillUnixLF(readFile(filePnt)))xyz
.     closeFile(filePnt)xyz
.     set the text of field "info_sta" to line 1 of myTextxyz
.     set the text of field "info_url" to line 2 of myTextxyz
.     set the text of field "info_text" to line 3 to the number of lines in myText of myTextxyz
.     set filePnt = EMPTYxyz
.   elsexyz
.     mFileUtilErr(me,myError)xyz
.   end ifxyz
. end mSetLoadInfoxyz
. xyz
. xyz
. on mCheckPref me,wichOnexyz
.   if FileExists(the pathName & wichOne) = 0 thenxyz
.     set filePnt = new(xtra "fileio")xyz
.     openFile(filePnt,the pathName & wichOne,1)xyz
.     setPosition(filePnt,0)xyz
.     set myText = readLine(filePnt)xyz
.     closeFile(filePnt)xyz
.     xyz
.     if GetStringFrom(myText,"#",TRUE) = "y" thenxyz
.       mKillPref(me,wichOne)xyz
.     end ifxyz
.     set filePnt = EMPTYxyz
.   end ifxyz
. end mCheckPrefxyz
. xyz
. xyz
. on mKillPref me,wichOnexyz
.   DeleteFile(the pathName & wichOne)xyz
. end mKillPrefxyz
. xyz
. xyz
. on mCheckLoadDone me,theIPxyz
.   if netDone(theIP) thenxyz
.     set myError = netError(theIP)xyz
.     if myError <> "OK" thenxyz
.       mSetStatus(me,"Network Error" && myError)xyz
.     end ifxyz
.     set myResult = 1xyz
.   elsexyz
.     set myResult = 0xyz
.   end ifxyz
.   xyz
.   return myResultxyz
. end mCheckLoadDonexyz
. xyz
. xyz
. on mFileUtilErr me,wichOnexyz
.   case wichOne ofxyz
.     0: xyz
.       set message to "successful completion"xyz
.     -1: xyz
.       set message to "General error of unknown origin"xyz
.     -5: xyz
.       set message to "File deletion failure"xyz
.     -6: xyz
.       set message to "File rename failure"xyz
.     -7: xyz
.       set message to "File not found"xyz
.     -8: xyz
.       set message to "Specified file is actually a directory"xyz
.     -9: xyz
.       set message to "File creation failure"xyz
.     -10: xyz
.       set message to "File open failure"xyz
.     -11: xyz
.       set message to "File write failure"xyz
.     -12: xyz
.       set message to "File close failure"xyz
.     -13: xyz
.       set message to "File read failure"xyz
.     -14: xyz
.       set message to "Destination disk full"xyz
.     -15: xyz
.       set message to "Directory not found"xyz
.     -16: xyz
.       set message to "Specified directory is actually a file"xyz
.     -17: xyz
.       set message to "Directory creation failure"xyz
.     -18: xyz
.       set message to "Could not delete specified directory"xyz
.     -19: xyz
.       set message to "Could not retrieve directory ID number"xyz
.     -40: xyz
. xyz
.       set message to "Could not allocate memory for file copy"xyz
.     -210: xyz
.       set message to "New filename already exists or two paths are different"xyz
.     otherwise xyz
.       set message to "unknown error code"xyz
.   end casexyz
.   xyz
.   if NOT(the text of field "status" contains "Error") thenxyz
.     mSetStatus(me,message)xyz
.   end ifxyz
. end mFileUtilErrxyz
. xyz
. xyzxyz
. xyz

