Changeset 241 for trunk/lingosource/castlib2/FileIOFunktionen.ls
- Timestamp:
- 12/18/09 15:27:43 (2 years ago)
- File:
-
- 1 edited
-
trunk/lingosource/castlib2/FileIOFunktionen.ls (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lingosource/castlib2/FileIOFunktionen.ls
r186 r241 7 7 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 8 8 9 on mGetTextFromFile me, pfad 9 on mGetTextFromFile me, pfad, readByteArray, useCharSet 10 10 retval = "" 11 12 11 if the runmode contains "Plugin" then return retval 13 12 14 13 fio = new(xtra "fileio") 15 16 14 if not objectP(fio) then return retval 15 16 useCharSet = string(useCharSet) 17 if length(useCharSet) > 0 then 18 if xscr().mGetVersionNumber() > 11.4 then 19 ------------- don't need to check whether the given charset is supported 20 ------------- as it is simply ignored, if it isn't 21 ------------- and it also gets reset so that the next instance of fileio 22 ------------- uses the default utf-8 again 23 -- installedCharSets = _system.getInstalledCharSets() 24 -- if installedCharSets.getPos(useCharSet) > 0 then fio.setCharSet(useCharSet) 25 fio.setCharSet(useCharSet) 26 end if 27 end if 17 28 18 29 if (voidP(pfad) or (pfad = "")) then pfad = mGetFilePathFromUser(me) … … 20 31 if ilk(pfad) = #string then 21 32 if pfad.length > 0 then 22 23 33 fio.openFile(pfad, 1) 24 34 if fio.status() = 0 then 25 26 retval = fio.readFile()35 if readByteArray = 1 then retval = fio.readByteArray(fio.getlength()) 36 else retval = fio.readFile() 27 37 fio.closeFile() 28 38 end if … … 33 43 end 34 44 45 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 46 47 on mGetByteArrayFromFile me, thePath 48 return mGetTextFromFile(me, thePath, (xscr().mGetVersionNumber() > 11.49)) 49 end 35 50 36 51 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx … … 44 59 -- paramList[#target] = instance 45 60 -- -- optional: 46 -- params[#theTimeOut] = 4000 -- milliseconds until operation times out 47 -- params[#progressHandler] = #progresscallbackFromGetText -- event sent whenever the percent done changes 61 -- paramList[#theTimeOut] = 4000 -- milliseconds until operation times out 62 -- paramList[#progressHandler] = #progresscallbackFromGetText -- event sent whenever the percent done changes 63 -- paramList[#isByteArray] = 0 -- boolean value, only D11 64 -- paramList[#charset] = "windows-1252" -- string, only D11 48 65 -- -- paramList[#customdata] = "whatever you need" 66 -- xscr(#FileIOFunktionen).mGetTextFromFileAsync(paramList) 67 49 68 -- 50 69 --on callbackFromGetText me, paramList … … 63 82 if not(internetLink) then internetLink = (fname starts "www.") 64 83 if the runmode contains "plugin" or internetLink then 65 -- scr = xscr().mGetInstance("NetLingoManagerPS__") 84 85 -- scr = xscr().mGetInstance("NetLingoManagerPS") 66 86 -- if ilk(scr) = #instance then 67 87 -- scr.mStartNetOP(paramList) … … 77 97 -- end if 78 98 else 79 paramList.setaprop(#theTextResult, mGetTextFromFile(me, paramList.getaprop(#theURL) ))99 paramList.setaprop(#theTextResult, mGetTextFromFile(me, paramList.getaprop(#theURL), paramList[#isByteArray], paramList[#charset])) 80 100 call(paramList.getaprop(#handler), [paramList.getaprop(#target)], paramList) 81 101 end if … … 83 103 84 104 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 105 106 on mGetByteArrayFromFileAsync me, paramList 107 paramList[#isByteArray] = 1 108 mGetTextFromFileAsync me, paramList 109 end 110 111 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 85 112 -- xxxxxxxxxxxxxxxxxx Write text out to a file 86 113 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 87 114 88 on mSaveToTextFile me, theText, pfad, theTitle, theDefaultName, startfolder 115 on mSaveToTextFile me, theText, pfad, theTitle, theDefaultName, startfolder, useCharSet 89 116 retval = 0 90 117 … … 98 125 fio = new(xtra "fileio") 99 126 if not objectP(fio) then return retval 127 128 useCharSet = string(useCharSet) 129 if length(useCharSet) > 0 then 130 if xscr().mGetVersionNumber() > 11.4 then 131 ------------- don't need to check whether the given charset is supported 132 ------------- as it is simply ignored, if it isn't 133 ------------- and it also gets reset so that the next instance of fileio 134 ------------- uses the default utf-8 again 135 -- installedCharSets = _system.getInstalledCharSets() 136 -- if installedCharSets.getPos(useCharSet) > 0 then fio.setCharSet(useCharSet) 137 fio.setCharSet(useCharSet) 138 end if 139 end if 140 100 141 101 142 if ilk(theTitle) <> #string then theTitle = "Save File"
Note: See TracChangeset
for help on using the changeset viewer.
