FileIOXtraVersion1.0.4-09dec97CHFileIOXtraforMacromediaDirector6.0=======================================FileIOprovidesasetofmethodsallowingusersofMacromediaDirector6.0toprogrammaticallyaccessfilesusingtheLingoscriptinglanguage.TheFileIOXtraisascriptingXtra.ThescriptingXtrainterfaceisportableacrossallMacromediaproducts.HencetheFileIOXtramaybeusedwithAuthorware4.UsingFileIO============Ifautomaticopeningisdesired,placeacopyoftheFileIOXtraforyourplatformintoApplicationXtra'sfolder.Ifautomaticopeningisnotdesired,theXtracanbeplacedanywhereandopenedusingLingo's'openXLib'command.Thisappliestoprojector'saswell,theXtramustbeplacedinanXtra'sfolderinthesamefolderastheprojector.EachinstanceofFileIOcanreferenceasingleopenfile.Ifmultiplefilesaretobeopenedsimultaneously,anewinstanceofFileIOisrequiredforeachopenedfile.Asingleinstancecanbeusedtoopenmultiplefiles,aslongasthefileisclosedbeforeanewfileisopened.Tocreateanewinstance,usethenew()method,definedbelow.Todisposeofaninstance,settheinstancevariableto0.AllmethodsthatreadfromorwritetothefilemustbecalledafterthefilehasbeenopenedusingtheopenFile()method.Ifanewfileistobeopenedusingthesameinstance,thefilemustbeclosedusingcloseFile().Filescanbeopenedinthreedifferentmodes:Read,WriteandRead/Write.Whenwritingtoafile,thecontentsofthefileafterthecurrentpositionareoverwritten.ExampleLingosetmyFile=new(xtrafileio)--CreateaninstanceofFileIOsetfileName=displayOpen(myFile)--DisplayOpenDialogandreturnthefileNameopenFile(myFile,fileName,1)--OpenthefilesettheFile=readFile(myFile)--ReadthefileandreturnastringtoLingocloseFile(myFile)--ClosethefilesetmyFile=0--DisposeoftheinstanceInthisexample,wecreatedanewinstanceandstoreditinthevariablemyFile.Next,thedisplayOpen()methodisusedtodisplayanopendialogtoallowafiletobechosen.Thefileisreturnedasafully-qualifiedpathstringtoLingo.Thefileisthenopenedinreadonlymode,thecontentsofthefileareread,andthefileisclosed.Lastly,theinstanceisdisposedof.KnownProblems==============ThecreateFile()methoddoesnotsupportrelativefilenames,ortheLingo'@'operatorinpathnames.Thiswillbefixedinalaterversion.ThedisplaySave()methoddoesnotdirectlyinformLingowhetherauserisreplacinganexistingfile.TheworkaroundistoattempttocreatethefileusingcreateFile()andchecktheerrorcodeforaFileAlreadyExistserror.History=======09dec97(v1.0.4)Fixedaproblemleadingtogarbagecharactersappearingattheendsoflines,orpossiblycrash.18apr97(v1.0.2)FixedparentingproblemwithdisplaySave()anddisplayOpen()methods.AddedsupportforAuthorware.27may96(v1.0.1)Addedsupportfordouble-bytecharactersets.Addedversion()methodtoreportFileIOXtraversioninformation.AddedgetOSDir()toreturnafullpathtotheWindowsDirectory/SystemFolder.15mar96(v1.0.0Beta)Firstpublicrelease.MethodReference================Thefirstlineofeachdefinitioncontainsthemethodname,alistofparametersandthiervaluetypes.TheinternalnameoftheFileIOXtraisfileio.Thisnameisusedwheneverreferencingthextrausingtheform'xtrafileio'.NotethatwhileDirectorandprojector'scanusenet-basedfilesbysupplyingaURLforafilename,theFileIOXtracannot.Itislimitedtoaccessesingfilesavailableviafilesystemsmountedonthelocalsystem.Newmethodswillappearatthebottomofthislist.---mMessageList(xtrareference)Returnsalistofmethodsandparameters,aswellasabriefexplanationofeach.---new(xtrareference)ThisiscalledtocreateanewinstanceofFileIO.TheXtracanbereferencedbynameornumber.Itreturnsaninstancevariableusedtoreferencetheinstance.---fileName(instance)ReturnsthefileNamestringofthecurrentopenfile.Thefilemustbeopenusethismethod.---status(instance)Returnstheerrorcodereturnedbythelastmethodcalled.Thevalueisreturnedasaninteger.---error(instance,interror)Returnsareadableerrorstring.Anumericerrorcodeispassedinasthesecondargument.Theerrorsreturnedcanbeanyofthefollowing:OKMemoryallocationfailureFiledirectoryfullVolumefullVolumenotfoundI/OErrorBadfilenameFilenotopenToomanyfilesopenFilenotfoundNosuchdriveNodiskindriveDirectorynotfoundInstancehasanopenfileFilealreadyexistsFileisopenedread-onlyFileisopenedwrite-onlyUnknownerror---setFilterMask(instance,stringmask)SetsthefiltermaskusedbycallstodisplayOpen()anddisplaySave().ThefiltermaskdetermineswhatfilestoshowwhendisplayinganOpenorSavedialog.Thesecondparameterisastringrepresentingthefiltermasktoset.OnWindows,thisisacommaseperatedstringoffiletypesandassociatedextensions(e.g.AllFiles,*.*,TextFiles,*.TXT),andastringoftypesontheMacintosh(e.g.TEXTPICT).OnWindows,thefiltermaskstringislimitedto256characters.OntheMacintosh,youarelimitedtofourfour-charactertypes.WhenanewinstanceofFileIOiscreated,thefiltermasksdefaultstoallfiles.Toresetthefiltermasktodisplayallfilesafterithasbeenset,justpassinanemptystring(e.g.setFilterMask(me,)).---openFile(instance,stringfileName,intopenMode)Opensthenamedfile.Thiscallmustbeusedbeforeanyread/writeoperationscantakeplace.Thefilenamecanbeeitherafully-qualifiedpathandfilename,orarelativefilename.TheLingo'@'pathnameoperatorissupported.TheopenModeparameterspecifieswhethertoopenthefileinRead,WriteorReadWritemode.ValidFlagsare:0Read/Write,1Read,2Write.---close