Changeset 245 for trunk/lingosource/castlib2/FileIOFunktionen.ls
- Timestamp:
- 03/21/10 11:39:48 (2 years ago)
- File:
-
- 1 edited
-
trunk/lingosource/castlib2/FileIOFunktionen.ls (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lingosource/castlib2/FileIOFunktionen.ls
r244 r245 1 -- FileIO Handlers -- c03 Alex da Franca -- alex@farbflash.de 2 --------------------------------------------------------------------- 1 -- FileIOFunktionen 2 ----------------------------------- 3 -- CREATED: 4 -- c03 Alex da Franca -- alex@farbflash.de 5 -- PROPERTIES: 6 --!memberProperties: [#name: "FileIOFunktionen", #scripttype: #parent, #scriptSyntax: #lingo, #comments: "~/Documents/Scripts/lingo/FileIOFunktionen.ls"] 7 -- 8 -- DESCRIPTION: FileIO Handlers 9 -- - 10 -- 11 -- REQUIRES: 12 -- (Prerequisites) 13 -- 14 -- USAGE: 15 -- - 16 -- 17 -- EXAMPLE: 18 -- - 19 ----------------------------------- 20 21 on _____________________PROPERTY_DECLARATION me 22 end 23 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 24 property ancestor 25 26 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 27 on ___________________STANDARD_EVENTS me 28 end 29 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 30 31 on new me 32 Script_Root_Object = member("Script_Root_Object") 33 if ilk(Script_Root_Object) = #member then 34 if Script_Root_Object.type = #script then 35 ancestor = new(script "Script_Root_Object") 36 mSetScriptName me, "FileIOFunktionen" 37 end if 38 end if 39 return me 40 end 41 42 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 43 on ___________________PUBLIC_EVENTS me 44 end 45 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 3 46 4 47 … … 98 141 else 99 142 paramList.setaprop(#theTextResult, mGetTextFromFile(me, paramList.getaprop(#theURL), paramList[#isByteArray], paramList[#charset])) 100 call(paramList.getaprop(#handler), [paramList.getaprop(#target)], paramList) 143 theResult = xscr().mDoDelayedCallback(paramList) 144 if theResult <> 1 then call(paramList.getaprop(#handler), [paramList.getaprop(#target)], paramList) 101 145 end if 102 146 end … … 321 365 322 366 on mGetFilePathFromUser me, startDir, defaultName, filetypes, prompt 367 ----------------------------------- 368 -- CREATED: - 369 -- ACTION: Asks the user for a path to a file and returns the filepath 370 -- INPUT: <startDir> ; string ; the directory to start the file selection dialog (only if buddyApi xtra is installed) 371 -- <defaultName> ; string ; pre-entered filename (only if buddyApi xtra is installed) 372 -- <filetypes> ; string ; filetype filter (only if buddyApi xtra is installed) 373 -- <prompt> ; string ; Caption of the dialog (only if buddyApi xtra is installed) 374 -- RETURNS: string ; absolute pathname delimited by the pathdelimiter of the current platform (widnows: "\", mac: ":") or "", if user canceled the process 375 -- EXAMPLE: relPath = xscr(#FileIOFunktionen).mGetFilePathFromUser(the moviepath, "soundRadius.xml", ".xml", "Please select soundradius scriptsettings") 376 ----------------------------------- 377 323 378 retval = "" 324 379 … … 361 416 362 417 return retval 418 end 419 420 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 421 422 on mGetMovieRelativePathFromUser me, startDir, defaultName, filetypes, prompt 423 ----------------------------------- 424 -- CREATED: 14.12.2009 425 -- ACTION: Asks the user for a path to a file 426 -- Takes care, that the file starts with the moviepath => is WITHIN the moviepath, 427 -- otherwise it calls itself until either the user selects a relative file or cancels the process. 428 -- Converts path delimiters to "/" => normalize the pathdelimiter for both platforms 429 -- INPUT: <startDir> ; string ; the directory to start the file selection dialog (only if buddyApi xtra is installed) 430 -- <defaultName> ; string ; pre-entered filename (only if buddyApi xtra is installed) 431 -- <filetypes> ; string ; filetype filter (only if buddyApi xtra is installed) 432 -- SPECIAL VALUE: can be "folder", which would not return a path to a folder, 433 -- but rather a path to a folder 434 -- <prompt> ; string ; Caption of the dialog (only if buddyApi xtra is installed) 435 -- RETURNS: string ; relative pathname delimited by "/" or "", if user canceled the process 436 -- EXAMPLE: relPath = xscr(#FileIOFunktionen).mGetMovieRelativePathFromUser(the moviepath, "soundRadius.xml", ".xml", "Please select soundradius scriptsettings") 437 ----------------------------------- 438 439 if filetypes = "folder" then 440 searchItem = "folder" 441 thePath = mGetFolderPathFromUser(me) 442 else 443 searchItem = "file" 444 thePath = mGetFilePathFromUser(me, startDir, defaultName, filetypes, prompt) 445 end if 446 if length(thePath) > 0 then 447 if offset(the moviepath, thePath) <> 1 then 448 alert "This " & searchItem & " is NOT within the moviepath. Please choose a " & searchItem & ", which is inside the current movie's path!" 449 return mGetMovieRelativePathFromUser(me, startDir, defaultName, filetypes, prompt) 450 end if 451 delete char 1 to length(the moviepath) of thePath 452 delim = the last char of the moviepath 453 if delim <> "/" then 454 offs = offset(delim, thePath) 455 repeat while offs > 0 456 put "/" into char offs of thePath 457 offs = offset(delim, thePath) 458 end repeat 459 end if 460 if filetypes = "folder" then 461 if the last char of thePath <> "/" then put "/" after thePath 462 end if 463 end if 464 return thePath 363 465 end 364 466
Note: See TracChangeset
for help on using the changeset viewer.
