| 1 | -- alexUtilities |
|---|
| 2 | ----------------------------------- |
|---|
| 3 | -- CREATED: |
|---|
| 4 | -- 14.12.2008 |
|---|
| 5 | -- PROPERTIES: |
|---|
| 6 | --!memberProperties: [#name: "alexUtilities", #scripttype: #parent, #scriptSyntax: #lingo, #comments: "~/Documents/Scripts/lingo/commonMovieScript.ls"] |
|---|
| 7 | -- |
|---|
| 8 | -- DESCRIPTION: |
|---|
| 9 | -- Some of my Authoring Utility Handlers -- c06 Alex da Franca -- alex@farbflash.de |
|---|
| 10 | -- |
|---|
| 11 | -- REQUIRES: |
|---|
| 12 | -- script "PseudoXMLPS" -> parse xml |
|---|
| 13 | -- although it does not really REQUIRE shell xtra and buddyApi xtra |
|---|
| 14 | -- still much of the functionality will gracefully fail, if those are not present |
|---|
| 15 | -- In order to export images, the sharp image exporter is required |
|---|
| 16 | -- if missing those functions fail gracefully |
|---|
| 17 | -- |
|---|
| 18 | -- USAGE: |
|---|
| 19 | -- This script is instantiated and used in the "tell the stage" block and one of the functions |
|---|
| 20 | -- which are defined in script "OSCmenu_Utilities" and which was selected by the user |
|---|
| 21 | -- will be executed in "stage scope". That means, that references are made form within the stage context |
|---|
| 22 | -- e.g. member("foo") will refer to a member in one of the stages castlibs |
|---|
| 23 | -- sprite(x) will refere to sprite(x) in the stages score and so on |
|---|
| 24 | -- |
|---|
| 25 | -- Please see the descriptions of many of those handlers at: http://www.farbflash.org/trac/HandlerMenu/wiki/utilityHandlers |
|---|
| 26 | -- (Although I started to comment each handler, I didn't reach far until now...) |
|---|
| 27 | ----------------------------------- |
|---|
| 28 | |
|---|
| 29 | property ancestor |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | -- since this script runs in "stage scope" we just set the name off the handlerMenu window |
|---|
| 33 | -- so that this script can "tell" something to the window, where it originates from => the tool miaw window |
|---|
| 34 | -- this is used for the "mDisplayWaitStatusText" and "mSwitchToStatusMode" handler at the moment |
|---|
| 35 | property pHandlerMenuWindowName |
|---|
| 36 | property pStatusMode -- are we in "show status" mode => maximized |
|---|
| 37 | |
|---|
| 38 | property pCaseLists |
|---|
| 39 | |
|---|
| 40 | property pCachedFiles |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | on new me |
|---|
| 44 | pCachedFiles = [:] |
|---|
| 45 | ancestor = new(script "PseudoXMLPS") -- we need this script later |
|---|
| 46 | -- and as we may already be in the scope of the stage, we use it as ancestor |
|---|
| 47 | -- because once in another scope, it will not be available as member |
|---|
| 48 | return me |
|---|
| 49 | end |
|---|
| 50 | |
|---|
| 51 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 52 | -- xxxxxxxxxxxxxxxxxx color( -> rgb( |
|---|
| 53 | -- fix the score data which has #color instead of #rgb when authored with D10, which fails with the older player |
|---|
| 54 | |
|---|
| 55 | on Authoring_ExchangeScriptListColorsToRGBs me |
|---|
| 56 | ----------------------------------- |
|---|
| 57 | -- ACTION: fix the score data which has #color instead of #rgb when authored with D10 |
|---|
| 58 | -- which fails with the older player (AUTHORING ONLY!) |
|---|
| 59 | -- INPUT: - |
|---|
| 60 | -- RETURNS: - |
|---|
| 61 | ----------------------------------- |
|---|
| 62 | |
|---|
| 63 | theLastFrame = the lastFrame |
|---|
| 64 | theLastChannel = the lastChannel |
|---|
| 65 | |
|---|
| 66 | repeat with theFrame = 1 to theLastFrame |
|---|
| 67 | go to theFrame |
|---|
| 68 | |
|---|
| 69 | repeat with theSprite = 1 to theLastChannel |
|---|
| 70 | tScriptList = sprite(theSprite).scriptList |
|---|
| 71 | if listP(tScriptList) then |
|---|
| 72 | cnt = count(tScriptList) |
|---|
| 73 | doChange = 0 |
|---|
| 74 | |
|---|
| 75 | repeat with behNr = 1 to cnt |
|---|
| 76 | thisBeh = tScriptList[behNr] |
|---|
| 77 | if stringP(thisBeh[2]) then |
|---|
| 78 | tString = thisBeh[2] |
|---|
| 79 | offs = offset("color(", tString) |
|---|
| 80 | repeat while offs > 0 |
|---|
| 81 | doChange = 1 |
|---|
| 82 | put "rgb(" into char offs to (offs+5) of tString |
|---|
| 83 | offs = offset("color(", tString) |
|---|
| 84 | end repeat |
|---|
| 85 | thisBeh[2] = tString |
|---|
| 86 | end if |
|---|
| 87 | end repeat |
|---|
| 88 | |
|---|
| 89 | if doChange then |
|---|
| 90 | sprite(theSprite).setScriptList(tScriptList) |
|---|
| 91 | end if |
|---|
| 92 | end if |
|---|
| 93 | end repeat |
|---|
| 94 | |
|---|
| 95 | end repeat |
|---|
| 96 | end |
|---|
| 97 | |
|---|
| 98 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 99 | |
|---|
| 100 | on mOpenContainingFolder me |
|---|
| 101 | ----------------------------------- |
|---|
| 102 | -- ACTION: Open the folder, where the current movie is inside in the Finder/Explorer |
|---|
| 103 | -- INPUT: - |
|---|
| 104 | -- RETURNS: - |
|---|
| 105 | ----------------------------------- |
|---|
| 106 | |
|---|
| 107 | if length(the moviepath) < 1 then |
|---|
| 108 | alert "The movie must be saved first!" |
|---|
| 109 | exit |
|---|
| 110 | end if |
|---|
| 111 | if the platform contains "mac" then theApp = "Finder.app" |
|---|
| 112 | else theApp = "Explorer.exe" |
|---|
| 113 | open the moviepath with theApp |
|---|
| 114 | end |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 118 | on ______________XML_IMPORT_EXPORT_HANDLERS me |
|---|
| 119 | end |
|---|
| 120 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 121 | |
|---|
| 122 | on mReadXML_2_List me, pfad |
|---|
| 123 | ----------------------------------- |
|---|
| 124 | -- ACTION: Read xml text from file and parse into lingo list using pseudoXMLPS script |
|---|
| 125 | -- INPUT: <pfad> ; string ; full pathname ; optional => default "" => show file selection dialog |
|---|
| 126 | -- RETURNS: lingo list or property list ; [:] in case of invalid xml file |
|---|
| 127 | ----------------------------------- |
|---|
| 128 | |
|---|
| 129 | theResult = pCachedFiles.getaprop(pfad) |
|---|
| 130 | if listP(theResult) then return theResult |
|---|
| 131 | |
|---|
| 132 | theResult = [:] |
|---|
| 133 | dertext = mGetTextFromFile(me, pfad) |
|---|
| 134 | if length(dertext) > 0 then |
|---|
| 135 | statusSwitched = mSwitchToStatusMode(me, 1) |
|---|
| 136 | theResult = mGetListFromXMLStringX(me, dertext) |
|---|
| 137 | pCachedFiles.setaProp(pfad, theResult) |
|---|
| 138 | if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0) |
|---|
| 139 | end if |
|---|
| 140 | return theResult |
|---|
| 141 | end |
|---|
| 142 | |
|---|
| 143 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 144 | |
|---|
| 145 | on mClearXML_Cache me, string_fullPath |
|---|
| 146 | ----------------------------------- |
|---|
| 147 | -- ACTION: We have a cache for xml files, sio that we do not need to parse the same |
|---|
| 148 | -- file over and over again, as itis time consuming esp. during repeat loops |
|---|
| 149 | -- so we store the result in pCachedFiles by filename. |
|---|
| 150 | -- In order to flush this cache for either one file (with parameter) or all files |
|---|
| 151 | -- (without parameter) use this handler |
|---|
| 152 | -- |
|---|
| 153 | -- INPUT: <string_fullPath> ; string ; full pathname ; optional => default "" => clear all cahced files |
|---|
| 154 | -- RETURNS: - |
|---|
| 155 | ----------------------------------- |
|---|
| 156 | |
|---|
| 157 | string_fullPath = string(string_fullPath) |
|---|
| 158 | if length(string_fullPath) > 0 then |
|---|
| 159 | pCachedFiles.deleteProp(string_fullPath) |
|---|
| 160 | else |
|---|
| 161 | pCachedFiles = [:] |
|---|
| 162 | end if |
|---|
| 163 | end |
|---|
| 164 | |
|---|
| 165 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 166 | |
|---|
| 167 | on mSaveList_2_XML me, theList, thePath |
|---|
| 168 | ----------------------------------- |
|---|
| 169 | -- ACTION: Convert a lingo list or property list to xml and write xml string to file |
|---|
| 170 | -- INPUT: <theList> ; #list or #proplist ; required |
|---|
| 171 | -- <thePath> ; string ; full pathname ; optional => default "" => show file save dialog |
|---|
| 172 | -- RETURNS: string => full pathname of newly created file or "", if user cancelled process |
|---|
| 173 | ----------------------------------- |
|---|
| 174 | |
|---|
| 175 | if not(list(theList)) then |
|---|
| 176 | global gRetVal |
|---|
| 177 | theList = gRetval |
|---|
| 178 | if not(list(theList)) then theList = [:] |
|---|
| 179 | end if |
|---|
| 180 | pCachedFiles.setaProp(thePath, theList) |
|---|
| 181 | theResult = mGetXMLStringFromList(me, theList) |
|---|
| 182 | return mSaveToTextFile(me, theResult, thePath) |
|---|
| 183 | end |
|---|
| 184 | |
|---|
| 185 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 186 | on ______________FILEIO_HANDLERS me |
|---|
| 187 | end |
|---|
| 188 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 192 | -- xxxxxxxxxxxxxxxxxx Read text in (if no path is provided show open dialog) |
|---|
| 193 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 194 | |
|---|
| 195 | on mGetTextFromFile me, pfad |
|---|
| 196 | ----------------------------------- |
|---|
| 197 | -- ACTION: Read contents of textfile |
|---|
| 198 | -- INPUT: <pfad> ; string ; full pathname ; optional => default "" => show file selection dialog |
|---|
| 199 | -- RETURNS: string => contents of textfile or "", if user cancelled process |
|---|
| 200 | ----------------------------------- |
|---|
| 201 | |
|---|
| 202 | retval = "" |
|---|
| 203 | |
|---|
| 204 | if the runmode contains "Plugin" then return retval |
|---|
| 205 | |
|---|
| 206 | fio = new(xtra "fileio") |
|---|
| 207 | |
|---|
| 208 | if not objectP(fio) then return retval |
|---|
| 209 | |
|---|
| 210 | if (voidP(pfad) or (pfad = "")) then pfad = fio.displayOpen() |
|---|
| 211 | |
|---|
| 212 | if ilk(pfad) = #string then |
|---|
| 213 | if pfad.length > 0 then |
|---|
| 214 | |
|---|
| 215 | fio.openFile(pfad, 1) |
|---|
| 216 | if fio.status() = 0 then |
|---|
| 217 | |
|---|
| 218 | retval = fio.readFile() |
|---|
| 219 | fio.closeFile() |
|---|
| 220 | end if |
|---|
| 221 | end if |
|---|
| 222 | end if |
|---|
| 223 | fio = void |
|---|
| 224 | return retval |
|---|
| 225 | end |
|---|
| 226 | |
|---|
| 227 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 228 | -- xxxxxxxxxxxxxxxxxx Write text out to a file |
|---|
| 229 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 230 | |
|---|
| 231 | on mSaveToTextFile me, theText, pfad, theTitle, theDefaultName, startfolder |
|---|
| 232 | ----------------------------------- |
|---|
| 233 | -- ACTION: Save text to textfile |
|---|
| 234 | -- INPUT: <theText> ; string ; string to save |
|---|
| 235 | -- <pfad> ; string ; full pathname ; optional => default "" => show file save dialog |
|---|
| 236 | -- <theTitle> ; string ; caption of the save dialog (if any => pfad == "") |
|---|
| 237 | -- <theDefaultName> ; string ; default filename provided in the save dialog (if any => pfad == "") |
|---|
| 238 | -- <startfolder> ; string ; startfolder of the save dialog (if any => pfad == "") |
|---|
| 239 | -- RETURNS: string => full pathname of newly created file or "", if user cancelled process |
|---|
| 240 | ----------------------------------- |
|---|
| 241 | |
|---|
| 242 | |
|---|
| 243 | retval = 0 |
|---|
| 244 | |
|---|
| 245 | if ilk(theText) <> #string then return retval |
|---|
| 246 | |
|---|
| 247 | if the runmode contains "plugin" then |
|---|
| 248 | if ilk(theDefaultName) <> #string then theDefaultName = "Untitled" |
|---|
| 249 | gotonetpage("mailto:alex@farbflash.de?subject="&theDefaultName&"&body="&urlencode(theText)) |
|---|
| 250 | return 1 |
|---|
| 251 | else |
|---|
| 252 | fio = new(xtra "fileio") |
|---|
| 253 | if not objectP(fio) then return retval |
|---|
| 254 | |
|---|
| 255 | if ilk(theTitle) <> #string then theTitle = "Save File" |
|---|
| 256 | |
|---|
| 257 | if ilk(theDefaultName) <> #string then theDefaultName = "Untitled" |
|---|
| 258 | |
|---|
| 259 | if (voidP(pfad) or (pfad = "")) then |
|---|
| 260 | if mCheckForXtra(me, "BudAPI") = 1 then |
|---|
| 261 | |
|---|
| 262 | resetUNames = 0 |
|---|
| 263 | if baSysFolder("prefs") starts "/" then |
|---|
| 264 | baReturnUnixNames(0) |
|---|
| 265 | resetUNames = 1 |
|---|
| 266 | end if |
|---|
| 267 | |
|---|
| 268 | startfolder = string(startfolder) |
|---|
| 269 | if length(startfolder) > 0 then |
|---|
| 270 | pfad = baGetFilename("save", startfolder, theDefaultName, "", 524288+4+2+4194304, theTitle, false, -1, -1) |
|---|
| 271 | else |
|---|
| 272 | pfad = baGetFilename("save", "", theDefaultName, "", 524288+4+2+4194304, theTitle, false, -1, -1) |
|---|
| 273 | end if |
|---|
| 274 | |
|---|
| 275 | if resetUNames = 1 then baReturnUnixNames(1) |
|---|
| 276 | |
|---|
| 277 | else |
|---|
| 278 | pfad = fio.displaySave(theTitle, theDefaultName) |
|---|
| 279 | end if |
|---|
| 280 | end if |
|---|
| 281 | |
|---|
| 282 | if ilk(pfad) = #string then |
|---|
| 283 | if pfad.length > 0 then |
|---|
| 284 | |
|---|
| 285 | fio.openFile(pfad, 0) |
|---|
| 286 | if fio.status() = 0 then fio.delete() |
|---|
| 287 | |
|---|
| 288 | fio.createFile(pfad) |
|---|
| 289 | if fio.status() = 0 then |
|---|
| 290 | |
|---|
| 291 | fio.openFile(pfad, 2) |
|---|
| 292 | if fio.status() = 0 then |
|---|
| 293 | |
|---|
| 294 | fio.writeString(theText) |
|---|
| 295 | |
|---|
| 296 | -- retval = (fio.status() = 0) |
|---|
| 297 | if fio.status() = 0 then retval = pfad |
|---|
| 298 | |
|---|
| 299 | fio.closeFile() |
|---|
| 300 | end if |
|---|
| 301 | end if |
|---|
| 302 | end if |
|---|
| 303 | end if |
|---|
| 304 | |
|---|
| 305 | fio = 0 |
|---|
| 306 | |
|---|
| 307 | end if |
|---|
| 308 | |
|---|
| 309 | return retval |
|---|
| 310 | end |
|---|
| 311 | |
|---|
| 312 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 313 | -- xxxxxxxxxxxxxxxxxx Write text out to a file |
|---|
| 314 | --------------------- helper for the bbdiff and svn handler |
|---|
| 315 | |
|---|
| 316 | on mSaveTextToTempFile me, theText, pfad |
|---|
| 317 | ----------------------------------- |
|---|
| 318 | -- ACTION: Write text out to a temporary file |
|---|
| 319 | -- (helper for the bbdiff and svn handler) |
|---|
| 320 | -- INPUT: <theText> ; string ; string to save |
|---|
| 321 | -- <pfad> ; string ; full pathname ; optional => default "tmpfile.txt" in temporary files folder |
|---|
| 322 | -- RETURNS: string => full pathname of newly created file or "", if user cancelled process |
|---|
| 323 | ----------------------------------- |
|---|
| 324 | |
|---|
| 325 | pfad = string(pfad) |
|---|
| 326 | |
|---|
| 327 | if length(pfad) < 1 then pfad = mGetTempFilePath(me, "tmpfile.txt") |
|---|
| 328 | |
|---|
| 329 | return mSaveToTextFile(me, theText, pfad) |
|---|
| 330 | |
|---|
| 331 | end |
|---|
| 332 | |
|---|
| 333 | |
|---|
| 334 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 335 | -- xxxxxxxxxxxxxxxxxx append string to file |
|---|
| 336 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 337 | |
|---|
| 338 | |
|---|
| 339 | on mAppendTextToFile me, theText, pfad |
|---|
| 340 | ----------------------------------- |
|---|
| 341 | -- ACTION: Write text out to a temporary file |
|---|
| 342 | -- (helper for the bbdiff and svn handler) |
|---|
| 343 | -- INPUT: <theText> ; string ; string to append to file <pfad> |
|---|
| 344 | -- <pfad> ; string ; full pathname ; optional => default "" => show file selection dialog |
|---|
| 345 | -- RETURNS: string => full pathname of newly created file or "", if user cancelled process |
|---|
| 346 | ----------------------------------- |
|---|
| 347 | |
|---|
| 348 | retval = 0 |
|---|
| 349 | |
|---|
| 350 | if ilk(theText) <> #string then return retval |
|---|
| 351 | |
|---|
| 352 | pfad = string(pfad) |
|---|
| 353 | |
|---|
| 354 | olddelim = the itemdelimiter |
|---|
| 355 | the itemdelimiter = the last char of the moviepath |
|---|
| 356 | fname = the last item of pfad |
|---|
| 357 | the itemdelimiter = olddelim |
|---|
| 358 | |
|---|
| 359 | if the runmode contains "plugin" then |
|---|
| 360 | if not(fname.length) then fname = "Untitled.txt" |
|---|
| 361 | altertext = getpref(fname) |
|---|
| 362 | if voidP(altertext) then altertext = theText |
|---|
| 363 | else put RETURN & theText after altertext |
|---|
| 364 | setpref(fname, altertext) |
|---|
| 365 | return 1 |
|---|
| 366 | else |
|---|
| 367 | |
|---|
| 368 | fio = new(xtra "fileio") |
|---|
| 369 | if not objectP(fio) then return retval |
|---|
| 370 | |
|---|
| 371 | if pfad.length then |
|---|
| 372 | |
|---|
| 373 | if mCheckFileExists(me, pfad) = 0 then |
|---|
| 374 | if mCheckFileExists(me, the moviepath & pfad) = 0 then |
|---|
| 375 | fio.createFile(the moviepath & fname) |
|---|
| 376 | else |
|---|
| 377 | theText = RETURN & theText |
|---|
| 378 | end if |
|---|
| 379 | fio.openFile(the moviepath & pfad, 0) |
|---|
| 380 | else |
|---|
| 381 | |
|---|
| 382 | theText = RETURN & theText |
|---|
| 383 | fio.openFile(pfad, 0) |
|---|
| 384 | end if |
|---|
| 385 | |
|---|
| 386 | else |
|---|
| 387 | pfad = the moviepath & the moviename & "_log.txt" |
|---|
| 388 | |
|---|
| 389 | if mCheckFileExists(me, pfad) = 0 then fio.createFile(pfad) |
|---|
| 390 | else theText = RETURN & theText |
|---|
| 391 | |
|---|
| 392 | fio.openFile(pfad, 0) |
|---|
| 393 | end if |
|---|
| 394 | |
|---|
| 395 | if fio.status() <> 0 then |
|---|
| 396 | fio = 0 |
|---|
| 397 | return retval |
|---|
| 398 | end if |
|---|
| 399 | |
|---|
| 400 | fio.setPosition(fio.getLength()) |
|---|
| 401 | |
|---|
| 402 | fio.writeString(theText) |
|---|
| 403 | |
|---|
| 404 | retval = (fio.status() = 0) |
|---|
| 405 | |
|---|
| 406 | fio.closeFile() |
|---|
| 407 | fio = 0 |
|---|
| 408 | |
|---|
| 409 | end if |
|---|
| 410 | |
|---|
| 411 | return retval |
|---|
| 412 | end |
|---|
| 413 | |
|---|
| 414 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 415 | |
|---|
| 416 | on mExportSelectedText me, theType |
|---|
| 417 | |
|---|
| 418 | cl = the activecastlib |
|---|
| 419 | sel = the selection of castlib cl |
|---|
| 420 | if not sel.count then exit |
|---|
| 421 | memref = member(sel[1][1], cl) |
|---|
| 422 | if [#text, #field].getPos(memref.type) < 1 then exit |
|---|
| 423 | |
|---|
| 424 | theDefaultName = memref.name |
|---|
| 425 | |
|---|
| 426 | theType = string(theType) |
|---|
| 427 | |
|---|
| 428 | if length(theType) < 1 then |
|---|
| 429 | splitpath = mSplitPath(me, theDefaultName) |
|---|
| 430 | -- if offset(".", theDefaultName) > 1 then |
|---|
| 431 | -- theType = theDefaultName.char[offset(".", theDefaultName) + 1 .. length(theDefaultName)] |
|---|
| 432 | -- end if |
|---|
| 433 | if length(splitpath[#extension]) > 0 then |
|---|
| 434 | theType = splitpath[#extension] |
|---|
| 435 | delete char 1 of theType |
|---|
| 436 | end if |
|---|
| 437 | forceType = 0 |
|---|
| 438 | else |
|---|
| 439 | if char 1 of theType = "#" then delete char 1 of theType |
|---|
| 440 | |
|---|
| 441 | if theType = "text" then theType = "txt" |
|---|
| 442 | if theType starts "plain" then theType = "txt" |
|---|
| 443 | |
|---|
| 444 | forceType = 1 |
|---|
| 445 | end if |
|---|
| 446 | |
|---|
| 447 | if memref.type = #field then |
|---|
| 448 | theType = "txt" |
|---|
| 449 | forceType = 1 |
|---|
| 450 | end if |
|---|
| 451 | |
|---|
| 452 | |
|---|
| 453 | if ["txt", "rtf", "htm", "html"].getPos(theType) < 1 then theType = "txt" |
|---|
| 454 | |
|---|
| 455 | |
|---|
| 456 | if theDefaultName = "" then theDefaultName = "Untitled." & theType |
|---|
| 457 | if offset(".", theDefaultName) < 1 then put "." & theType after theDefaultName |
|---|
| 458 | |
|---|
| 459 | theTitle = "Save text" |
|---|
| 460 | if mCheckForXtra(me, "BudAPI") = 1 then |
|---|
| 461 | |
|---|
| 462 | resetUNames = 0 |
|---|
| 463 | if baSysFolder("prefs") starts "/" then |
|---|
| 464 | baReturnUnixNames(0) |
|---|
| 465 | resetUNames = 1 |
|---|
| 466 | end if |
|---|
| 467 | |
|---|
| 468 | pfad = baGetFilename("save", "", theDefaultName, "", 524288+4+2+4194304, theTitle, false, -1, -1) |
|---|
| 469 | |
|---|
| 470 | if resetUNames = 1 then baReturnUnixNames(1) |
|---|
| 471 | |
|---|
| 472 | else |
|---|
| 473 | fio = new(xtra "fileio") |
|---|
| 474 | pfad = fio.displaySave(theTitle, theDefaultName) |
|---|
| 475 | fio = 0 |
|---|
| 476 | end if |
|---|
| 477 | |
|---|
| 478 | if forceType = 0 then |
|---|
| 479 | len = length(pfad) |
|---|
| 480 | if len < 1 then exit |
|---|
| 481 | -- basename = pfad |
|---|
| 482 | -- ext = "" |
|---|
| 483 | -- repeat with n = len down to 1 |
|---|
| 484 | -- c = char n of pfad |
|---|
| 485 | -- if c = "." then exit repeat |
|---|
| 486 | -- put c before ext |
|---|
| 487 | -- if length(ext) > 4 then exit repeat |
|---|
| 488 | -- end repeat |
|---|
| 489 | -- if ["txt", "rtf", "htm", "html"].getPos(ext) > 0 then theType = ext |
|---|
| 490 | splitpath = mSplitPath(me, pfad) |
|---|
| 491 | ext = splitpath[#extension] |
|---|
| 492 | if length(ext) > 0 then |
|---|
| 493 | if ".txt.rtf.htm.html" contains ext then |
|---|
| 494 | delete char 1 of ext |
|---|
| 495 | theType = ext |
|---|
| 496 | end if |
|---|
| 497 | end if |
|---|
| 498 | end if |
|---|
| 499 | |
|---|
| 500 | case theType of |
|---|
| 501 | "rtf": |
|---|
| 502 | derText = memref.rtf |
|---|
| 503 | "htm", "html": |
|---|
| 504 | derText = memref.html |
|---|
| 505 | otherwise: |
|---|
| 506 | derText = memref.text |
|---|
| 507 | end case |
|---|
| 508 | |
|---|
| 509 | mSaveToTextFile me, derText, pfad, "Save file", theDefaultName |
|---|
| 510 | |
|---|
| 511 | end |
|---|
| 512 | |
|---|
| 513 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 514 | |
|---|
| 515 | on mGetFilePathFromUser me |
|---|
| 516 | retval = "" |
|---|
| 517 | |
|---|
| 518 | if the runmode contains "Plugin" then return retval |
|---|
| 519 | |
|---|
| 520 | if mCheckForXtra(me, "BudAPI") = 1 then -- if buddy is present... |
|---|
| 521 | |
|---|
| 522 | resetUNames = 0 |
|---|
| 523 | if baSysFolder("prefs") starts "/" then |
|---|
| 524 | baReturnUnixNames(0) |
|---|
| 525 | resetUNames = 1 |
|---|
| 526 | end if |
|---|
| 527 | |
|---|
| 528 | -- if the platform contains "mac" then filter = "" |
|---|
| 529 | -- else filter = "*.*" |
|---|
| 530 | retval = baGetFilename("Please select file", "", "Filename", "*.*", 524288+2+4+4194304, "Select file", false, -2, -2) |
|---|
| 531 | |
|---|
| 532 | if resetUNames = 1 then baReturnUnixNames(1) |
|---|
| 533 | |
|---|
| 534 | else |
|---|
| 535 | fio = new(xtra "fileio") |
|---|
| 536 | |
|---|
| 537 | if not objectP(fio) then return retval |
|---|
| 538 | |
|---|
| 539 | retval = fio.displayOpen() |
|---|
| 540 | |
|---|
| 541 | fio = void |
|---|
| 542 | |
|---|
| 543 | end if |
|---|
| 544 | |
|---|
| 545 | return retval |
|---|
| 546 | end |
|---|
| 547 | |
|---|
| 548 | |
|---|
| 549 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 550 | |
|---|
| 551 | on mGetFolderPathFromUser me, startFolder, theTitle, flags, instruction, offsx, offsy |
|---|
| 552 | retval = "" |
|---|
| 553 | |
|---|
| 554 | if the runmode contains "Plugin" then return retval |
|---|
| 555 | |
|---|
| 556 | if mCheckForXtra(me, "BudAPI") = 1 then -- if buddy is present... |
|---|
| 557 | |
|---|
| 558 | resetUNames = 0 |
|---|
| 559 | if baSysFolder("prefs") starts "/" then |
|---|
| 560 | baReturnUnixNames(0) |
|---|
| 561 | resetUNames = 1 |
|---|
| 562 | end if |
|---|
| 563 | |
|---|
| 564 | startFolder = string(startFolder) |
|---|
| 565 | instruction = string(instruction) |
|---|
| 566 | flags = integer(flags) |
|---|
| 567 | if ilk(flags) <> #integer then flags = 0 |
|---|
| 568 | theTitle = string(theTitle) |
|---|
| 569 | |
|---|
| 570 | offsx = integer(offsx) |
|---|
| 571 | if ilk(offsx) <> #integer then offsx = -1 |
|---|
| 572 | |
|---|
| 573 | offsy = integer(offsy) |
|---|
| 574 | if ilk(offsy) <> #integer then offsy = -1 |
|---|
| 575 | |
|---|
| 576 | retval = baGetFolder(startFolder, theTitle, flags, instruction, offsx, offsy ) |
|---|
| 577 | |
|---|
| 578 | if resetUNames = 1 then baReturnUnixNames(1) |
|---|
| 579 | |
|---|
| 580 | else if mCheckForXtra(me, "FileXtra4") = 1 then -- if not buddy then try filextra |
|---|
| 581 | fx = (xtra "filextra4").new() |
|---|
| 582 | if objectP(fx) then |
|---|
| 583 | retval = fx.fx_FolderSelectDialog("") |
|---|
| 584 | end if |
|---|
| 585 | fx = 0 |
|---|
| 586 | else |
|---|
| 587 | fio = new(xtra "fileio") |
|---|
| 588 | if not objectP(fio) then return retval |
|---|
| 589 | retval = fio.displayOpen() |
|---|
| 590 | if length(retval) > 0 then |
|---|
| 591 | olddelim = the itemdelimiter |
|---|
| 592 | the itemdelimiter = the last char of the moviepath |
|---|
| 593 | delete the last item of retval |
|---|
| 594 | put the itemdelimiter after retval |
|---|
| 595 | the itemdelimiter = olddelim |
|---|
| 596 | end if |
|---|
| 597 | fio = void |
|---|
| 598 | end if |
|---|
| 599 | |
|---|
| 600 | return retval |
|---|
| 601 | end |
|---|
| 602 | |
|---|
| 603 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 604 | |
|---|
| 605 | on mGetFileList me, folderpath |
|---|
| 606 | if the runmode contains "plugin" then return [] |
|---|
| 607 | |
|---|
| 608 | if length(string(folderpath)) < 1 then folderpath = mGetFolderPathFromUser(me) |
|---|
| 609 | if length(folderpath) < 1 then return [] |
|---|
| 610 | |
|---|
| 611 | if mCheckForXtra(me, "BudAPI") = 1 then -- if buddy is present... |
|---|
| 612 | |
|---|
| 613 | -- currently there is a bug in buddy beta with bafilelist, so we hack here... |
|---|
| 614 | if mGetFloatVersionNumber(me, the productversion) < 11 then |
|---|
| 615 | |
|---|
| 616 | -- -- budApi version: |
|---|
| 617 | retval = baFileList(folderpath, "*.*") |
|---|
| 618 | |
|---|
| 619 | else |
|---|
| 620 | |
|---|
| 621 | retval = [] |
|---|
| 622 | n = 1 |
|---|
| 623 | this = getnthfilenameinfolder(folderpath, n) |
|---|
| 624 | repeat while length(this) > 0 |
|---|
| 625 | if length(getnthfilenameinfolder(folderpath & this, 1)) = 0 then retval.add(this) |
|---|
| 626 | n = n + 1 |
|---|
| 627 | this = getnthfilenameinfolder(folderpath, n) |
|---|
| 628 | end repeat |
|---|
| 629 | |
|---|
| 630 | end if |
|---|
| 631 | |
|---|
| 632 | |
|---|
| 633 | else if mCheckForXtra(me, "FileXtra4") = 1 then -- if not buddy then try filextra |
|---|
| 634 | -- -- filextra4 version: |
|---|
| 635 | fx = (xtra "filextra4").new() |
|---|
| 636 | if objectP(fx) then |
|---|
| 637 | retval = fx.fx_FolderToList(folderpath) |
|---|
| 638 | delim = the last char of the moviepath |
|---|
| 639 | repeat with n = count(retval) down to 1 |
|---|
| 640 | if the last char of retval[n] = delim then retval.deleteAt(n) |
|---|
| 641 | end repeat |
|---|
| 642 | end if |
|---|
| 643 | fx = 0 |
|---|
| 644 | |
|---|
| 645 | else |
|---|
| 646 | |
|---|
| 647 | retval = [] |
|---|
| 648 | n = 1 |
|---|
| 649 | this = getnthfilenameinfolder(folderpath, n) |
|---|
| 650 | repeat while length(this) > 0 |
|---|
| 651 | if length(getnthfilenameinfolder(folderpath & this, 1)) = 0 then retval.add(this) |
|---|
| 652 | n = n + 1 |
|---|
| 653 | this = getnthfilenameinfolder(folderpath, n) |
|---|
| 654 | end repeat |
|---|
| 655 | end if |
|---|
| 656 | |
|---|
| 657 | return retval |
|---|
| 658 | end |
|---|
| 659 | |
|---|
| 660 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 661 | |
|---|
| 662 | on mGetFolderList me, folderpath |
|---|
| 663 | if the runmode contains "plugin" then return [] |
|---|
| 664 | |
|---|
| 665 | if length(string(folderpath)) < 1 then folderpath = mGetFolderPathFromUser(me) |
|---|
| 666 | if length(folderpath) < 1 then return [] |
|---|
| 667 | |
|---|
| 668 | if mCheckForXtra(me, "BudAPI") = 1 then -- if buddy is present... |
|---|
| 669 | -- -- budApi version: |
|---|
| 670 | retval = baFolderList(folderpath) |
|---|
| 671 | |
|---|
| 672 | else if mCheckForXtra(me, "FileXtra4") = 1 then -- if not buddy then try filextra |
|---|
| 673 | -- -- filextra4 version: |
|---|
| 674 | fx = (xtra "filextra4").new() |
|---|
| 675 | if objectP(fx) then |
|---|
| 676 | retval = fx.fx_FolderToList(folderpath) |
|---|
| 677 | delim = the last char of the moviepath |
|---|
| 678 | repeat with n = count(retval) down to 1 |
|---|
| 679 | |
|---|
| 680 | if the last char of retval[n] <> delim then |
|---|
| 681 | retval.deleteAt(n) |
|---|
| 682 | else |
|---|
| 683 | str = retval[n] |
|---|
| 684 | -- delete the last char of str |
|---|
| 685 | retval[n] = str |
|---|
| 686 | end if |
|---|
| 687 | |
|---|
| 688 | end repeat |
|---|
| 689 | end if |
|---|
| 690 | fx = 0 |
|---|
| 691 | |
|---|
| 692 | else |
|---|
| 693 | |
|---|
| 694 | retval = [] |
|---|
| 695 | n = 1 |
|---|
| 696 | this = getnthfilenameinfolder(folderpath, n) |
|---|
| 697 | repeat while length(this) > 0 |
|---|
| 698 | if length(getnthfilenameinfolder(folderpath & this, 1)) > 0 then retval.add(this) |
|---|
| 699 | n = n + 1 |
|---|
| 700 | this = getnthfilenameinfolder(folderpath, n) |
|---|
| 701 | end repeat |
|---|
| 702 | end if |
|---|
| 703 | |
|---|
| 704 | return retval |
|---|
| 705 | |
|---|
| 706 | end |
|---|
| 707 | |
|---|
| 708 | |
|---|
| 709 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 710 | on ______________SHARP_IMAGE_EXPORT me |
|---|
| 711 | end |
|---|
| 712 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 713 | |
|---|
| 714 | -- Two handlers I wrote to deal with Werner Sharps great Bitmap export Xtra (SharpXtra) |
|---|
| 715 | -- get the xtra and infos about it at: http://www.sharp-software.com |
|---|
| 716 | |
|---|
| 717 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 718 | -- export the selected members of a castlib: |
|---|
| 719 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 720 | |
|---|
| 721 | -- -- ARGUMENTS: |
|---|
| 722 | -- thePath: #string -> filename; if not a string or "" then a save selection dialog (fileio) is displayed |
|---|
| 723 | |
|---|
| 724 | -- theType: #symbol -> type of output file; possible values: #jpg, #png, #bmp, #pct |
|---|
| 725 | -- if voidP or not a symbol then defaults to #pct on mac and #bmp on windows |
|---|
| 726 | |
|---|
| 727 | -- compr: #integer -> jpg quality |
|---|
| 728 | |
|---|
| 729 | -- USAGE: |
|---|
| 730 | -- Select the members you want to export |
|---|
| 731 | -- type in the message window: |
|---|
| 732 | -- -- new(script "SharpImageExport").mExportSelectedBMs(#png) |
|---|
| 733 | -- or |
|---|
| 734 | -- -- new(script "SharpImageExport").mExportSelectedBMs(#jpg, 60) |
|---|
| 735 | -- or |
|---|
| 736 | -- -- new(script "SharpImageExport").mExportSelectedBMs("", "", the moviepath&"myBitmap") |
|---|
| 737 | |
|---|
| 738 | on mExportSelectedBMs me, theType, compr, thePath |
|---|
| 739 | |
|---|
| 740 | thePath = mGetSaveFolderPath(me, thePath) |
|---|
| 741 | if thePath = 0 then exit |
|---|
| 742 | |
|---|
| 743 | |
|---|
| 744 | mp = the moviepath |
|---|
| 745 | if length(mp) < 1 then mp = the applicationpath |
|---|
| 746 | |
|---|
| 747 | |
|---|
| 748 | |
|---|
| 749 | theType = string(theType) |
|---|
| 750 | |
|---|
| 751 | mac = the last char of mp = ":" |
|---|
| 752 | if length(theType) < 1 then |
|---|
| 753 | -- if mac then theType = "pct" |
|---|
| 754 | -- else theType = "bmp" |
|---|
| 755 | theType = "png" |
|---|
| 756 | end if |
|---|
| 757 | if (mac and (theType = "bmp")) then theType = "pct" |
|---|
| 758 | if (not(mac) and (theType = "pct")) then theType = "bmp" |
|---|
| 759 | |
|---|
| 760 | -- theDot = offset(".", thePath) |
|---|
| 761 | -- if theDot then thePath = thePath.char[1 .. (theDot - 1)] |
|---|
| 762 | splitpath = mSplitPath(me, thePath) |
|---|
| 763 | thePath = splitpath[#basedir] & splitpath[#basename] |
|---|
| 764 | |
|---|
| 765 | if not(["jpg", "png", "bmp", "pct"].getPos(theType)) then exit |
|---|
| 766 | |
|---|
| 767 | statusSwitched = mSwitchToStatusMode(me, 1) |
|---|
| 768 | |
|---|
| 769 | useMemberName = (the last char of thePath = the last char of mp) |
|---|
| 770 | |
|---|
| 771 | cl = the activecastlib |
|---|
| 772 | sel = the selection of castlib cl |
|---|
| 773 | anz = sel.count |
|---|
| 774 | cnt = 1 |
|---|
| 775 | repeat with n = 1 to anz |
|---|
| 776 | repeat with m = sel[n][1] to sel[n][2] |
|---|
| 777 | memref = member(m, cl) |
|---|
| 778 | dertyp = memref.type |
|---|
| 779 | if dertyp = #bitmap then |
|---|
| 780 | if useMemberName then |
|---|
| 781 | currPath = thePath&memref.name&"."&theType |
|---|
| 782 | else |
|---|
| 783 | if cnt = 1 then |
|---|
| 784 | currPath = thePath&"."&theType |
|---|
| 785 | else |
|---|
| 786 | currPath = thePath&cnt&"."&theType |
|---|
| 787 | end if |
|---|
| 788 | end if |
|---|
| 789 | theResult = mExportBM(me, memref, currPath, theType, compr) |
|---|
| 790 | if not theResult then put "Failed on member"&&memref.number&":"&memref.name |
|---|
| 791 | cnt = cnt + 1 |
|---|
| 792 | end if |
|---|
| 793 | end repeat |
|---|
| 794 | end repeat |
|---|
| 795 | |
|---|
| 796 | if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0) |
|---|
| 797 | |
|---|
| 798 | end |
|---|
| 799 | |
|---|
| 800 | |
|---|
| 801 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 802 | -- export a single member or imageObject: |
|---|
| 803 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 804 | |
|---|
| 805 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 806 | -- -- ARGUMENTS: |
|---|
| 807 | |
|---|
| 808 | -- BMmember: #member, #integer, #string or #imageObject |
|---|
| 809 | |
|---|
| 810 | -- thePath: #string -> filename; if not a string or "" then a save selection dialog (fileio) is displayed |
|---|
| 811 | |
|---|
| 812 | -- theType: #symbol -> type of output file; possible values: #jpg, #png, #bmp, #pct |
|---|
| 813 | -- if voidP or not a symbol then defaults to #pct on mac and #bmp on windows |
|---|
| 814 | |
|---|
| 815 | -- compr: #integer -> jpg quality |
|---|
| 816 | |
|---|
| 817 | -- USAGE: |
|---|
| 818 | -- type in the message window: |
|---|
| 819 | -- -- new(script "SharpImageExport").mExportBM(member("myBitmap")) |
|---|
| 820 | -- or |
|---|
| 821 | -- -- new(script "SharpImageExport").mExportBM(imageObject) |
|---|
| 822 | -- or |
|---|
| 823 | -- -- new(script "SharpImageExport").mExportBM("myTextmember") |
|---|
| 824 | -- etc., etc. |
|---|
| 825 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 826 | |
|---|
| 827 | on mExportBM me, BMmember, thePath, theType, compr, xtraInst |
|---|
| 828 | |
|---|
| 829 | -- first check all arguments: |
|---|
| 830 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 831 | -- check the member or if an imageObject create a member |
|---|
| 832 | |
|---|
| 833 | theType = string(theType) |
|---|
| 834 | |
|---|
| 835 | delmem = 0 |
|---|
| 836 | if ilk(BMmember) = #image then |
|---|
| 837 | -- preserve the alphachannel: |
|---|
| 838 | -- to export to other filetypes flatten the alphachannel first |
|---|
| 839 | if ((BMmember.depth = 32) and BMmember.useAlpha) then theType = "png" |
|---|
| 840 | |
|---|
| 841 | tempmember = new(#bitmap) |
|---|
| 842 | tempmember.image = BMmember |
|---|
| 843 | delmem = 1 |
|---|
| 844 | else |
|---|
| 845 | tempmember = member(BMmember) |
|---|
| 846 | case tempmember.type of |
|---|
| 847 | #bitmap: |
|---|
| 848 | -- preserve the alphachannel: |
|---|
| 849 | -- to export to other filetypes flatten the alphachannel first |
|---|
| 850 | if ((BMmember.depth = 32) and BMmember.useAlpha) then theType = "png" |
|---|
| 851 | #text, #vectorshape, #flash, #realmedia, #shockwave3d: |
|---|
| 852 | -- preserve the alphachannel: |
|---|
| 853 | -- to export to other fileformats flatten the alphachannel first |
|---|
| 854 | if not([#realmedia, #shockwave3d].getPos(tempmember.type)) then theType = "png" |
|---|
| 855 | |
|---|
| 856 | temp = new(#bitmap) |
|---|
| 857 | temp.image = tempmember.image |
|---|
| 858 | delmem = 1 |
|---|
| 859 | tempmember = temp |
|---|
| 860 | otherwise |
|---|
| 861 | alert "Bitmap missing" |
|---|
| 862 | exit |
|---|
| 863 | end case |
|---|
| 864 | end if |
|---|
| 865 | |
|---|
| 866 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 867 | -- check the pathname |
|---|
| 868 | thePath = mGetSavePath(me, thePath) |
|---|
| 869 | if thePath = 0 then |
|---|
| 870 | if delmem then tempmember.erase() |
|---|
| 871 | exit |
|---|
| 872 | end if |
|---|
| 873 | |
|---|
| 874 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 875 | -- check theType |
|---|
| 876 | mp = the moviepath |
|---|
| 877 | if length(mp) < 1 then mp = the applicationpath |
|---|
| 878 | mac = the last char of mp = ":" |
|---|
| 879 | if length(theType) < 1 then |
|---|
| 880 | -- if mac then theType = "pct" |
|---|
| 881 | -- else theType = "bmp" |
|---|
| 882 | theType = "png" |
|---|
| 883 | end if |
|---|
| 884 | if (mac and (theType = "bmp")) then theType = "pct" |
|---|
| 885 | if (not(mac) and (theType = "pct")) then theType = "bmp" |
|---|
| 886 | |
|---|
| 887 | -- -- ensure the right file extension: |
|---|
| 888 | |
|---|
| 889 | -- theDot = offset(".", thePath) |
|---|
| 890 | -- if theDot = 0 then thePath = thePath&"."&theType |
|---|
| 891 | |
|---|
| 892 | splitpath = mSplitPath(me, thePath) |
|---|
| 893 | if length(splitpath[#extension]) < 1 then splitpath[#extension] = "." & theType |
|---|
| 894 | thePath = splitpath[#basedir] & splitpath[#basename] & splitpath[#extension] |
|---|
| 895 | |
|---|
| 896 | -- else thePath = thePath.char[1 .. theDot]&theType |
|---|
| 897 | |
|---|
| 898 | |
|---|
| 899 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 900 | -- create an instance of Werner Sharps cool Xtra: |
|---|
| 901 | if not(objectP(xtraInst)) then |
|---|
| 902 | xtraInst = new (xtra "SharpExport") |
|---|
| 903 | if not(objectP(xtraInst)) then |
|---|
| 904 | if delmem then tempmember.erase() |
|---|
| 905 | alert "Sharp Xtra missing" |
|---|
| 906 | exit |
|---|
| 907 | end if |
|---|
| 908 | delXtra = 1 |
|---|
| 909 | end if |
|---|
| 910 | |
|---|
| 911 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 912 | -- export bitmap |
|---|
| 913 | case theType of |
|---|
| 914 | "jpg": |
|---|
| 915 | -- Saving as a JPG (8-bit castmember or higher): |
|---|
| 916 | if ilk(compr) <> #integer then compr = 100 |
|---|
| 917 | theResult = xtraInst.exportJPG(tempmember, thePath, compr) |
|---|
| 918 | |
|---|
| 919 | -- parameter 1 - bitmap member reference |
|---|
| 920 | -- parameter 2 - pathname to save to |
|---|
| 921 | -- parameter 3 - jpeg compression level (higher is better quality) |
|---|
| 922 | |
|---|
| 923 | "png": |
|---|
| 924 | -- Saving as a PNG: |
|---|
| 925 | theResult = xtraInst.exportPNG(tempmember, thePath) |
|---|
| 926 | |
|---|
| 927 | "bmp": |
|---|
| 928 | -- Saving as a BMP (Windows only): |
|---|
| 929 | theResult = xtraInst.exportBMP(tempmember, thePath) |
|---|
| 930 | |
|---|
| 931 | "pct": |
|---|
| 932 | -- Saving a PICT (Macintosh only): |
|---|
| 933 | theResult = xtraInst.exportPICT(tempmember, thePath) |
|---|
| 934 | |
|---|
| 935 | end case |
|---|
| 936 | |
|---|
| 937 | |
|---|
| 938 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 939 | -- Possible Error Codes: |
|---|
| 940 | case theResult of |
|---|
| 941 | 0: |
|---|
| 942 | retval = 1 -- success |
|---|
| 943 | -1: |
|---|
| 944 | retval = 0 |
|---|
| 945 | put "Sharp Xtra Error: Destination file can not be written" |
|---|
| 946 | -2: |
|---|
| 947 | retval = 0 |
|---|
| 948 | put "Sharp Xtra Error: Out of memory" |
|---|
| 949 | -3: |
|---|
| 950 | retval = 0 |
|---|
| 951 | put "Sharp Xtra Error: Wrong number of args" |
|---|
| 952 | -4: |
|---|
| 953 | retval = 0 |
|---|
| 954 | put "Sharp Xtra Error: Bad parameter" |
|---|
| 955 | -5: |
|---|
| 956 | retval = 0 |
|---|
| 957 | put "Sharp Xtra Error: Castmember not found" |
|---|
| 958 | -6: |
|---|
| 959 | retval = 0 |
|---|
| 960 | put "Sharp Xtra Error: Castmember media not found" |
|---|
| 961 | -7: |
|---|
| 962 | retval = 0 |
|---|
| 963 | put "Sharp Xtra Error: Castmember is not a bitmap" |
|---|
| 964 | -8: |
|---|
| 965 | retval = 0 |
|---|
| 966 | put "Sharp Xtra Error: Unsupported bitdepth (JPEG support is 8 bits or higher)" |
|---|
| 967 | -9: |
|---|
| 968 | retval = 0 |
|---|
| 969 | put "Sharp Xtra Error: JPEG compression failed (internal error with JPEG library)" |
|---|
| 970 | -10: |
|---|
| 971 | retval = 0 |
|---|
| 972 | put "Sharp Xtra Error: PNG compression failed (internal error with PNG library)" |
|---|
| 973 | otherwise |
|---|
| 974 | retval = 0 |
|---|
| 975 | put "Sharp Xtra Error: Unknown error" |
|---|
| 976 | end case |
|---|
| 977 | |
|---|
| 978 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 979 | -- cleanup |
|---|
| 980 | if delmem then tempmember.erase() |
|---|
| 981 | if delXtra = 1 then xtraInst = 0 |
|---|
| 982 | |
|---|
| 983 | -- return boolean for success |
|---|
| 984 | return retval |
|---|
| 985 | end |
|---|
| 986 | |
|---|
| 987 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 988 | -- display a save dialog, if necessary |
|---|
| 989 | on mGetSavePath me, thePath |
|---|
| 990 | displaySave = (ilk(thePath) <> #string) |
|---|
| 991 | if not displaySave then displaySave = not(thePath.length) |
|---|
| 992 | |
|---|
| 993 | if displaySave then |
|---|
| 994 | fio = new(xtra "fileio") |
|---|
| 995 | if not objectP(fio) then exit |
|---|
| 996 | thePath = fio.displaySave("Select Destination", "Untitled") |
|---|
| 997 | fio = 0 |
|---|
| 998 | end if |
|---|
| 999 | |
|---|
| 1000 | if not thePath.length then return 0 |
|---|
| 1001 | else return thePath |
|---|
| 1002 | end |
|---|
| 1003 | |
|---|
| 1004 | |
|---|
| 1005 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1006 | -- display a save dialog, if necessary |
|---|
| 1007 | on mGetSaveFolderPath me, thePath |
|---|
| 1008 | displaySave = (ilk(thePath) <> #string) |
|---|
| 1009 | if not displaySave then displaySave = not(thePath.length) |
|---|
| 1010 | |
|---|
| 1011 | if displaySave then |
|---|
| 1012 | thePath = mGetFolderPathFromUser(me) |
|---|
| 1013 | end if |
|---|
| 1014 | |
|---|
| 1015 | if not thePath.length then return 0 |
|---|
| 1016 | else return thePath |
|---|
| 1017 | end |
|---|
| 1018 | |
|---|
| 1019 | |
|---|
| 1020 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1021 | on ______________AUTHORING_UTILITIES me |
|---|
| 1022 | end |
|---|
| 1023 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1024 | |
|---|
| 1025 | |
|---|
| 1026 | |
|---|
| 1027 | on mDeleteMembersByName me, praefix |
|---|
| 1028 | |
|---|
| 1029 | searchParams = mProcessSearchString(me, praefix) |
|---|
| 1030 | searchString = searchParams.getaprop(#searchString) |
|---|
| 1031 | |
|---|
| 1032 | repeat with n = 1 to the number of castlibs |
|---|
| 1033 | repeat with z = 1 to the number of members of castlib n |
|---|
| 1034 | |
|---|
| 1035 | case searchParams.getaprop(#searchMode) of |
|---|
| 1036 | |
|---|
| 1037 | #startsWith: |
|---|
| 1038 | if member(z, n).name starts searchString then |
|---|
| 1039 | member(z, n).erase() |
|---|
| 1040 | end if |
|---|
| 1041 | |
|---|
| 1042 | #endsWith: |
|---|
| 1043 | theName = member(z, n).name |
|---|
| 1044 | len = length(theName) |
|---|
| 1045 | startchar = len - length(searchString) + 1 |
|---|
| 1046 | if theName.char[startchar .. len] = searchString then |
|---|
| 1047 | member(z, n).erase() |
|---|
| 1048 | end if |
|---|
| 1049 | |
|---|
| 1050 | #equals: |
|---|
| 1051 | if member(z, n).name = searchString then |
|---|
| 1052 | member(z, n).erase() |
|---|
| 1053 | end if |
|---|
| 1054 | |
|---|
| 1055 | otherwise: |
|---|
| 1056 | if member(z, n).name contains searchString then |
|---|
| 1057 | member(z, n).erase() |
|---|
| 1058 | end if |
|---|
| 1059 | |
|---|
| 1060 | end case |
|---|
| 1061 | |
|---|
| 1062 | end repeat |
|---|
| 1063 | end repeat |
|---|
| 1064 | end |
|---|
| 1065 | |
|---|
| 1066 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1067 | |
|---|
| 1068 | on mProcessSearchString me, srchString |
|---|
| 1069 | |
|---|
| 1070 | searchmode = #contains |
|---|
| 1071 | |
|---|
| 1072 | if char 1 of srchString = "^" then |
|---|
| 1073 | if the last char of srchString <> "$" then |
|---|
| 1074 | searchmode = #startsWith |
|---|
| 1075 | else |
|---|
| 1076 | searchmode = #equals |
|---|
| 1077 | delete the last char of srchString |
|---|
| 1078 | end if |
|---|
| 1079 | delete char 1 of srchString |
|---|
| 1080 | else |
|---|
| 1081 | if the last char of srchString = "$" then |
|---|
| 1082 | searchmode = #endsWith |
|---|
| 1083 | delete the last char of srchString |
|---|
| 1084 | end if |
|---|
| 1085 | end if |
|---|
| 1086 | |
|---|
| 1087 | return [#searchString:srchString, #searchMode:searchmode] |
|---|
| 1088 | end |
|---|
| 1089 | |
|---|
| 1090 | |
|---|
| 1091 | |
|---|
| 1092 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1093 | -- xxxxxxxxxxxxxxxxxx Fill/Remove empty castslots in a given castlib, to preserve the member ordering |
|---|
| 1094 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1095 | |
|---|
| 1096 | on ______________ARRANGE_CASTS |
|---|
| 1097 | end |
|---|
| 1098 | |
|---|
| 1099 | on mUnlinkBitmaps me |
|---|
| 1100 | cl = the activecastlib |
|---|
| 1101 | sel = the selection of castlib cl |
|---|
| 1102 | anz = sel.count |
|---|
| 1103 | repeat with n = 1 to anz |
|---|
| 1104 | repeat with m = sel[n][1] to sel[n][2] |
|---|
| 1105 | memref = member(m, cl) |
|---|
| 1106 | if memref.type = #bitmap then |
|---|
| 1107 | fname = memref.filename |
|---|
| 1108 | if fname.length then |
|---|
| 1109 | memref.importfileinto(fname, [#trimwhitespace:0]) |
|---|
| 1110 | put "imported:"&&memref |
|---|
| 1111 | end if |
|---|
| 1112 | end if |
|---|
| 1113 | end repeat |
|---|
| 1114 | end repeat |
|---|
| 1115 | end |
|---|
| 1116 | |
|---|
| 1117 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1118 | |
|---|
| 1119 | on mFillDummyMember me |
|---|
| 1120 | cnum = the number of castlibs |
|---|
| 1121 | repeat with cl = 1 to cnum |
|---|
| 1122 | num = the number of members of castlib cl |
|---|
| 1123 | repeat with n = 1 to num |
|---|
| 1124 | if member(n, cl).type = #empty then |
|---|
| 1125 | m = new(#bitmap, member(n, cl)) |
|---|
| 1126 | m.name = "DummyCastlibFillMember" |
|---|
| 1127 | end if |
|---|
| 1128 | end repeat |
|---|
| 1129 | end repeat |
|---|
| 1130 | end |
|---|
| 1131 | |
|---|
| 1132 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1133 | |
|---|
| 1134 | on mRemoveDummyMember me |
|---|
| 1135 | cnum = the number of castlibs |
|---|
| 1136 | repeat with cl = 1 to cnum |
|---|
| 1137 | num = the number of members of castlib cl |
|---|
| 1138 | repeat with n = 1 to num |
|---|
| 1139 | if member(n, cl).name = "DummyCastlibFillMember" then member(n, cl).erase() |
|---|
| 1140 | end repeat |
|---|
| 1141 | end repeat |
|---|
| 1142 | end |
|---|
| 1143 | |
|---|
| 1144 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1145 | -- xxxxxxxxxxxxxxxxxx Search Behavior Initializers |
|---|
| 1146 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1147 | |
|---|
| 1148 | on ______________FIND_ALL_IN_SCORE |
|---|
| 1149 | end |
|---|
| 1150 | |
|---|
| 1151 | -- search in all behavior initializers (GPDL) of the current movie for <str> |
|---|
| 1152 | -- if <str> is "" or void, then default to the current selected script member name as parameter |
|---|
| 1153 | |
|---|
| 1154 | on mFindInGPDL me, str |
|---|
| 1155 | |
|---|
| 1156 | statusSwitched = mSwitchToStatusMode(me, 1) |
|---|
| 1157 | |
|---|
| 1158 | letzterframe = the lastframe |
|---|
| 1159 | letzterkanal = the lastChannel |
|---|
| 1160 | |
|---|
| 1161 | if voidP(str) or str = "" then |
|---|
| 1162 | memstr = "" |
|---|
| 1163 | cl = the activecastlib |
|---|
| 1164 | sel = the selection of castlib cl |
|---|
| 1165 | repeat with thisSel in sel |
|---|
| 1166 | repeat with m = thisSel[1] to thisSel[2] |
|---|
| 1167 | thisMember = member(m, cl) |
|---|
| 1168 | if thisMember.type = #script then |
|---|
| 1169 | memstr = string(thisMember) |
|---|
| 1170 | exit repeat |
|---|
| 1171 | end if |
|---|
| 1172 | end repeat |
|---|
| 1173 | if length(memstr) > 0 then exit repeat |
|---|
| 1174 | end repeat |
|---|
| 1175 | |
|---|
| 1176 | else |
|---|
| 1177 | memstr = string(member(str)) |
|---|
| 1178 | end if |
|---|
| 1179 | |
|---|
| 1180 | retlist = [] |
|---|
| 1181 | repeat with fr = 1 to letzterframe |
|---|
| 1182 | go fr |
|---|
| 1183 | repeat with kn = 1 to letzterkanal |
|---|
| 1184 | if sprite(kn).startframe = fr then |
|---|
| 1185 | scrli = string(sprite(kn).scriptlist) |
|---|
| 1186 | if scrli.length > 2 then |
|---|
| 1187 | if offset(str, scrli) then |
|---|
| 1188 | retlist.add([#theFrame: fr, #theSprite:kn]) |
|---|
| 1189 | else if offset(memstr, scrli) then |
|---|
| 1190 | retlist.add([#theFrame: fr, #theSprite:kn]) |
|---|
| 1191 | end if |
|---|
| 1192 | end if |
|---|
| 1193 | end if |
|---|
| 1194 | end repeat |
|---|
| 1195 | end repeat |
|---|
| 1196 | |
|---|
| 1197 | if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0) |
|---|
| 1198 | |
|---|
| 1199 | return retlist |
|---|
| 1200 | end |
|---|
| 1201 | |
|---|
| 1202 | |
|---|
| 1203 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1204 | -- xxxxxxxxxxxxxxxxxx Find selected members in Score => CMD + H |
|---|
| 1205 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1206 | |
|---|
| 1207 | -- put mSelectInScore() -- current frame |
|---|
| 1208 | -- put mSelectInScore(1, 0) -- all frames |
|---|
| 1209 | -- put mSelectInScore(20, 30) -- frames 20 to 30 |
|---|
| 1210 | |
|---|
| 1211 | on mSelectInScore me, startfr, endfr |
|---|
| 1212 | |
|---|
| 1213 | |
|---|
| 1214 | ------------------------------ |
|---|
| 1215 | -- this allows to enter anything other than an integer or an integer < 1 in order to search all frames |
|---|
| 1216 | if not(voidP(startfr)) then |
|---|
| 1217 | startfr = integer(startfr) |
|---|
| 1218 | if voidP(startfr) then |
|---|
| 1219 | startfr = 1 |
|---|
| 1220 | endfr = 0 |
|---|
| 1221 | end if |
|---|
| 1222 | if startfr < 1 then |
|---|
| 1223 | startfr = 1 |
|---|
| 1224 | endfr = 0 |
|---|
| 1225 | end if |
|---|
| 1226 | end if |
|---|
| 1227 | ------------------------------ |
|---|
| 1228 | |
|---|
| 1229 | cl = the activecastlib |
|---|
| 1230 | castSel = castlib(cl).selection |
|---|
| 1231 | selectedMembers = [:] |
|---|
| 1232 | repeat with n = 1 to castSel.count |
|---|
| 1233 | thisSel = castSel[n] |
|---|
| 1234 | repeat with m = thisSel[1] to thisSel[2] |
|---|
| 1235 | thisMember = member(m, cl) |
|---|
| 1236 | -- ullala changed for woody - mb -- |
|---|
| 1237 | if not(voidP(thisMember)) then |
|---|
| 1238 | thisType = selectedMembers.getaprop(thisMember.type) |
|---|
| 1239 | end if |
|---|
| 1240 | -- ullala changed for woody - mb end -- |
|---|
| 1241 | if ilk(thisType) <> #list then |
|---|
| 1242 | thisType = [] |
|---|
| 1243 | selectedMembers.setaprop(thisMember.type, thisType) |
|---|
| 1244 | end if |
|---|
| 1245 | thisType.add(thisMember) |
|---|
| 1246 | end repeat |
|---|
| 1247 | end repeat |
|---|
| 1248 | |
|---|
| 1249 | thisType = selectedMembers.getaprop(#script) |
|---|
| 1250 | if listP(thisType) then |
|---|
| 1251 | repeat with n = thisType.count down to 1 |
|---|
| 1252 | if thisType[n].scriptType <> #score then |
|---|
| 1253 | thisType.deleteAt(n) |
|---|
| 1254 | else |
|---|
| 1255 | behavior = 1 |
|---|
| 1256 | end if |
|---|
| 1257 | end repeat |
|---|
| 1258 | if not(thisType.count) then |
|---|
| 1259 | selectedMembers.deleteProp(#script) |
|---|
| 1260 | behavior = 0 |
|---|
| 1261 | end if |
|---|
| 1262 | if not(selectedMembers.count) then return 0 |
|---|
| 1263 | end if |
|---|
| 1264 | |
|---|
| 1265 | specialType = [#script, #palette, #sound, #transition] |
|---|
| 1266 | otherTypes = [] |
|---|
| 1267 | repeat with n = selectedMembers.count down to 1 |
|---|
| 1268 | if not(specialType.getPos(selectedMembers.getPropAt(n))) then otherTypes.add(selectedMembers.getPropAt(n)) |
|---|
| 1269 | end repeat |
|---|
| 1270 | |
|---|
| 1271 | |
|---|
| 1272 | if voidP(startfr) then startfr = the frame |
|---|
| 1273 | if voidP(endfr) then endfr = the frame |
|---|
| 1274 | if endfr < 1 then endfr = the lastframe |
|---|
| 1275 | |
|---|
| 1276 | thelastChannel = the lastChannel |
|---|
| 1277 | |
|---|
| 1278 | theSelection = [] |
|---|
| 1279 | repeat with fr = startfr to endfr |
|---|
| 1280 | go fr |
|---|
| 1281 | |
|---|
| 1282 | -- effectchannels: |
|---|
| 1283 | |
|---|
| 1284 | -- scripts: |
|---|
| 1285 | if behavior then |
|---|
| 1286 | thisType = selectedMembers.getaprop(#script) |
|---|
| 1287 | |
|---|
| 1288 | if thisType.getPos(member(the framescript)) then theSelection.add([0, 0, fr, fr]) |
|---|
| 1289 | |
|---|
| 1290 | repeat with kn = 1 to thelastChannel |
|---|
| 1291 | currSpr = sprite(kn) |
|---|
| 1292 | if (currSpr.startframe = fr) or ((fr = startfr) and currSpr.startframe > 0) then |
|---|
| 1293 | |
|---|
| 1294 | scrli = currSpr.scriptlist |
|---|
| 1295 | if scrli.count then |
|---|
| 1296 | instCnt = scrli.count |
|---|
| 1297 | repeat with i = 1 to instCnt |
|---|
| 1298 | if thisType.getPos(scrLi[i][1]) then |
|---|
| 1299 | theSelection.add([kn, kn, currSpr.startframe, currSpr.endframe]) |
|---|
| 1300 | exit repeat |
|---|
| 1301 | end if |
|---|
| 1302 | end repeat |
|---|
| 1303 | end if |
|---|
| 1304 | |
|---|
| 1305 | end if |
|---|
| 1306 | end repeat |
|---|
| 1307 | |
|---|
| 1308 | end if |
|---|
| 1309 | |
|---|
| 1310 | thisType = selectedMembers.getaprop(#palette) |
|---|
| 1311 | if listP(thisType) then |
|---|
| 1312 | if thisType.getPos(member(the framepalette)) then theSelection.add([-4, -4, fr, fr]) |
|---|
| 1313 | next repeat |
|---|
| 1314 | end if |
|---|
| 1315 | |
|---|
| 1316 | thisType = selectedMembers.getaprop(#transition) |
|---|
| 1317 | if listP(thisType) then |
|---|
| 1318 | if thisType.getPos(member(the frametransition)) then theSelection.add([-3, -3, fr, fr]) |
|---|
| 1319 | next repeat |
|---|
| 1320 | end if |
|---|
| 1321 | |
|---|
| 1322 | thisType = selectedMembers.getaprop(#transition) |
|---|
| 1323 | if listP(thisType) then |
|---|
| 1324 | if thisType.getPos(member(the framesound1)) then theSelection.add([-2, -2, fr, fr]) |
|---|
| 1325 | next repeat |
|---|
| 1326 | if thisType.getPos(member(the framesound2)) then theSelection.add([-1, -1, fr, fr]) |
|---|
| 1327 | next repeat |
|---|
| 1328 | end if |
|---|
| 1329 | |
|---|
| 1330 | -- normal sprites: |
|---|
| 1331 | repeat with kn = 1 to thelastChannel |
|---|
| 1332 | currSpr = sprite(kn) |
|---|
| 1333 | if (currSpr.startframe = fr) or ((fr = startfr) and currSpr.startframe > 0) then |
|---|
| 1334 | repeat with theType in otherTypes |
|---|
| 1335 | thisType = selectedMembers.getaprop(theType) |
|---|
| 1336 | if listP(thisType) then |
|---|
| 1337 | if thisType.getPos(currSpr.member) then theSelection.add([kn, kn, currSpr.startframe, currSpr.endframe]) |
|---|
| 1338 | end if |
|---|
| 1339 | end repeat |
|---|
| 1340 | end if |
|---|
| 1341 | end repeat |
|---|
| 1342 | end repeat |
|---|
| 1343 | |
|---|
| 1344 | -- select in score: |
|---|
| 1345 | if theSelection.count then the scoreselection = theSelection |
|---|
| 1346 | else beep |
|---|
| 1347 | |
|---|
| 1348 | -- bring score to foreground (only works if UIHelper xtra is present): |
|---|
| 1349 | activateWindow(5) |
|---|
| 1350 | |
|---|
| 1351 | -- return the number of matches: |
|---|
| 1352 | return theSelection.count |
|---|
| 1353 | end |
|---|
| 1354 | |
|---|
| 1355 | |
|---|
| 1356 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1357 | |
|---|
| 1358 | on mListallPuts me |
|---|
| 1359 | |
|---|
| 1360 | statusSwitched = mSwitchToStatusMode(me, 1) |
|---|
| 1361 | |
|---|
| 1362 | mDisplayWaitStatusText me, "See the message window for results of search" |
|---|
| 1363 | |
|---|
| 1364 | cnum = the number of castlibs |
|---|
| 1365 | repeat with l = 1 to cnum |
|---|
| 1366 | mnum = the number of members of castlib l |
|---|
| 1367 | repeat with n = 1 to mnum |
|---|
| 1368 | memref = member(n, l) |
|---|
| 1369 | if memref.type = #script then |
|---|
| 1370 | st = memref.scripttext |
|---|
| 1371 | nl = the number of lines of st |
|---|
| 1372 | numlines = the number of lines of st |
|---|
| 1373 | repeat with r = 1 to numlines |
|---|
| 1374 | |
|---|
| 1375 | lin = line r of st |
|---|
| 1376 | |
|---|
| 1377 | offs = offset("put ", lin) |
|---|
| 1378 | |
|---|
| 1379 | if offs > 0 then |
|---|
| 1380 | |
|---|
| 1381 | theLine = lin |
|---|
| 1382 | |
|---|
| 1383 | |
|---|
| 1384 | |
|---|
| 1385 | if ((offs = 1) or (char offs-1 of lin = " ")) then |
|---|
| 1386 | |
|---|
| 1387 | linWOQuote = "" |
|---|
| 1388 | offs = offset(QUOTE, lin) |
|---|
| 1389 | repeat while offs > 0 |
|---|
| 1390 | put char 1 to offs-1 of lin & " " after linWOQuote |
|---|
| 1391 | delete char 1 to offs of lin |
|---|
| 1392 | offs = offset(QUOTE, lin) |
|---|
| 1393 | if offs > 0 then |
|---|
| 1394 | delete char 1 to offs of lin |
|---|
| 1395 | end if |
|---|
| 1396 | offs = offset(QUOTE, lin) |
|---|
| 1397 | end repeat |
|---|
| 1398 | put lin after linWOQuote |
|---|
| 1399 | |
|---|
| 1400 | offs = offset("--", linWOQuote) |
|---|
| 1401 | if offs > 0 then |
|---|
| 1402 | delete char offs to length(linWOQuote) of linWOQuote |
|---|
| 1403 | end if |
|---|
| 1404 | |
|---|
| 1405 | offs = offset("put ", linWOQuote) |
|---|
| 1406 | |
|---|
| 1407 | if offs > 0 then |
|---|
| 1408 | |
|---|
| 1409 | |
|---|
| 1410 | if not(linWOQuote contains " into ") then |
|---|
| 1411 | if not(linWOQuote contains " after ") then |
|---|
| 1412 | if not(linWOQuote contains " before ") then |
|---|
| 1413 | |
|---|
| 1414 | mDisplayWaitStatusText me, theLine |
|---|
| 1415 | |
|---|
| 1416 | put "-----------" |
|---|
| 1417 | le = length(st.line[1 .. r-1]) |
|---|
| 1418 | put memref & ": line" && r & ":" && theLine & RETURN & "activateScriptEditor" && n & "," && l & "," && le & "," && le+1 & RETURN & "-----------" |
|---|
| 1419 | end if |
|---|
| 1420 | end if |
|---|
| 1421 | end if |
|---|
| 1422 | end if |
|---|
| 1423 | end if |
|---|
| 1424 | end if |
|---|
| 1425 | |
|---|
| 1426 | end repeat |
|---|
| 1427 | end if |
|---|
| 1428 | end repeat |
|---|
| 1429 | end repeat |
|---|
| 1430 | |
|---|
| 1431 | if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0) |
|---|
| 1432 | |
|---|
| 1433 | end |
|---|
| 1434 | |
|---|
| 1435 | |
|---|
| 1436 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1437 | -- xxxxxxxxxxxxxxxxxx Member namen aendern |
|---|
| 1438 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1439 | |
|---|
| 1440 | on ______________PROCESS_MEMBER_NAMES |
|---|
| 1441 | end |
|---|
| 1442 | |
|---|
| 1443 | on mNameMemberNames me, newName |
|---|
| 1444 | cl = the activecastlib |
|---|
| 1445 | sel = the selection of castlib cl |
|---|
| 1446 | anz = sel.count |
|---|
| 1447 | repeat with n = 1 to anz |
|---|
| 1448 | repeat with m = sel[n][1] to sel[n][2] |
|---|
| 1449 | memref = member(m, cl) |
|---|
| 1450 | memref.name = newName |
|---|
| 1451 | end repeat |
|---|
| 1452 | end repeat |
|---|
| 1453 | end |
|---|
| 1454 | |
|---|
| 1455 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1456 | |
|---|
| 1457 | on mChangeMemName me, praefix, suffix |
|---|
| 1458 | cl = the activecastlib |
|---|
| 1459 | sel = the selection of castlib cl |
|---|
| 1460 | anz = sel.count |
|---|
| 1461 | repeat with n = 1 to anz |
|---|
| 1462 | repeat with m = sel[n][1] to sel[n][2] |
|---|
| 1463 | member(m,cl).name = praefix&member(m,cl).name&suffix |
|---|
| 1464 | end repeat |
|---|
| 1465 | end repeat |
|---|
| 1466 | end |
|---|
| 1467 | |
|---|
| 1468 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1469 | |
|---|
| 1470 | on mNumberMemberNames me, numberOfDigits, startnum, theDelimiter, stepSize |
|---|
| 1471 | cl = the activecastlib |
|---|
| 1472 | sel = the selection of castlib cl |
|---|
| 1473 | anz = sel.count |
|---|
| 1474 | anfangstr = string(startnum) |
|---|
| 1475 | repeat while anfangstr.length < numberOfDigits |
|---|
| 1476 | anfangstr = "0"&anfangstr |
|---|
| 1477 | end repeat |
|---|
| 1478 | |
|---|
| 1479 | repeat with n = 1 to anz |
|---|
| 1480 | repeat with m = sel[n][1] to sel[n][2] |
|---|
| 1481 | memref = member(m, cl) |
|---|
| 1482 | memref.name = memref.name & theDelimiter & anfangstr |
|---|
| 1483 | startnum = startnum + stepSize |
|---|
| 1484 | anfangstr = string(startnum) |
|---|
| 1485 | repeat while anfangstr.length < numberOfDigits |
|---|
| 1486 | anfangstr = "0"&anfangstr |
|---|
| 1487 | end repeat |
|---|
| 1488 | end repeat |
|---|
| 1489 | end repeat |
|---|
| 1490 | end |
|---|
| 1491 | |
|---|
| 1492 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1493 | |
|---|
| 1494 | on mReplaceInMemName me, searchstr, replacestring |
|---|
| 1495 | if not(searchstr.length) then exit |
|---|
| 1496 | |
|---|
| 1497 | cl = the activecastlib |
|---|
| 1498 | sel = the selection of castlib cl |
|---|
| 1499 | anz = sel.count |
|---|
| 1500 | repeat with n = 1 to anz |
|---|
| 1501 | repeat with m = sel[n][1] to sel[n][2] |
|---|
| 1502 | memref = member(m, cl) |
|---|
| 1503 | dername = memref.name |
|---|
| 1504 | stelle = offset(searchstr, dername) |
|---|
| 1505 | offs = 0 |
|---|
| 1506 | if stelle then |
|---|
| 1507 | neuername = "" |
|---|
| 1508 | repeat while stelle |
|---|
| 1509 | if stelle > 1 then neuername = neuername&dername.char[1 .. (stelle - 1)] |
|---|
| 1510 | neuername = neuername&replacestring |
|---|
| 1511 | dername = dername.char[(stelle + searchstr.length) .. dername.length] |
|---|
| 1512 | stelle = offset(searchstr, dername) |
|---|
| 1513 | if stelle = 0 then neuername = neuername&dername |
|---|
| 1514 | end repeat |
|---|
| 1515 | memref.name = neuername |
|---|
| 1516 | end if |
|---|
| 1517 | end repeat |
|---|
| 1518 | end repeat |
|---|
| 1519 | end |
|---|
| 1520 | |
|---|
| 1521 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1522 | -- xxxxxxxxxxxxxxxxxx Statistics |
|---|
| 1523 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1524 | |
|---|
| 1525 | |
|---|
| 1526 | on ______________STATISTICS |
|---|
| 1527 | end |
|---|
| 1528 | |
|---|
| 1529 | on GetScriptlines me, withoutComments, selectionOnly |
|---|
| 1530 | |
|---|
| 1531 | groesster = [0] |
|---|
| 1532 | scriptmems = 0 |
|---|
| 1533 | scriptlines = 0 |
|---|
| 1534 | numwords = 0 |
|---|
| 1535 | woerter = 0 |
|---|
| 1536 | |
|---|
| 1537 | if selectionOnly then |
|---|
| 1538 | cl = the activecastlib |
|---|
| 1539 | sel = the selection of castlib cl |
|---|
| 1540 | anz = sel.count |
|---|
| 1541 | repeat with n = 1 to anz |
|---|
| 1542 | repeat with m = sel[n][1] to sel[n][2] |
|---|
| 1543 | memref = member(m, cl) |
|---|
| 1544 | dertyp = memref.type |
|---|
| 1545 | if [#script].getPos(dertyp) then |
|---|
| 1546 | dertext = memref.scripttext |
|---|
| 1547 | scriptmems = scriptmems + 1 |
|---|
| 1548 | |
|---|
| 1549 | retlist = mGetScriptStats(me, dertext, withoutComments) |
|---|
| 1550 | |
|---|
| 1551 | scriptlines = scriptlines + retlist[1] |
|---|
| 1552 | woerter = woerter + retlist[2] |
|---|
| 1553 | numwords = numwords + retlist[3] |
|---|
| 1554 | |
|---|
| 1555 | if retlist[1] > groesster[1] then |
|---|
| 1556 | groesster[1] = retlist[1] |
|---|
| 1557 | groesster[2] = retlist[2] |
|---|
| 1558 | groesster[3] = retlist[3] |
|---|
| 1559 | groesster[4] = memref |
|---|
| 1560 | groesster[5] = memref.name |
|---|
| 1561 | end if |
|---|
| 1562 | end if |
|---|
| 1563 | end repeat |
|---|
| 1564 | end repeat |
|---|
| 1565 | else |
|---|
| 1566 | repeat with n = 1 to the number of castlibs |
|---|
| 1567 | mn = the number of members of castlib n |
|---|
| 1568 | repeat with m = 1 to mn |
|---|
| 1569 | if member(m,n).type = #script then |
|---|
| 1570 | |
|---|
| 1571 | dertext = member(m,n).scripttext |
|---|
| 1572 | scriptmems = scriptmems + 1 |
|---|
| 1573 | |
|---|
| 1574 | retlist = mGetScriptStats(me, dertext, withoutComments) |
|---|
| 1575 | |
|---|
| 1576 | scriptlines = scriptlines + retlist[1] |
|---|
| 1577 | woerter = woerter + retlist[2] |
|---|
| 1578 | numwords = numwords + retlist[3] |
|---|
| 1579 | |
|---|
| 1580 | if retlist[1] > groesster[1] then |
|---|
| 1581 | groesster[1] = retlist[1] |
|---|
| 1582 | groesster[2] = retlist[2] |
|---|
| 1583 | groesster[3] = retlist[3] |
|---|
| 1584 | groesster[4] = member(m,n) |
|---|
| 1585 | groesster[5] = member(m,n).name |
|---|
| 1586 | end if |
|---|
| 1587 | |
|---|
| 1588 | end if |
|---|
| 1589 | end repeat |
|---|
| 1590 | end repeat |
|---|
| 1591 | end if |
|---|
| 1592 | |
|---|
| 1593 | put "Number of Scriptmembers:"&&scriptmems |
|---|
| 1594 | put "Number of Scriptlines:"&&scriptlines |
|---|
| 1595 | put "Number of Words:"&&woerter |
|---|
| 1596 | put "Number of Chars:"&&numwords |
|---|
| 1597 | put "--------------" |
|---|
| 1598 | put "Biggest member:" |
|---|
| 1599 | put groesster[4] & "("&groesster[5]&")" |
|---|
| 1600 | put "Number of Scriptlines:"&&groesster[1] |
|---|
| 1601 | put "Number of Words:"&&groesster[2] |
|---|
| 1602 | put "Number of Chars:"&&groesster[3] |
|---|
| 1603 | |
|---|
| 1604 | end |
|---|
| 1605 | |
|---|
| 1606 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1607 | |
|---|
| 1608 | on mGetScriptStats me, scrText, withoutComments |
|---|
| 1609 | retlist = [] |
|---|
| 1610 | |
|---|
| 1611 | if withoutComments then |
|---|
| 1612 | scrli = [scrText] |
|---|
| 1613 | -- repeat with n = scrText.line.count down to 1 |
|---|
| 1614 | -- thisLine = scrText.line[n] |
|---|
| 1615 | -- if thisLine.word.count < 1 or offset("--", thisLine.word[1]) = 1 then delete line n of scrText |
|---|
| 1616 | -- end repeat |
|---|
| 1617 | |
|---|
| 1618 | pregex_replace(scrli, "\-\-[^\r]*", "ig", "") |
|---|
| 1619 | pregex_replace(scrli, "\r\W*\r", "gis", RETURN) |
|---|
| 1620 | |
|---|
| 1621 | scrText = scrli[1] |
|---|
| 1622 | end if |
|---|
| 1623 | |
|---|
| 1624 | retlist[1] = scrText.line.count |
|---|
| 1625 | retlist[2] = scrText.word.count |
|---|
| 1626 | retlist[3] = scrText.length |
|---|
| 1627 | return retlist |
|---|
| 1628 | |
|---|
| 1629 | end |
|---|
| 1630 | |
|---|
| 1631 | |
|---|
| 1632 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1633 | -- xxxxxxxxxxxxxxxxxx open director help miau with searchstring <theText> |
|---|
| 1634 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1635 | |
|---|
| 1636 | on ______________HELP_MIAW_FUNCTIONS |
|---|
| 1637 | end |
|---|
| 1638 | |
|---|
| 1639 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1640 | |
|---|
| 1641 | on mGetHelpWindowRef me |
|---|
| 1642 | |
|---|
| 1643 | ap = the applicationpath |
|---|
| 1644 | delim = the last char of ap |
|---|
| 1645 | n = 1 |
|---|
| 1646 | pfade = [] |
|---|
| 1647 | pfade.add(ap & "Help" & delim & "help.dir") -- director 8.5 |
|---|
| 1648 | pfade.add(ap & "Xtras" & delim & "help.dir") -- director 9 |
|---|
| 1649 | pfade.add(ap & "Configuration" & delim & "Xtras" & delim & "help.dir") -- director 10 Win |
|---|
| 1650 | if offset("Contents", ap) then |
|---|
| 1651 | olddelim = the itemdelimiter |
|---|
| 1652 | the itemdelimiter = delim |
|---|
| 1653 | delete the last item of ap |
|---|
| 1654 | delete the last item of ap |
|---|
| 1655 | delete the last item of ap |
|---|
| 1656 | delete the last item of ap |
|---|
| 1657 | put delim after ap |
|---|
| 1658 | the itemdelimiter = olddelim |
|---|
| 1659 | end if |
|---|
| 1660 | pfade.add(ap & "Configuration" & delim & "Xtras" & delim & "help.dir") -- director 10 OSX |
|---|
| 1661 | |
|---|
| 1662 | pfad = pfade[n] |
|---|
| 1663 | repeat while mCheckFileExists(me, pfad) = 0 |
|---|
| 1664 | n = n + 1 |
|---|
| 1665 | if n > count(pfade) then |
|---|
| 1666 | alertList = [#buttons: #YesNo, #default:1, #title: "Help Miaw missing", #message: "The help miaw is missing, do you want to visit the website of the help miaw tool?", #icon:#question, #movable: 0] |
|---|
| 1667 | mui = new(xtra "MUI") |
|---|
| 1668 | resp = mui.alert(alertList) |
|---|
| 1669 | mui = 0 |
|---|
| 1670 | if resp = 1 then |
|---|
| 1671 | if mCheckForXtra(me, "BudAPI") then |
|---|
| 1672 | -- give BudAPI precedence before gotonetpage |
|---|
| 1673 | baOpenURL("http://www.farbflash.de/customHelp/index.html", "normal") |
|---|
| 1674 | else |
|---|
| 1675 | gotonetpage("http://www.farbflash.de/customHelp/index.html") |
|---|
| 1676 | end if |
|---|
| 1677 | end if |
|---|
| 1678 | return 0 |
|---|
| 1679 | end if |
|---|
| 1680 | pfad = pfade[n] |
|---|
| 1681 | end repeat |
|---|
| 1682 | |
|---|
| 1683 | -- check if the miaw is already open |
|---|
| 1684 | isOpen = 0 |
|---|
| 1685 | repeat with win in the windowlist |
|---|
| 1686 | if win.filename = pfad then |
|---|
| 1687 | isOpen = 1 |
|---|
| 1688 | exit repeat |
|---|
| 1689 | end if |
|---|
| 1690 | end repeat |
|---|
| 1691 | |
|---|
| 1692 | -- open it if necessary |
|---|
| 1693 | if not isOpen then |
|---|
| 1694 | win = window("help") |
|---|
| 1695 | if voidP(win) then win = window().new("help") |
|---|
| 1696 | win.filename = pfad |
|---|
| 1697 | end if |
|---|
| 1698 | |
|---|
| 1699 | return win |
|---|
| 1700 | |
|---|
| 1701 | end |
|---|
| 1702 | |
|---|
| 1703 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1704 | |
|---|
| 1705 | on mGetHelp me, theText |
|---|
| 1706 | |
|---|
| 1707 | win = mGetHelpWindowRef(me) |
|---|
| 1708 | if ilk(win) <> #window then exit |
|---|
| 1709 | |
|---|
| 1710 | open win |
|---|
| 1711 | |
|---|
| 1712 | -- tell the miaw to display the first matched substring |
|---|
| 1713 | tell win |
|---|
| 1714 | mLingoDict theText |
|---|
| 1715 | end tell |
|---|
| 1716 | |
|---|
| 1717 | return true |
|---|
| 1718 | end |
|---|
| 1719 | |
|---|
| 1720 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1721 | |
|---|
| 1722 | on makeHelpEntries me |
|---|
| 1723 | cl = the activecastlib |
|---|
| 1724 | sel = the selection of castlib cl |
|---|
| 1725 | anz = sel.count |
|---|
| 1726 | |
|---|
| 1727 | helpwindow = mGetHelpWindowRef(me) |
|---|
| 1728 | |
|---|
| 1729 | if ilk(helpwindow) <> #window then |
|---|
| 1730 | exit |
|---|
| 1731 | end if |
|---|
| 1732 | |
|---|
| 1733 | created = 0 |
|---|
| 1734 | |
|---|
| 1735 | if mCheckForXtra(me, "BudAPI") then |
|---|
| 1736 | theResult = baMsgBox("Create new index ?", "New index", "Yesno", "Question", 1) |
|---|
| 1737 | if theResult = "Yes" then |
|---|
| 1738 | theResult = baPrompt("Enter new title", "Enter new title", "New index", 0, -2, -2) |
|---|
| 1739 | if length(theResult) then |
|---|
| 1740 | tell helpwindow to mCreateIndexMember theResult |
|---|
| 1741 | end if |
|---|
| 1742 | end if |
|---|
| 1743 | end if |
|---|
| 1744 | |
|---|
| 1745 | repeat with n = 1 to anz |
|---|
| 1746 | repeat with m = sel[n][2] down to sel[n][1] |
|---|
| 1747 | memref = member(m, cl) |
|---|
| 1748 | if [#field, #text].getPos(memref.type) then |
|---|
| 1749 | dername = memref.name |
|---|
| 1750 | tell helpwindow to mCreateEntry dername, dername |
|---|
| 1751 | created = 1 |
|---|
| 1752 | end if |
|---|
| 1753 | end repeat |
|---|
| 1754 | end repeat |
|---|
| 1755 | |
|---|
| 1756 | |
|---|
| 1757 | if created = 0 then |
|---|
| 1758 | alert "Please select one or more text or field members to create help entries from" |
|---|
| 1759 | |
|---|
| 1760 | end if |
|---|
| 1761 | |
|---|
| 1762 | end |
|---|
| 1763 | |
|---|
| 1764 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1765 | -- parse a scripttext and create a help page for each handler |
|---|
| 1766 | |
|---|
| 1767 | on makeHelpFilesFromScript me, memref, onlyHandlerWithComments |
|---|
| 1768 | |
|---|
| 1769 | if ilk(memref) <> #member then |
|---|
| 1770 | |
|---|
| 1771 | cl = the activecastlib |
|---|
| 1772 | sel = the selection of castlib cl |
|---|
| 1773 | |
|---|
| 1774 | exitrepeat = 0 |
|---|
| 1775 | repeat with sub in sel |
|---|
| 1776 | repeat with mem = sub[1] to sub[2] |
|---|
| 1777 | memref = member(mem,cl) |
|---|
| 1778 | if memref.type = #script then |
|---|
| 1779 | exitrepeat = 1 |
|---|
| 1780 | exit repeat |
|---|
| 1781 | end if |
|---|
| 1782 | end repeat |
|---|
| 1783 | if exitrepeat = 1 then exit repeat |
|---|
| 1784 | end repeat |
|---|
| 1785 | |
|---|
| 1786 | end if |
|---|
| 1787 | |
|---|
| 1788 | |
|---|
| 1789 | if memref.type <> #script then |
|---|
| 1790 | alert "Select a scriptmember in order to create help pages for each handler" |
|---|
| 1791 | exit |
|---|
| 1792 | end if |
|---|
| 1793 | |
|---|
| 1794 | scrType = memref.scripttype |
|---|
| 1795 | scrText = memref.scripttext |
|---|
| 1796 | |
|---|
| 1797 | the itemdelimiter = "," |
|---|
| 1798 | str = RETURN&"on " |
|---|
| 1799 | offs = offset(str, scrText) |
|---|
| 1800 | repeat while offs |
|---|
| 1801 | |
|---|
| 1802 | ulList = [] |
|---|
| 1803 | blList = [] |
|---|
| 1804 | |
|---|
| 1805 | |
|---|
| 1806 | |
|---|
| 1807 | vor = scrText.char[1 .. offs] |
|---|
| 1808 | lc = vor.line.count |
|---|
| 1809 | km = "" |
|---|
| 1810 | repeat while lc > 0 |
|---|
| 1811 | if vor.line[lc].word.count > 0 then |
|---|
| 1812 | if word 1 of vor.line[lc] starts "--" then |
|---|
| 1813 | if not (vor.line[lc] starts "-- xxx") and not(vor.line[lc] starts "--xxx") then |
|---|
| 1814 | put vor.line[lc] & RETURN before km |
|---|
| 1815 | lc = lc - 1 |
|---|
| 1816 | else |
|---|
| 1817 | exit repeat |
|---|
| 1818 | end if |
|---|
| 1819 | else |
|---|
| 1820 | exit repeat |
|---|
| 1821 | end if |
|---|
| 1822 | else |
|---|
| 1823 | lc = lc - 1 |
|---|
| 1824 | end if |
|---|
| 1825 | end repeat |
|---|
| 1826 | if (length(km) > 0) then put return after km |
|---|
| 1827 | lc = vor.line.count + 1 |
|---|
| 1828 | hndline = scrText.line[lc] |
|---|
| 1829 | coffs = offset("--", hndline) |
|---|
| 1830 | if coffs > 0 then |
|---|
| 1831 | put hndline.char[coffs+2 .. length(hndline)] & RETURN after km |
|---|
| 1832 | end if |
|---|
| 1833 | lc = lc + 1 |
|---|
| 1834 | geslc = scrText.line.count |
|---|
| 1835 | repeat while lc < geslc |
|---|
| 1836 | if scrText.line[lc].word.count > 0 then |
|---|
| 1837 | if word 1 of scrText.line[lc] starts "--" then |
|---|
| 1838 | if not (scrText.line[lc] starts "-- xxx") and not(scrText.line[lc] starts "--xxx") then |
|---|
| 1839 | put RETURN & scrText.line[lc] after km |
|---|
| 1840 | lc = lc + 1 |
|---|
| 1841 | else |
|---|
| 1842 | exit repeat |
|---|
| 1843 | end if |
|---|
| 1844 | else |
|---|
| 1845 | exit repeat |
|---|
| 1846 | end if |
|---|
| 1847 | else |
|---|
| 1848 | lc = lc + 1 |
|---|
| 1849 | end if |
|---|
| 1850 | end repeat |
|---|
| 1851 | |
|---|
| 1852 | |
|---|
| 1853 | if onlyHandlerWithComments then doit = (length(km) > 0) |
|---|
| 1854 | else doit = 1 |
|---|
| 1855 | |
|---|
| 1856 | |
|---|
| 1857 | delete char 1 to offs + str.length - 1 of scrText |
|---|
| 1858 | handlername = scrText.word[1] |
|---|
| 1859 | parmc = (scrText.line[1].word.count > 1) |
|---|
| 1860 | delete word 1 of scrText |
|---|
| 1861 | |
|---|
| 1862 | |
|---|
| 1863 | if doit = 1 then |
|---|
| 1864 | |
|---|
| 1865 | neuertext = new(#text) |
|---|
| 1866 | neuertext.font = "Arial" |
|---|
| 1867 | neuertext.fontsize = 12 |
|---|
| 1868 | neuertext.fontstyle = [#plain] |
|---|
| 1869 | neuertext.alignment = #left |
|---|
| 1870 | neuertext.name = handlername |
|---|
| 1871 | |
|---|
| 1872 | end if |
|---|
| 1873 | |
|---|
| 1874 | argList = [] |
|---|
| 1875 | if parmc then |
|---|
| 1876 | offs2 = offset(RETURN, scrText) |
|---|
| 1877 | args = scrText.char[1 .. offs2] |
|---|
| 1878 | delete char 1 to offs2 of scrText |
|---|
| 1879 | |
|---|
| 1880 | anz = args.item.count |
|---|
| 1881 | repeat with n = 1 to anz |
|---|
| 1882 | if args.item[n].word[1] <> "me" then argList.add(args.item[n].word[1]) |
|---|
| 1883 | end repeat |
|---|
| 1884 | end if |
|---|
| 1885 | |
|---|
| 1886 | |
|---|
| 1887 | if doit = 1 then |
|---|
| 1888 | |
|---|
| 1889 | neuertext.text = RETURN&handlername&RETURN&RETURN&RETURN |
|---|
| 1890 | blList.add(1) |
|---|
| 1891 | |
|---|
| 1892 | neuertext.setContentsafter("Syntax: ") |
|---|
| 1893 | ulList.add(neuertext.text.word.count) |
|---|
| 1894 | |
|---|
| 1895 | if scrType = #score then |
|---|
| 1896 | neuertext.setContentsafter("sendSprite") |
|---|
| 1897 | neuertext.setContentsafter("(spritenumber, #"&handlername&", ") |
|---|
| 1898 | anz = argList.count |
|---|
| 1899 | repeat with n = 1 to anz |
|---|
| 1900 | neuertext.setContentsafter(argList[n]&", ") |
|---|
| 1901 | end repeat |
|---|
| 1902 | neuertext.char[neuertext.char.count].delete() |
|---|
| 1903 | neuertext.char[neuertext.char.count].delete() |
|---|
| 1904 | neuertext.setContentsafter(")"&RETURN&RETURN) |
|---|
| 1905 | |
|---|
| 1906 | else if scrType = #parent then |
|---|
| 1907 | neuertext.setContentsafter("call") |
|---|
| 1908 | neuertext.setContentsafter("(#"&handlername&", [scriptObject], ") |
|---|
| 1909 | anz = argList.count |
|---|
| 1910 | repeat with n = 1 to anz |
|---|
| 1911 | neuertext.setContentsafter(argList[n]&", ") |
|---|
| 1912 | end repeat |
|---|
| 1913 | neuertext.char[neuertext.char.count].delete() |
|---|
| 1914 | neuertext.char[neuertext.char.count].delete() |
|---|
| 1915 | neuertext.setContentsafter(")"&RETURN&RETURN) |
|---|
| 1916 | |
|---|
| 1917 | else |
|---|
| 1918 | neuertext.setContentsafter(handlername) |
|---|
| 1919 | neuertext.setContentsafter(" ") |
|---|
| 1920 | anz = argList.count |
|---|
| 1921 | repeat with n = 1 to anz |
|---|
| 1922 | neuertext.setContentsafter(argList[n]&", ") |
|---|
| 1923 | end repeat |
|---|
| 1924 | neuertext.char[neuertext.char.count].delete() |
|---|
| 1925 | if anz > 0 then neuertext.char[neuertext.char.count].delete() |
|---|
| 1926 | neuertext.setContentsafter(RETURN&RETURN) |
|---|
| 1927 | |
|---|
| 1928 | end if |
|---|
| 1929 | |
|---|
| 1930 | neuertext.setContentsafter("Arguments: ") |
|---|
| 1931 | ulList.add(neuertext.text.word.count) |
|---|
| 1932 | neuertext.setContentsafter(RETURN) |
|---|
| 1933 | neuertext.setContentsafter(RETURN) |
|---|
| 1934 | anz = argList.count |
|---|
| 1935 | if anz > 0 then |
|---|
| 1936 | repeat with n = 1 to anz |
|---|
| 1937 | neuertext.setContentsafter(" - "&argList[n]&" <type> "&RETURN&RETURN) |
|---|
| 1938 | end repeat |
|---|
| 1939 | else |
|---|
| 1940 | neuertext.setContentsafter("-- none --"&RETURN) |
|---|
| 1941 | end if |
|---|
| 1942 | |
|---|
| 1943 | neuertext.setContentsafter(RETURN) |
|---|
| 1944 | |
|---|
| 1945 | neuertext.setContentsafter("Returns: ") |
|---|
| 1946 | ulList.add(neuertext.text.word.count) |
|---|
| 1947 | neuertext.setContentsafter(RETURN) |
|---|
| 1948 | neuertext.setContentsafter(RETURN) |
|---|
| 1949 | neuertext.setContentsafter(RETURN) |
|---|
| 1950 | |
|---|
| 1951 | neuertext.setContentsafter("Description: ") |
|---|
| 1952 | ulList.add(neuertext.text.word.count) |
|---|
| 1953 | neuertext.setContentsafter(RETURN) |
|---|
| 1954 | if length(km) > 0 then neuertext.setContentsafter(km) |
|---|
| 1955 | else neuertext.setContentsafter(RETURN) |
|---|
| 1956 | neuertext.setContentsafter(RETURN) |
|---|
| 1957 | |
|---|
| 1958 | neuertext.setContentsafter("Example: ") |
|---|
| 1959 | ulList.add(neuertext.text.word.count) |
|---|
| 1960 | neuertext.setContentsafter(RETURN) |
|---|
| 1961 | neuertext.setContentsafter(RETURN) |
|---|
| 1962 | |
|---|
| 1963 | anz = blList.count |
|---|
| 1964 | repeat with n = 1 to anz |
|---|
| 1965 | neuertext.word[blList[n]].fontstyle = [#bold] |
|---|
| 1966 | neuertext.word[blList[n]].fontsize = neuertext.word[blList[n]].fontsize + 2 |
|---|
| 1967 | end repeat |
|---|
| 1968 | |
|---|
| 1969 | anz = ulList.count |
|---|
| 1970 | repeat with n = 1 to anz |
|---|
| 1971 | neuertext.word[ulList[n]].fontstyle = [#bold, #underline] |
|---|
| 1972 | end repeat |
|---|
| 1973 | |
|---|
| 1974 | end if |
|---|
| 1975 | |
|---|
| 1976 | |
|---|
| 1977 | offs = offset(str, scrText) |
|---|
| 1978 | end repeat |
|---|
| 1979 | |
|---|
| 1980 | end |
|---|
| 1981 | |
|---|
| 1982 | -- CASTLABELS |
|---|
| 1983 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1984 | -- xxxxxxxxxxxxxxxxxx mein labeler |
|---|
| 1985 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 1986 | |
|---|
| 1987 | on ______________CAST_LABELS me |
|---|
| 1988 | end |
|---|
| 1989 | |
|---|
| 1990 | -- my colors: |
|---|
| 1991 | -- -- red = common scripts = rgb(180, 0, 0) |
|---|
| 1992 | -- -- green = normal independant behaviors = rgb(0, 100, 100) |
|---|
| 1993 | -- -- blue = dependant behaviors (-> Manager) = rgb(0, 50, 100) |
|---|
| 1994 | |
|---|
| 1995 | on makeLabel me, theContent, theBackgroundColor, memberRef |
|---|
| 1996 | ------------ |
|---|
| 1997 | -- REQUIRED PARAMETERS: |
|---|
| 1998 | -- -- <theContent> -> format: #string, #image, #bitmap, #text, #flash, #vectorshape |
|---|
| 1999 | |
|---|
| 2000 | -- NOT REQUIRED PARAMETERS: |
|---|
| 2001 | -- -- <theBackgroundColor> -> format: #color; default, if not specified: rgb(0,0,0) |
|---|
| 2002 | -- -- <memberRef> -> format: #member; reference to the member you want to change the thumbnail; default, if not specified: the first selected member |
|---|
| 2003 | ------------ |
|---|
| 2004 | |
|---|
| 2005 | ------------ |
|---|
| 2006 | -- EXAMPLES: |
|---|
| 2007 | |
|---|
| 2008 | -- makeLabel "Nifty Label" -- draws a the string "Nifty Label" on black background for the current selected member |
|---|
| 2009 | -- makeLabel "Red Label", rgb(255, 0, 0) -- draws a the string "Red Label" on red background for the current selected member |
|---|
| 2010 | -- makeLabel "Blue Label on Member 5", rgb(0, 0, 255), member(5,1) -- draws a the string "Blue Label on Member 5" on blue background for member 5 of castlib 1 |
|---|
| 2011 | -- makeLabel member("myBitmap").image -- draws the image of member "myBitmap" on black background for the current selected member |
|---|
| 2012 | -- makeLabel member("myBitmap") -- draws the image of member "myBitmap" on black background for the current selected member (thge same as above) |
|---|
| 2013 | -- ... |
|---|
| 2014 | -- -- you get the picture... |
|---|
| 2015 | ------------ |
|---|
| 2016 | |
|---|
| 2017 | contentIlk = ilk(theContent) |
|---|
| 2018 | if contentIlk = void then exit |
|---|
| 2019 | |
|---|
| 2020 | |
|---|
| 2021 | ------------ |
|---|
| 2022 | -- -- unfortunately I don't know how to get the thumbnail setting for the cast window... |
|---|
| 2023 | -- -- so you must comment the line out, which fit your preferred setting of the thumbnail size here: |
|---|
| 2024 | ------------ |
|---|
| 2025 | -- thumbRect = rect(0, 0, 43, 32) -- for thumbnail size #small |
|---|
| 2026 | thumbRect = rect(0, 0, 55, 41) -- for thumbnail size #medium |
|---|
| 2027 | -- thumbRect = rect(0, 0, 79, 59) -- for thumbnail size #large |
|---|
| 2028 | |
|---|
| 2029 | |
|---|
| 2030 | ------------ |
|---|
| 2031 | -- -- if memberRef is #empty, we create a bitmap in its place to act as a 'castlib label' |
|---|
| 2032 | -- -- in this case the name of this member is preceeded by two underscores, so that it can be deleted later easily |
|---|
| 2033 | -- -- and it acts as 'kind of header' in the list view of the castlib, when it is sorted by number |
|---|
| 2034 | ------------ |
|---|
| 2035 | makeTemp = 1 |
|---|
| 2036 | if ilk(memberRef) = #member then |
|---|
| 2037 | |
|---|
| 2038 | -- ullala changed for woody - mb -- |
|---|
| 2039 | if voidP(memberRef) then makeTemp = 0 |
|---|
| 2040 | else if memberRef.type = #empty then makeTemp = 0 |
|---|
| 2041 | -- ullala changed for woody - mb end -- |
|---|
| 2042 | |
|---|
| 2043 | else -- get the first selected member |
|---|
| 2044 | |
|---|
| 2045 | activeCL = the activeCastLib |
|---|
| 2046 | memberRef = member(castLib(activeCL).selection[1][1], activeCL) |
|---|
| 2047 | if ilk(memberRef) <> #member then exit -- no member selected |
|---|
| 2048 | |
|---|
| 2049 | -- ullala changed for woody - mb -- |
|---|
| 2050 | if voidP(memberRef) then makeTemp = 0 |
|---|
| 2051 | else if memberRef.type = #empty then makeTemp = 0 |
|---|
| 2052 | else if memberRef.type = #text then |
|---|
| 2053 | alert "Text members can not have custom thumbnails" |
|---|
| 2054 | exit |
|---|
| 2055 | end if |
|---|
| 2056 | -- ullala changed for woody - mb end -- |
|---|
| 2057 | |
|---|
| 2058 | end if |
|---|
| 2059 | |
|---|
| 2060 | if makeTemp then |
|---|
| 2061 | tempMember = new(#bitmap) |
|---|
| 2062 | else |
|---|
| 2063 | tempMember = new(#bitmap, memberRef) |
|---|
| 2064 | |
|---|
| 2065 | case contentIlk of |
|---|
| 2066 | #string: |
|---|
| 2067 | tempMember.name = "__"&theContent&"_Castlabel" |
|---|
| 2068 | #member: |
|---|
| 2069 | tempMember.name = "__"&theContent.name&"_Castlabel" |
|---|
| 2070 | #image: |
|---|
| 2071 | tempMember.name = "__Icon_Castlabel" |
|---|
| 2072 | end case |
|---|
| 2073 | end if |
|---|
| 2074 | |
|---|
| 2075 | tempMember.trimwhitespace = true |
|---|
| 2076 | |
|---|
| 2077 | if ilk(theBackgroundColor) = #string or ilk(theBackgroundColor) = #symbol then |
|---|
| 2078 | theBackgroundColor = string(theBackgroundColor) |
|---|
| 2079 | case theBackgroundColor of |
|---|
| 2080 | "rot", "red": theBackgroundColor = rgb(180, 0, 0) |
|---|
| 2081 | "gruen", "green": theBackgroundColor = rgb(0, 100, 100) |
|---|
| 2082 | "gray", "grey", "grau": theBackgroundColor = rgb(80, 80, 80) |
|---|
| 2083 | "blau", "blue": theBackgroundColor = rgb(0, 50, 100) |
|---|
| 2084 | "hellblau", "lightblue": theBackgroundColor = rgb(0,100,180) |
|---|
| 2085 | end case |
|---|
| 2086 | end if |
|---|
| 2087 | |
|---|
| 2088 | |
|---|
| 2089 | if ilk(theBackgroundColor) <> #color then theBackgroundColor = rgb(0, 0, 0) -- default is black |
|---|
| 2090 | if contentIlk = #string then theDepth = 8 - ((theBackgroundColor = rgb(0, 0, 0)) * 7) -- if black, then 1 - bit, else 8-bit |
|---|
| 2091 | else if contentIlk = #image then theDepth = theContent.depth |
|---|
| 2092 | else theDepth = 16 |
|---|
| 2093 | tImage = image(thumbRect.width, thumbRect.height, theDepth) |
|---|
| 2094 | |
|---|
| 2095 | tImage.fill(thumbRect, theBackgroundColor) |
|---|
| 2096 | |
|---|
| 2097 | ------------ |
|---|
| 2098 | -- -- specify the margin, you like here: |
|---|
| 2099 | ------------ |
|---|
| 2100 | theMargin = point(2, 0) |
|---|
| 2101 | |
|---|
| 2102 | targetRect = thumbRect.inflate((theMargin[1] * -1), (theMargin[2] * -1)) |
|---|
| 2103 | |
|---|
| 2104 | case contentIlk of |
|---|
| 2105 | #string: |
|---|
| 2106 | tempTextmember = new(#text) |
|---|
| 2107 | tempTextmember.text = theContent |
|---|
| 2108 | tempTextmember.width = thumbRect.width - (theMargin[1] * 2) |
|---|
| 2109 | |
|---|
| 2110 | ------------ |
|---|
| 2111 | -- -- text parameters: |
|---|
| 2112 | ------------ |
|---|
| 2113 | tempTextmember.color = rgb(255, 255, 255) |
|---|
| 2114 | tempTextmember.font = "Geneva" |
|---|
| 2115 | tempTextmember.fontsize = 9 |
|---|
| 2116 | -- tempTextmember.alignment = #center |
|---|
| 2117 | |
|---|
| 2118 | if the optionDown or the controldown or the shiftdown or the commanddown then |
|---|
| 2119 | tempTextmember.fontStyle = [#bold] |
|---|
| 2120 | else |
|---|
| 2121 | tempTextmember.fontStyle = [#plain] |
|---|
| 2122 | end if |
|---|
| 2123 | -- --/ text parameters |
|---|
| 2124 | ------------ |
|---|
| 2125 | |
|---|
| 2126 | theContent = tempTextmember.image.duplicate() |
|---|
| 2127 | |
|---|
| 2128 | tempTextmember.erase() |
|---|
| 2129 | |
|---|
| 2130 | targetRect = theContent.rect.offset(theMargin[1], theMargin[2]) |
|---|
| 2131 | |
|---|
| 2132 | #member: |
|---|
| 2133 | if [#bitmap, #text, #flash, #vectorshape].getPos(theContent.type) > 0 then |
|---|
| 2134 | theContent = theContent.image.duplicate() |
|---|
| 2135 | theContent = theContent.trimwhitespace() |
|---|
| 2136 | |
|---|
| 2137 | diff = targetrect.width - theContent.width |
|---|
| 2138 | if (diff > 0) then targetrect = targetrect - rect(0, 0, diff, 0) |
|---|
| 2139 | diff = targetrect.height - theContent.height |
|---|
| 2140 | if (diff > 0) then targetrect = targetrect - rect(0, 0, 0, diff) |
|---|
| 2141 | |
|---|
| 2142 | else |
|---|
| 2143 | exit -- not a member with an image property |
|---|
| 2144 | end if |
|---|
| 2145 | |
|---|
| 2146 | #image: |
|---|
| 2147 | |
|---|
| 2148 | diff = targetrect.width - theContent.width |
|---|
| 2149 | if (diff > 0) then targetrect = targetrect - rect(0, 0, diff, 0) |
|---|
| 2150 | diff = targetrect.height - theContent.height |
|---|
| 2151 | if (diff > 0) then targetrect = targetrect - rect(0, 0, 0, diff) |
|---|
| 2152 | |
|---|
| 2153 | end case |
|---|
| 2154 | |
|---|
| 2155 | ------------ |
|---|
| 2156 | -- -- center: |
|---|
| 2157 | ------------ |
|---|
| 2158 | -- targetrect = targetrect.offset(((thumbRect.width - targetrect.width) / 2), ((thumbRect.height - targetrect.height) / 2)) |
|---|
| 2159 | |
|---|
| 2160 | tImage.copyPixels(theContent, targetRect, theContent.rect) |
|---|
| 2161 | tempMember.image = tImage.trimwhitespace() |
|---|
| 2162 | |
|---|
| 2163 | ------------ |
|---|
| 2164 | -- -- 1 pixel red border: |
|---|
| 2165 | ------------ |
|---|
| 2166 | -- tempMember.image.draw(tempMember.image.rect, [#shapetype:#rect, #linesize:1, #color:rgb(255,0,0)]) |
|---|
| 2167 | |
|---|
| 2168 | memberRef.thumbnail = tempMember.picture |
|---|
| 2169 | |
|---|
| 2170 | if makeTemp then tempMember.erase() |
|---|
| 2171 | |
|---|
| 2172 | end |
|---|
| 2173 | |
|---|
| 2174 | |
|---|
| 2175 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2176 | |
|---|
| 2177 | -- TEXT BITMAPS |
|---|
| 2178 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2179 | -- xxxxxxxxxxxxxxxxxx Textmember zu Images mit Masken konvertieren |
|---|
| 2180 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2181 | on ______________CONVERT_TEXT_INTO_IMAGE_WITH_MASK me |
|---|
| 2182 | end |
|---|
| 2183 | |
|---|
| 2184 | on mConvertToBitmap me -- bitmap + Maske aus selected textmembern machen |
|---|
| 2185 | cl = the activecastlib |
|---|
| 2186 | sel = the selection of castlib cl |
|---|
| 2187 | repeat with sub in sel |
|---|
| 2188 | repeat with mem = sub[1] to sub[2] |
|---|
| 2189 | textmemref = member(mem,cl) |
|---|
| 2190 | if textmemref.type = #text then |
|---|
| 2191 | memname = textmemref.name |
|---|
| 2192 | newName = memname&"BM" |
|---|
| 2193 | neuerMem = makeBMs(me, textmemref, newName) |
|---|
| 2194 | end if |
|---|
| 2195 | end repeat |
|---|
| 2196 | end repeat |
|---|
| 2197 | end |
|---|
| 2198 | |
|---|
| 2199 | -- xxxxxxxxxxxxx bitmap + Maske aus einem textmember machen |
|---|
| 2200 | |
|---|
| 2201 | on makeBMs me, textmemref, newName -- macht anhand von member(<textmemref>) zwei member: text als bitmap und maske |
|---|
| 2202 | |
|---|
| 2203 | |
|---|
| 2204 | dertyp = #empty |
|---|
| 2205 | if not(voidP(textmemref)) then dertyp = textmemref.type |
|---|
| 2206 | |
|---|
| 2207 | newMem = 0 |
|---|
| 2208 | case dertyp of |
|---|
| 2209 | #text, #field: |
|---|
| 2210 | clname = textmemref.castlibnum |
|---|
| 2211 | |
|---|
| 2212 | newMem = new(#bitmap, castlib clname) |
|---|
| 2213 | if dertyp = #field then |
|---|
| 2214 | newimgMask = new(#bitmap, castlib clname) |
|---|
| 2215 | newimgMask.picture = textmemref.picture |
|---|
| 2216 | img = image(newimgMask.width, newimgMask.height, 8, 0, #grayscale) |
|---|
| 2217 | img.copyPixels(newimgMask.image, img.rect, newimgMask.rect) |
|---|
| 2218 | newimgMask.image = img |
|---|
| 2219 | else |
|---|
| 2220 | maske = textmemref.image.extractAlpha() |
|---|
| 2221 | newimgMask = new(#bitmap, castlib clname) |
|---|
| 2222 | newimgMask.image = maske.trimwhitespace() |
|---|
| 2223 | end if |
|---|
| 2224 | |
|---|
| 2225 | newMem.name = newName |
|---|
| 2226 | newimgMask.name = newName&"Mask" |
|---|
| 2227 | |
|---|
| 2228 | newimgMask.trimWhiteSpace = 1 |
|---|
| 2229 | |
|---|
| 2230 | -- das andere schwarz fuellen |
|---|
| 2231 | bild = image(newimgMask.width, newimgMask.height, 1, 0) |
|---|
| 2232 | bild.fill(bild.rect, rgb(0,0,0)) |
|---|
| 2233 | newMem.image = bild |
|---|
| 2234 | |
|---|
| 2235 | newMem.regpoint = point(0,0) |
|---|
| 2236 | newimgMask.regpoint = point(0,0) |
|---|
| 2237 | end case |
|---|
| 2238 | return newMem |
|---|
| 2239 | end |
|---|
| 2240 | |
|---|
| 2241 | |
|---|
| 2242 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2243 | on _______________LINKED_TEXT me |
|---|
| 2244 | end |
|---|
| 2245 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2246 | |
|---|
| 2247 | |
|---|
| 2248 | |
|---|
| 2249 | on mLinkSelectedText me |
|---|
| 2250 | |
|---|
| 2251 | -- get the member or create a new one if necessary |
|---|
| 2252 | -- if a #text or #field member is selected in the cast |
|---|
| 2253 | -- it gets replaced otherwise a new member in castlib 1 is created |
|---|
| 2254 | cl = the activecastlib |
|---|
| 2255 | memref = member(castlib(cl).selection[1][1], cl) |
|---|
| 2256 | if memref.type = #empty then memref = new(#text, memref) |
|---|
| 2257 | if [#text, #field].getPos(memref.type) < 1 then memref = new(#text) |
|---|
| 2258 | |
|---|
| 2259 | -- display file open dialog to select the text file: |
|---|
| 2260 | fio = new(xtra "fileio") |
|---|
| 2261 | if objectP(fio) then |
|---|
| 2262 | pfad = fio.displayOpen() |
|---|
| 2263 | if not(pfad.length) then exit |
|---|
| 2264 | |
|---|
| 2265 | -- open and read the file: |
|---|
| 2266 | fio.openFile(pfad, 1) |
|---|
| 2267 | if not(fio.status()) then |
|---|
| 2268 | dertext = fio.readfile() |
|---|
| 2269 | if not(fio.status()) then |
|---|
| 2270 | if dertext.length then |
|---|
| 2271 | |
|---|
| 2272 | -- get the filename and file extension |
|---|
| 2273 | mp = the moviepath |
|---|
| 2274 | delim = the last char of mp |
|---|
| 2275 | -- od = the itemdelimiter |
|---|
| 2276 | -- the itemdelimiter = delim |
|---|
| 2277 | -- fname = the last item of pfad |
|---|
| 2278 | -- the itemdelimiter = od |
|---|
| 2279 | -- len = fname.length |
|---|
| 2280 | -- if fname.char[len - 3] = "." then |
|---|
| 2281 | -- fnameW = fname.char[1 .. len - 4] |
|---|
| 2282 | -- ext = fname.char[len - 2 .. len] |
|---|
| 2283 | -- else if fname.char[len - 4] = "." then |
|---|
| 2284 | -- fnameW = fname.char[1 .. len - 5] |
|---|
| 2285 | -- ext = fname.char[len - 3 .. len] |
|---|
| 2286 | -- else |
|---|
| 2287 | -- fnameW = fname |
|---|
| 2288 | -- ext = "" |
|---|
| 2289 | -- end if |
|---|
| 2290 | splitpath = mSplitPath(me, pfad) |
|---|
| 2291 | fnameW = splitpath[#basename] |
|---|
| 2292 | ext = splitpath[#extension] |
|---|
| 2293 | fname = fnameW & ext |
|---|
| 2294 | if length(ext) > 0 then delete char 1 of ext |
|---|
| 2295 | |
|---|
| 2296 | -- in case of field we always use the plain text: |
|---|
| 2297 | if memref.type = #field then ext = "" |
|---|
| 2298 | |
|---|
| 2299 | -- write the file contents into the member |
|---|
| 2300 | if ext starts "rtf" then |
|---|
| 2301 | memref.rtf = dertext |
|---|
| 2302 | else if ext starts "htm" then |
|---|
| 2303 | memref.html = dertext |
|---|
| 2304 | else |
|---|
| 2305 | memref.text = dertext |
|---|
| 2306 | end if |
|---|
| 2307 | |
|---|
| 2308 | -- change the path to a relative path |
|---|
| 2309 | -- for files which are inside the movies path hierarchie |
|---|
| 2310 | offs = offset(mp, pfad) |
|---|
| 2311 | if offs = 1 then |
|---|
| 2312 | delete char 1 to mp.length of pfad |
|---|
| 2313 | put "@" & delim before pfad |
|---|
| 2314 | end if |
|---|
| 2315 | |
|---|
| 2316 | -- name the new member, if not already. |
|---|
| 2317 | if memref.name = "" then memref.name = fnameW |
|---|
| 2318 | |
|---|
| 2319 | -- get the modification date of the file as number: |
|---|
| 2320 | moddate = 0 |
|---|
| 2321 | if mCheckXtra(me, "BudAPI") then |
|---|
| 2322 | moddate = baFileAge(baShortFileName(pfad)) |
|---|
| 2323 | else if mCheckXtra(me, "FileXtra4") then |
|---|
| 2324 | fx = new(xtra "filextra4") |
|---|
| 2325 | if objectP(fx) then moddate = fx.fx_FileGetModNumber(pfad) |
|---|
| 2326 | fx = 0 |
|---|
| 2327 | end if |
|---|
| 2328 | |
|---|
| 2329 | -- write the info into the members comment field: |
|---|
| 2330 | comm = "LinkedTextMember" & RETURN |
|---|
| 2331 | put pfad & RETURN after comm |
|---|
| 2332 | put moddate & RETURN after comm |
|---|
| 2333 | put ext after comm |
|---|
| 2334 | memref.comments = comm |
|---|
| 2335 | |
|---|
| 2336 | else |
|---|
| 2337 | put "Handler: mLinkSelectedText" |
|---|
| 2338 | put " -- File "&pfad&" is empty" |
|---|
| 2339 | end if |
|---|
| 2340 | else |
|---|
| 2341 | put "Handler: mLinkSelectedText" |
|---|
| 2342 | put " -- Couldn't read file "&pfad |
|---|
| 2343 | end if |
|---|
| 2344 | fio.closeFile() |
|---|
| 2345 | else |
|---|
| 2346 | put "Handler: mLinkSelectedText" |
|---|
| 2347 | put " -- Couldn't open file "&pfad&" to read" |
|---|
| 2348 | end if |
|---|
| 2349 | put "Handler: mLinkSelectedText" |
|---|
| 2350 | put " -- FileIO xtra missing" |
|---|
| 2351 | end if |
|---|
| 2352 | |
|---|
| 2353 | fio = 0 |
|---|
| 2354 | end |
|---|
| 2355 | |
|---|
| 2356 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2357 | |
|---|
| 2358 | on mUpdateAllLinkedTexts me |
|---|
| 2359 | |
|---|
| 2360 | -- create xtra object outside the repeat loop only once |
|---|
| 2361 | if mCheckXtra(me, "BudAPI") then |
|---|
| 2362 | fx = "bapi" |
|---|
| 2363 | else if mCheckXtra(me, "FileXtra4") then |
|---|
| 2364 | fx = new(xtra "filextra4") |
|---|
| 2365 | else |
|---|
| 2366 | fx = 0 |
|---|
| 2367 | end if |
|---|
| 2368 | |
|---|
| 2369 | fio = new(xtra "fileio") |
|---|
| 2370 | |
|---|
| 2371 | if not objectP(fio) then |
|---|
| 2372 | put "Handler: mUpdateAllLinkedTexts; FileIO xtra missing" |
|---|
| 2373 | exit |
|---|
| 2374 | end if |
|---|
| 2375 | |
|---|
| 2376 | statusSwitched = mSwitchToStatusMode(me, 1) |
|---|
| 2377 | |
|---|
| 2378 | -- loop through all castlibs: |
|---|
| 2379 | numCl = the number of castlibs |
|---|
| 2380 | repeat with m = 1 to numCl |
|---|
| 2381 | |
|---|
| 2382 | -- loop through all members: |
|---|
| 2383 | numMem = the number of members of castlib m |
|---|
| 2384 | repeat with n = 1 to numMem |
|---|
| 2385 | |
|---|
| 2386 | -- check for #text or #field with the matching member.comments |
|---|
| 2387 | memref = member(n, m) |
|---|
| 2388 | if [#text, #field].getPos(memref.type) > 0 then |
|---|
| 2389 | comm = memref.comments |
|---|
| 2390 | if comm.line.count > 3 then |
|---|
| 2391 | if comm.line[1] = "LinkedTextMember" then |
|---|
| 2392 | |
|---|
| 2393 | pfad = comm.line[2] |
|---|
| 2394 | moddate = float(comm.line[3]) |
|---|
| 2395 | ext = comm.line[4] |
|---|
| 2396 | if not floatP(moddate) then moddate = 0.0 |
|---|
| 2397 | |
|---|
| 2398 | -- compare the modification date |
|---|
| 2399 | if objectP(fx) then |
|---|
| 2400 | newModdate = fx.fx_FileGetModNumber(pfad) |
|---|
| 2401 | upd = (newModdate > moddate) |
|---|
| 2402 | else if fx = "bapi" then |
|---|
| 2403 | newModdate = baFileAge(baShortFileName(pfad)) |
|---|
| 2404 | upd = (newModdate > moddate) |
|---|
| 2405 | else |
|---|
| 2406 | newModdate = 0 |
|---|
| 2407 | upd = 1 |
|---|
| 2408 | end if |
|---|
| 2409 | |
|---|
| 2410 | -- if the file is newqer then update |
|---|
| 2411 | if upd then |
|---|
| 2412 | fio.openFile(pfad, 1) |
|---|
| 2413 | if not(fio.status()) then |
|---|
| 2414 | dertext = fio.readfile() |
|---|
| 2415 | if not(fio.status()) then |
|---|
| 2416 | if ext starts "rtf" then |
|---|
| 2417 | memref.rtf = dertext |
|---|
| 2418 | else if ext starts "htm" then |
|---|
| 2419 | memref.html = dertext |
|---|
| 2420 | else |
|---|
| 2421 | memref.text = dertext |
|---|
| 2422 | end if |
|---|
| 2423 | |
|---|
| 2424 | -- update the member.comments |
|---|
| 2425 | put newModdate into line 3 of comm |
|---|
| 2426 | memref.comments = comm |
|---|
| 2427 | |
|---|
| 2428 | -- put results: |
|---|
| 2429 | put "Updated file"&&pfad |
|---|
| 2430 | |
|---|
| 2431 | else |
|---|
| 2432 | put "Handler: mUpdateAllLinkedTexts" |
|---|
| 2433 | put " -- Couldn't read file "&pfad |
|---|
| 2434 | end if |
|---|
| 2435 | else |
|---|
| 2436 | put "Handler: mUpdateAllLinkedTexts" |
|---|
| 2437 | put " -- Couldn't open file "&pfad&" to read" |
|---|
| 2438 | end if |
|---|
| 2439 | end if |
|---|
| 2440 | end if |
|---|
| 2441 | end if |
|---|
| 2442 | end if |
|---|
| 2443 | end repeat |
|---|
| 2444 | end repeat |
|---|
| 2445 | |
|---|
| 2446 | -- dispose xtra objects: |
|---|
| 2447 | fx = 0 |
|---|
| 2448 | fio = 0 |
|---|
| 2449 | |
|---|
| 2450 | if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0) |
|---|
| 2451 | |
|---|
| 2452 | end |
|---|
| 2453 | |
|---|
| 2454 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2455 | |
|---|
| 2456 | -- check for available scripting xtra: |
|---|
| 2457 | on mCheckXtra me, which |
|---|
| 2458 | repeat with n = the number of xtras down to 1 |
|---|
| 2459 | if (the name of xtra n = which) then return 1 |
|---|
| 2460 | end repeat |
|---|
| 2461 | return 0 |
|---|
| 2462 | end |
|---|
| 2463 | |
|---|
| 2464 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2465 | |
|---|
| 2466 | on mExportScripttext me, skipIcons, convertLineBreaksToUnix, theFolder |
|---|
| 2467 | |
|---|
| 2468 | |
|---|
| 2469 | theFolder = string(theFolder) |
|---|
| 2470 | if length(theFolder) < 1 then theFolder = mGetFolderPathFromUser(me) |
|---|
| 2471 | if length(theFolder) < 1 then exit |
|---|
| 2472 | |
|---|
| 2473 | if the last char of theFolder <> the last char of the moviepath then put the last char of the moviepath after theFolder |
|---|
| 2474 | |
|---|
| 2475 | |
|---|
| 2476 | cl = the activecastlib |
|---|
| 2477 | sel = the selection of castlib cl |
|---|
| 2478 | firstCastNum = cl |
|---|
| 2479 | lastCastNum = cl |
|---|
| 2480 | |
|---|
| 2481 | |
|---|
| 2482 | DirectImageInstance = 0 |
|---|
| 2483 | if skipIcons <> 1 then |
|---|
| 2484 | if mCheckForXtra(me, "SharpExport") = 1 then |
|---|
| 2485 | SharpExportInst = new(xtra "SharpExport") |
|---|
| 2486 | else |
|---|
| 2487 | skipIcons = 1 |
|---|
| 2488 | end if |
|---|
| 2489 | end if |
|---|
| 2490 | |
|---|
| 2491 | |
|---|
| 2492 | isMac = (the platform contains "mac") -- we need the differentiation because of the dreaded 31 char limit |
|---|
| 2493 | |
|---|
| 2494 | ----------------------- |
|---|
| 2495 | resetUNames = 0 |
|---|
| 2496 | if isMac then |
|---|
| 2497 | if baSysFolder("prefs") starts "/" then |
|---|
| 2498 | baReturnUnixNames(0) |
|---|
| 2499 | resetUNames = 1 |
|---|
| 2500 | end if |
|---|
| 2501 | end if |
|---|
| 2502 | ----------------------- |
|---|
| 2503 | |
|---|
| 2504 | doit = 0 |
|---|
| 2505 | versionNum = mGetFloatVersionNumber(me, the productversion) |
|---|
| 2506 | |
|---|
| 2507 | repeat with m = firstCastNum to lastCastNum |
|---|
| 2508 | |
|---|
| 2509 | listOfAllFiles = [] |
|---|
| 2510 | |
|---|
| 2511 | thisFolder = theFolder |
|---|
| 2512 | |
|---|
| 2513 | doit = 0 |
|---|
| 2514 | |
|---|
| 2515 | sel = the selection of castlib m |
|---|
| 2516 | |
|---|
| 2517 | repeat with sub in sel |
|---|
| 2518 | repeat with n = sub[1] to sub[2] |
|---|
| 2519 | |
|---|
| 2520 | memref = member(n, m) |
|---|
| 2521 | memtype = memref.type |
|---|
| 2522 | |
|---|
| 2523 | convertLineBreaksToUnixT = 0 |
|---|
| 2524 | |
|---|
| 2525 | if [#script, #field, #text].getPos(memtype) > 0 then |
|---|
| 2526 | |
|---|
| 2527 | case memtype of |
|---|
| 2528 | |
|---|
| 2529 | ----------------------- |
|---|
| 2530 | #script: |
|---|
| 2531 | ext = ".ls" |
|---|
| 2532 | scrText = memref.scripttext |
|---|
| 2533 | scrtype = memref.scripttype |
|---|
| 2534 | |
|---|
| 2535 | ------------------------------ meta data |
|---|
| 2536 | infolist = [:] |
|---|
| 2537 | infolist[#name] = memref.name |
|---|
| 2538 | infolist[#scripttype] = memref.scripttype |
|---|
| 2539 | if versionNum >= 10 then infolist[#scriptSyntax] = memref.scriptSyntax |
|---|
| 2540 | comm = memref.comments |
|---|
| 2541 | offs = offset(RETURN, comm) |
|---|
| 2542 | repeat while offs |
|---|
| 2543 | put QUOTE & " & RETURN & " & QUOTE into char offs of comm |
|---|
| 2544 | end repeat |
|---|
| 2545 | infolist[#comments] = comm |
|---|
| 2546 | |
|---|
| 2547 | offs2 = 0 |
|---|
| 2548 | export_meta_data = scrText&"" |
|---|
| 2549 | offs = offset("--!memberProperties:", export_meta_data) |
|---|
| 2550 | if offs > 0 then |
|---|
| 2551 | delete char 1 to offs of export_meta_data |
|---|
| 2552 | offs2 = offset("]", export_meta_data) |
|---|
| 2553 | end if |
|---|
| 2554 | |
|---|
| 2555 | if offs2 > 0 then |
|---|
| 2556 | put "--!memberProperties:" && infolist into char offs to offs + offs2 of scrText |
|---|
| 2557 | else |
|---|
| 2558 | put "--!memberProperties:" && infolist & RETURN before scrText |
|---|
| 2559 | end if |
|---|
| 2560 | |
|---|
| 2561 | ------------------------------ |
|---|
| 2562 | |
|---|
| 2563 | ----------------------- |
|---|
| 2564 | #field: |
|---|
| 2565 | ext = ".txt" |
|---|
| 2566 | scrText = memref.text |
|---|
| 2567 | scrtype = #field |
|---|
| 2568 | ----------------------- |
|---|
| 2569 | #text: |
|---|
| 2570 | ext = ".html" |
|---|
| 2571 | scrText = memref.html |
|---|
| 2572 | convertLineBreaksToUnixT = 0 |
|---|
| 2573 | scrtype = #text |
|---|
| 2574 | ----------------------- |
|---|
| 2575 | otherwise: |
|---|
| 2576 | ext = ".txt" |
|---|
| 2577 | scrText = memref.text |
|---|
| 2578 | scrtype = #field |
|---|
| 2579 | end case |
|---|
| 2580 | |
|---|
| 2581 | memname = memref.name |
|---|
| 2582 | |
|---|
| 2583 | theDefaultName = memname |
|---|
| 2584 | |
|---|
| 2585 | doit = 1 |
|---|
| 2586 | |
|---|
| 2587 | if length(theDefaultName) < 1 then |
|---|
| 2588 | theDefaultName = "member" & n & "_" & m |
|---|
| 2589 | memref.name = theDefaultName |
|---|
| 2590 | put "renamed member" && memref && "to member(" & QUOTE & theDefaultName & QUOTE & ") as member without names are not supported" |
|---|
| 2591 | end if |
|---|
| 2592 | |
|---|
| 2593 | theDefaultName = mStripFunnyCharsFromFileName(me, theDefaultName) |
|---|
| 2594 | |
|---|
| 2595 | origname = theDefaultName&"" |
|---|
| 2596 | if length(theDefaultName) > 25 and isMac then |
|---|
| 2597 | |
|---|
| 2598 | ms = string(the milliseconds) |
|---|
| 2599 | mlen = length(ms) |
|---|
| 2600 | ms = char mlen - 6 to mlen of ms |
|---|
| 2601 | |
|---|
| 2602 | theDefaultName = char 1 to 18 of theDefaultName |
|---|
| 2603 | theDefaultName = theDefaultName & ms -- trim filenames as the mac version of fileio wants to deal with 31 chars |
|---|
| 2604 | |
|---|
| 2605 | end if |
|---|
| 2606 | |
|---|
| 2607 | |
|---|
| 2608 | |
|---|
| 2609 | ------------------------------------------ trac subversion support works better with unix linebreaks... |
|---|
| 2610 | if voidP(convertLineBreaksToUnix) then convertLineBreaksToUnix = 1 |
|---|
| 2611 | if convertLineBreaksToUnix = "" then convertLineBreaksToUnix = 1 |
|---|
| 2612 | |
|---|
| 2613 | if convertLineBreaksToUnix = 1 then |
|---|
| 2614 | if convertLineBreaksToUnixT <> 1 then |
|---|
| 2615 | if mCheckForXtra(me, "Pregex") = 1 then |
|---|
| 2616 | |
|---|
| 2617 | scrTextLi = [scrText] |
|---|
| 2618 | pregex_replace(scrTextLi, "\x0D\x0A?", "g", "\x0A") |
|---|
| 2619 | scrText = scrTextLi[1] |
|---|
| 2620 | |
|---|
| 2621 | else |
|---|
| 2622 | |
|---|
| 2623 | fndStr = numToChar(13) & numToChar(10) |
|---|
| 2624 | offs = offset(fndStr, scrText) |
|---|
| 2625 | repeat while offs > 0 |
|---|
| 2626 | delete char offs of scrText |
|---|
| 2627 | offs = offset(fndStr, scrText) |
|---|
| 2628 | end repeat |
|---|
| 2629 | |
|---|
| 2630 | fndStr = numToChar(13) |
|---|
| 2631 | offs = offset(fndStr, scrText) |
|---|
| 2632 | repeat while offs > 0 |
|---|
| 2633 | put numToChar(10) into char offs of scrText |
|---|
| 2634 | offs = offset(fndStr, scrText) |
|---|
| 2635 | end repeat |
|---|
| 2636 | end if |
|---|
| 2637 | end if |
|---|
| 2638 | end if |
|---|
| 2639 | ----------------------------------------- |
|---|
| 2640 | |
|---|
| 2641 | if theDefaultName <> origname then |
|---|
| 2642 | alterText = "" |
|---|
| 2643 | snam = baShortFileName(thisFolder & origname & ext) |
|---|
| 2644 | if length(snam) > 0 then |
|---|
| 2645 | alterText = mGetTextFromFile(me, snam) |
|---|
| 2646 | else |
|---|
| 2647 | alterText = mGetTextFromFile(me, thisFolder & origname & ext) |
|---|
| 2648 | end if |
|---|
| 2649 | else |
|---|
| 2650 | alterText = mGetTextFromFile(me, thisFolder & theDefaultName & ext) |
|---|
| 2651 | end if |
|---|
| 2652 | |
|---|
| 2653 | listOfAllFiles.add(mLowerCase(me, origname)) |
|---|
| 2654 | |
|---|
| 2655 | if alterText <> scrText then |
|---|
| 2656 | |
|---|
| 2657 | --------------------- compare without whitespaces: |
|---|
| 2658 | noChanges = (mRemoveWhiteSpaces(me, scrText&"") = mRemoveWhiteSpaces(me, alterText&"")) |
|---|
| 2659 | |
|---|
| 2660 | |
|---|
| 2661 | if noChanges = 0 then |
|---|
| 2662 | |
|---|
| 2663 | mSaveToTextFile me, scrText, thisFolder & theDefaultName & ext |
|---|
| 2664 | |
|---|
| 2665 | bmexp = 0 |
|---|
| 2666 | if skipIcons <> 1 then |
|---|
| 2667 | |
|---|
| 2668 | thumbmember = new(#bitmap) |
|---|
| 2669 | thumbmember.picture = memref.thumbnail |
|---|
| 2670 | |
|---|
| 2671 | if thumbmember.width > 0 then |
|---|
| 2672 | bmexp = 1 |
|---|
| 2673 | if baFileExists(thisFolder & theDefaultName & ".png") then baDeleteFile(thisFolder & theDefaultName & ".png") |
|---|
| 2674 | |
|---|
| 2675 | if objectP(DirectImageInstance) then |
|---|
| 2676 | |
|---|
| 2677 | DirectImageInstance.imageLoadFromMember(thumbmember) |
|---|
| 2678 | DirectImageInstance.imageSaveToFile(thisFolder & theDefaultName & ".png", 100, 1,1) |
|---|
| 2679 | |
|---|
| 2680 | else if objectP(SharpExportInst) then |
|---|
| 2681 | mExportBM me, thumbmember, thisFolder & theDefaultName & ".png", "png", 100, SharpExportInst |
|---|
| 2682 | |
|---|
| 2683 | end if |
|---|
| 2684 | end if |
|---|
| 2685 | |
|---|
| 2686 | thumbmember.erase() |
|---|
| 2687 | |
|---|
| 2688 | end if |
|---|
| 2689 | |
|---|
| 2690 | |
|---|
| 2691 | if theDefaultName <> origname then |
|---|
| 2692 | |
|---|
| 2693 | snam = baShortFileName(thisFolder & origname & ext) |
|---|
| 2694 | if length(snam) > 0 then baDeleteFile(snam) |
|---|
| 2695 | erg = baRenameFile(thisFolder & theDefaultName & ext, thisFolder & origname & ext) |
|---|
| 2696 | if erg <> 1 then put "Couldn't rename file " & thisFolder & theDefaultName & ext & " to " & thisFolder & origname & ext |
|---|
| 2697 | if bmexp = 1 then |
|---|
| 2698 | snam = baShortFileName(thisFolder & origname & ".png") |
|---|
| 2699 | if length(snam) > 0 then baDeleteFile(snam) |
|---|
| 2700 | erg = baRenameFile(thisFolder & theDefaultName & ".png", thisFolder & origname & ".png") |
|---|
| 2701 | if erg <> 1 then put "Couldn't rename file " & thisFolder & theDefaultName & ".png to " & thisFolder & origname & ".png" |
|---|
| 2702 | end if |
|---|
| 2703 | |
|---|
| 2704 | end if |
|---|
| 2705 | |
|---|
| 2706 | if origname <> memname then |
|---|
| 2707 | put "Renamed member" && memref && "to" && origname & ". Scriptmember names must not be emoty or contain illegal characters (SPACE, /, :, \, &)" |
|---|
| 2708 | end if |
|---|
| 2709 | |
|---|
| 2710 | end if |
|---|
| 2711 | end if |
|---|
| 2712 | |
|---|
| 2713 | end if |
|---|
| 2714 | end repeat |
|---|
| 2715 | end repeat |
|---|
| 2716 | |
|---|
| 2717 | end repeat |
|---|
| 2718 | |
|---|
| 2719 | if resetUNames = 1 then baReturnUnixNames(1) |
|---|
| 2720 | |
|---|
| 2721 | DirectImageInstance = 0 |
|---|
| 2722 | SharpExportInst = 0 |
|---|
| 2723 | |
|---|
| 2724 | end |
|---|
| 2725 | |
|---|
| 2726 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2727 | on _______________SHELL_COMMAND me |
|---|
| 2728 | end |
|---|
| 2729 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2730 | |
|---|
| 2731 | |
|---|
| 2732 | on mDoShellCmd me, cmd, ReturnChar, maxTime, returnList, useOpen, stdout_callback, stderr_callback |
|---|
| 2733 | |
|---|
| 2734 | if voidP(maxTime) then maxTime = 0 |
|---|
| 2735 | |
|---|
| 2736 | if mCheckForXtra(me, "ff_shell") = 0 then |
|---|
| 2737 | if mCheckForXtra(me, "Shell") = 0 then |
|---|
| 2738 | mShellXtraMissing me |
|---|
| 2739 | return "" |
|---|
| 2740 | else |
|---|
| 2741 | if returnList = 1 then |
|---|
| 2742 | |
|---|
| 2743 | if the platform contains "mac" then |
|---|
| 2744 | return shell_cmd_list(cmd) |
|---|
| 2745 | else |
|---|
| 2746 | return shell_cmd(cmd, ReturnChar, maxTime, 1, useOpen, stdout_callback, stderr_callback) |
|---|
| 2747 | end if |
|---|
| 2748 | |
|---|
| 2749 | else |
|---|
| 2750 | |
|---|
| 2751 | if the platform contains "mac" then |
|---|
| 2752 | return shell_cmd(cmd) |
|---|
| 2753 | else |
|---|
| 2754 | return shell_cmd(cmd, ReturnChar, maxTime, 0, useOpen, stdout_callback, stderr_callback) |
|---|
| 2755 | end if |
|---|
| 2756 | |
|---|
| 2757 | end if |
|---|
| 2758 | end if |
|---|
| 2759 | else |
|---|
| 2760 | ff_shellxtra = new(xtra "ff_shell") |
|---|
| 2761 | li = ff_shellxtra.ff_shell(cmd) |
|---|
| 2762 | ff_shellxtra = 0 |
|---|
| 2763 | if returnList = 1 then |
|---|
| 2764 | retlist = [] |
|---|
| 2765 | if listP(li) then |
|---|
| 2766 | cnt = count(li) |
|---|
| 2767 | repeat with n = 1 to cnt |
|---|
| 2768 | this = li[n] |
|---|
| 2769 | if the last char of this = RETURN then delete the last char of this |
|---|
| 2770 | if charToNum(the last char of this) = 10 then delete the last char of this |
|---|
| 2771 | retlist.add(this) |
|---|
| 2772 | end repeat |
|---|
| 2773 | end if |
|---|
| 2774 | return retlist |
|---|
| 2775 | else |
|---|
| 2776 | str = "" |
|---|
| 2777 | if listP(li) then |
|---|
| 2778 | cnt = count(li) |
|---|
| 2779 | repeat with n = 1 to cnt |
|---|
| 2780 | this = li[n] |
|---|
| 2781 | if the last char of this <> RETURN then put RETURN after this |
|---|
| 2782 | put this after str |
|---|
| 2783 | end repeat |
|---|
| 2784 | if length(str) > 0 then delete the last char of str |
|---|
| 2785 | end if |
|---|
| 2786 | return str |
|---|
| 2787 | end if |
|---|
| 2788 | end if |
|---|
| 2789 | return "" |
|---|
| 2790 | |
|---|
| 2791 | end |
|---|
| 2792 | |
|---|
| 2793 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2794 | |
|---|
| 2795 | on mConvertHFS2Unix me, fname |
|---|
| 2796 | |
|---|
| 2797 | if not(the platform contains "mac") then return fname |
|---|
| 2798 | |
|---|
| 2799 | if fname starts "/" then return fname -- huh? must already be an absolute unix path |
|---|
| 2800 | |
|---|
| 2801 | offs = offset(":", fname) |
|---|
| 2802 | repeat while offs |
|---|
| 2803 | put "/" into char offs of fname |
|---|
| 2804 | offs = offset(":", fname) |
|---|
| 2805 | end repeat |
|---|
| 2806 | put "/Volumes/" before fname |
|---|
| 2807 | |
|---|
| 2808 | return fname |
|---|
| 2809 | |
|---|
| 2810 | end |
|---|
| 2811 | |
|---|
| 2812 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2813 | |
|---|
| 2814 | on mConvertUnix2Hfs me, fname |
|---|
| 2815 | if not(the platform contains "mac") then return fname |
|---|
| 2816 | |
|---|
| 2817 | if fname starts "/Volumes/" then |
|---|
| 2818 | olddelim = the itemdelimiter |
|---|
| 2819 | the itemdelimiter = "/" |
|---|
| 2820 | delete item 1 to 3 of fname |
|---|
| 2821 | the itemdelimiter = olddelim |
|---|
| 2822 | put "/" before fname |
|---|
| 2823 | end if |
|---|
| 2824 | |
|---|
| 2825 | if not(fname starts "/") then return fname -- huh? doesn't seem to be an absolute unix path |
|---|
| 2826 | |
|---|
| 2827 | offs = offset("/", fname) |
|---|
| 2828 | repeat while offs |
|---|
| 2829 | put ":" into char offs of fname |
|---|
| 2830 | offs = offset("/", fname) |
|---|
| 2831 | end repeat |
|---|
| 2832 | |
|---|
| 2833 | osDir = getOsDirectory() |
|---|
| 2834 | olddelim = the itemdelimiter |
|---|
| 2835 | the itemdelimiter = ":" |
|---|
| 2836 | put item 1 of osDir before fname |
|---|
| 2837 | the itemdelimiter = olddelim |
|---|
| 2838 | |
|---|
| 2839 | return fname |
|---|
| 2840 | |
|---|
| 2841 | end |
|---|
| 2842 | |
|---|
| 2843 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2844 | ------------------- subversion support works better with unix linebreaks... |
|---|
| 2845 | |
|---|
| 2846 | on mConvertLineBreaksToUnix me, st |
|---|
| 2847 | |
|---|
| 2848 | if mCheckForXtra(me, "Pregex") = 1 then |
|---|
| 2849 | scrTextLi = [st] |
|---|
| 2850 | pregex_replace(scrTextLi, "\x0D\x0A?", "g", "\x0A") |
|---|
| 2851 | return scrTextLi[1] |
|---|
| 2852 | else |
|---|
| 2853 | fndStr = numToChar(13) & numToChar(10) |
|---|
| 2854 | offs = offset(fndStr, st) |
|---|
| 2855 | repeat while offs > 0 |
|---|
| 2856 | delete char offs of st |
|---|
| 2857 | offs = offset(fndStr, st) |
|---|
| 2858 | end repeat |
|---|
| 2859 | |
|---|
| 2860 | fndStr = numToChar(13) |
|---|
| 2861 | offs = offset(fndStr, st) |
|---|
| 2862 | repeat while offs > 0 |
|---|
| 2863 | put numToChar(10) into char offs of st |
|---|
| 2864 | offs = offset(fndStr, st) |
|---|
| 2865 | end repeat |
|---|
| 2866 | |
|---|
| 2867 | end if |
|---|
| 2868 | |
|---|
| 2869 | return st |
|---|
| 2870 | |
|---|
| 2871 | end |
|---|
| 2872 | |
|---|
| 2873 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2874 | ----------- always convert to mac linebreaks for scripts as director internally uses mac linebreaks |
|---|
| 2875 | |
|---|
| 2876 | on mConvertLineBreaksToMac me, scrText |
|---|
| 2877 | |
|---|
| 2878 | if mCheckForXtra(me, "Pregex") = 1 then |
|---|
| 2879 | |
|---|
| 2880 | scrTextLi = [scrText] |
|---|
| 2881 | pregex_replace(scrTextLi, "\x0D?\x0A", "g", "\x0D") |
|---|
| 2882 | return scrTextLi[1] |
|---|
| 2883 | |
|---|
| 2884 | else |
|---|
| 2885 | |
|---|
| 2886 | -- first convert windows to mac |
|---|
| 2887 | fndStr = numToChar(13) & numToChar(10) |
|---|
| 2888 | offs = offset(fndStr, scrText) |
|---|
| 2889 | repeat while offs > 0 |
|---|
| 2890 | put numToChar(13) into char offs to offs+1 of scrText |
|---|
| 2891 | offs = offset(fndStr, scrText) |
|---|
| 2892 | end repeat |
|---|
| 2893 | |
|---|
| 2894 | -- now convert unix to mac |
|---|
| 2895 | fndStr = numToChar(10) |
|---|
| 2896 | offs = offset(fndStr, scrText) |
|---|
| 2897 | repeat while offs > 0 |
|---|
| 2898 | put numToChar(13) into char offs of scrText |
|---|
| 2899 | offs = offset(fndStr, scrText) |
|---|
| 2900 | end repeat |
|---|
| 2901 | |
|---|
| 2902 | end if |
|---|
| 2903 | ----------------------------------------- |
|---|
| 2904 | |
|---|
| 2905 | return scrText |
|---|
| 2906 | |
|---|
| 2907 | end |
|---|
| 2908 | |
|---|
| 2909 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2910 | |
|---|
| 2911 | on mGetTempFilePath me, theName |
|---|
| 2912 | |
|---|
| 2913 | -------------- for some reason, I don't know why, if I use this buddyApi temp folder |
|---|
| 2914 | -------------- files get screwed up with invalid unicode chars ???!!! |
|---|
| 2915 | -------------- so I resort to the old behavior just using /tmp |
|---|
| 2916 | |
|---|
| 2917 | -- if mCheckForXtra(me, "BudAPI") then |
|---|
| 2918 | -- |
|---|
| 2919 | -- if the platform contains "mac" then |
|---|
| 2920 | -- |
|---|
| 2921 | -- resetUNames = 0 |
|---|
| 2922 | -- if baSysFolder("prefs") starts "/" then |
|---|
| 2923 | -- baReturnUnixNames(0) |
|---|
| 2924 | -- resetUNames = 1 |
|---|
| 2925 | -- end if |
|---|
| 2926 | -- tempSrcHFSPath = basysfolder("temp") |
|---|
| 2927 | -- if length(tempSrcHFSPath) > 0 then |
|---|
| 2928 | -- tempSrcHFSPath = tempSrcHFSPath & theName |
|---|
| 2929 | -- if resetUNames = 1 then baReturnUnixNames(1) |
|---|
| 2930 | -- return tempSrcHFSPath |
|---|
| 2931 | -- else |
|---|
| 2932 | -- if resetUNames = 1 then baReturnUnixNames(1) |
|---|
| 2933 | -- end if |
|---|
| 2934 | -- |
|---|
| 2935 | -- else |
|---|
| 2936 | -- tmpfolder = baSysFolder("temp") |
|---|
| 2937 | -- if length(tmpfolder) > 0 then return tmpfolder & theName |
|---|
| 2938 | -- end if |
|---|
| 2939 | -- |
|---|
| 2940 | -- end if |
|---|
| 2941 | |
|---|
| 2942 | -- we only come here, if |
|---|
| 2943 | -- -- a.) buddyApi is NOT present or |
|---|
| 2944 | -- -- b.) basysfolder("temp") returns "" (for whatever reason...!) |
|---|
| 2945 | if the platform contains "mac" then |
|---|
| 2946 | |
|---|
| 2947 | tempSrcPath = "/tmp/" & theName |
|---|
| 2948 | |
|---|
| 2949 | return mConvertUnix2Hfs(me, tempSrcPath) |
|---|
| 2950 | |
|---|
| 2951 | else |
|---|
| 2952 | tmpfolder = "C:\WINDOWS\TEMP\" |
|---|
| 2953 | return tmpfolder & theName |
|---|
| 2954 | end if |
|---|
| 2955 | |
|---|
| 2956 | |
|---|
| 2957 | end |
|---|
| 2958 | |
|---|
| 2959 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2960 | on _______________GLOSSARY_ITEMS me |
|---|
| 2961 | end |
|---|
| 2962 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2963 | |
|---|
| 2964 | |
|---|
| 2965 | on snipTitle me |
|---|
| 2966 | |
|---|
| 2967 | str = "-----------------------------------"&\ |
|---|
| 2968 | RETURN & " -- CREATED: <currentDate>"&\ |
|---|
| 2969 | RETURN & " -- ACTION: Description"&\ |
|---|
| 2970 | RETURN & " -- INPUT: -"&\ |
|---|
| 2971 | RETURN & " -- RETURNS: -"&\ |
|---|
| 2972 | RETURN & " -- EXAMPLE: -"&\ |
|---|
| 2973 | RETURN & "-----------------------------------" |
|---|
| 2974 | |
|---|
| 2975 | mPasteItem me, str, 1 |
|---|
| 2976 | |
|---|
| 2977 | end |
|---|
| 2978 | |
|---|
| 2979 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 2980 | |
|---|
| 2981 | on snipAbstract me |
|---|
| 2982 | |
|---|
| 2983 | str = " -- <Scriptname>"&\ |
|---|
| 2984 | RETURN & " -----------------------------------"&\ |
|---|
| 2985 | RETURN & " -- CREATED:"&\ |
|---|
| 2986 | RETURN & " -- <currentDate>"&\ |
|---|
| 2987 | RETURN & " -- PROPERTIES:"&\ |
|---|
| 2988 | RETURN & " --!memberProperties: [#name: ""E&"<scriptname>""E&", #scripttype: #<scripttype>, #scriptSyntax: #<scriptSyntax>, #comments: ""E&"<comments>""E&"]"&\ |
|---|
| 2989 | RETURN & " --"&\ |
|---|
| 2990 | RETURN & " -- DESCRIPTION:"&\ |
|---|
| 2991 | RETURN & " -- -"&\ |
|---|
| 2992 | RETURN & " --"&\ |
|---|
| 2993 | RETURN & " -- REQUIRES:"&\ |
|---|
| 2994 | RETURN & " -- (Prerequisites)"&\ |
|---|
| 2995 | RETURN & " --"&\ |
|---|
| 2996 | RETURN & " -- USAGE:"&\ |
|---|
| 2997 | RETURN & " -- -"&\ |
|---|
| 2998 | RETURN & " --"&\ |
|---|
| 2999 | RETURN & " -- EXAMPLE:"&\ |
|---|
| 3000 | RETURN & " -- -"&\ |
|---|
| 3001 | RETURN & " -----------------------------------" |
|---|
| 3002 | |
|---|
| 3003 | mPasteItem me, str, 1 |
|---|
| 3004 | |
|---|
| 3005 | end |
|---|
| 3006 | |
|---|
| 3007 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3008 | |
|---|
| 3009 | on pasteDate me |
|---|
| 3010 | |
|---|
| 3011 | dstring = "alex am" && the date && "um" && the time |
|---|
| 3012 | theText = "--" && dstring |
|---|
| 3013 | put RETURN & "--------------------------------------------------------" after theText |
|---|
| 3014 | put RETURN & RETURN & "--------------------------------------------------------" after theText |
|---|
| 3015 | put RETURN & "-- //" && dstring after theText |
|---|
| 3016 | mPasteItem me, theText |
|---|
| 3017 | end |
|---|
| 3018 | |
|---|
| 3019 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3020 | |
|---|
| 3021 | on pasteDivider me |
|---|
| 3022 | dstring = "-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
|---|
| 3023 | mPasteItem me, dstring |
|---|
| 3024 | end |
|---|
| 3025 | |
|---|
| 3026 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3027 | |
|---|
| 3028 | on mPasteItem me, theText, replacePlaceHolder |
|---|
| 3029 | |
|---|
| 3030 | |
|---|
| 3031 | theMem = 0 |
|---|
| 3032 | cl = the activecastlib |
|---|
| 3033 | sel = the selection of castlib cl |
|---|
| 3034 | if count(sel) = 1 then |
|---|
| 3035 | theMem = member(sel[1][1], cl) |
|---|
| 3036 | if theMem.type <> #script then |
|---|
| 3037 | repeat with n = 1 to the number of castlibs |
|---|
| 3038 | if n <> cl then |
|---|
| 3039 | sel = the selection of castlib n |
|---|
| 3040 | if count(sel) = 1 then |
|---|
| 3041 | theMem = member(sel[1][1],n) |
|---|
| 3042 | if theMem.type = #script then exit repeat |
|---|
| 3043 | end if |
|---|
| 3044 | end if |
|---|
| 3045 | end repeat |
|---|
| 3046 | end if |
|---|
| 3047 | end if |
|---|
| 3048 | |
|---|
| 3049 | |
|---|
| 3050 | if ilk(theMem) = #member then |
|---|
| 3051 | if theMem.type = #script then |
|---|
| 3052 | |
|---|
| 3053 | --------------------------------- we paste the placeholder only here in this script, because there is a placeholder |
|---|
| 3054 | --------------------------------- for the current scriptname, which we only "know" here in this script |
|---|
| 3055 | if replacePlaceHolder = 1 then |
|---|
| 3056 | placeholders = [["<currentDate>", the short date], ["<scriptname>", theMem.name], ["<scripttype>", theMem.scripttype], ["<scriptSyntax>", theMem.scriptSyntax], ["<comments>", theMem.comments]] |
|---|
| 3057 | |
|---|
| 3058 | repeat with repl in placeholders |
|---|
| 3059 | if repl[1] <> repl[2] then |
|---|
| 3060 | offs = offset(repl[1], theText) |
|---|
| 3061 | repeat while offs > 0 |
|---|
| 3062 | put repl[2] into char offs to offs + length(repl[1]) - 1 of theText |
|---|
| 3063 | offs = offset(repl[1], theText) |
|---|
| 3064 | end repeat |
|---|
| 3065 | end if |
|---|
| 3066 | end repeat |
|---|
| 3067 | |
|---|
| 3068 | end if |
|---|
| 3069 | --------------------------------- |
|---|
| 3070 | |
|---|
| 3071 | end if |
|---|
| 3072 | end if |
|---|
| 3073 | |
|---|
| 3074 | pastefield = new(#field) |
|---|
| 3075 | pastefield.text = theText |
|---|
| 3076 | |
|---|
| 3077 | oldclipboard = new(#field) |
|---|
| 3078 | oldclipboard.pasteClipBoardInto() |
|---|
| 3079 | |
|---|
| 3080 | pastefield.copyToClipBoard() |
|---|
| 3081 | |
|---|
| 3082 | |
|---|
| 3083 | if ilk(theMem) = #member then |
|---|
| 3084 | if theMem.type = #script then |
|---|
| 3085 | activateScriptEditor(theMem.memberNum, cl, -1, -1) |
|---|
| 3086 | |
|---|
| 3087 | dispatchcommand(4613) |
|---|
| 3088 | end if |
|---|
| 3089 | end if |
|---|
| 3090 | |
|---|
| 3091 | |
|---|
| 3092 | copyToClipBoard(oldclipboard) |
|---|
| 3093 | |
|---|
| 3094 | oldclipboard.erase() |
|---|
| 3095 | pastefield.erase() |
|---|
| 3096 | end |
|---|
| 3097 | |
|---|
| 3098 | |
|---|
| 3099 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3100 | |
|---|
| 3101 | on mSwitchToStatusMode me, On_Off |
|---|
| 3102 | |
|---|
| 3103 | retval = 0 |
|---|
| 3104 | |
|---|
| 3105 | if pStatusMode = 0 then |
|---|
| 3106 | if On_Off = 0 then |
|---|
| 3107 | return retval |
|---|
| 3108 | end if |
|---|
| 3109 | else |
|---|
| 3110 | if On_Off = 1 then |
|---|
| 3111 | return retval |
|---|
| 3112 | end if |
|---|
| 3113 | end if |
|---|
| 3114 | |
|---|
| 3115 | |
|---|
| 3116 | pHandlerMenuWindowName = string(me.pHandlerMenuWindowName) |
|---|
| 3117 | if length(pHandlerMenuWindowName) < 1 then return retval |
|---|
| 3118 | w = window(pHandlerMenuWindowName) |
|---|
| 3119 | |
|---|
| 3120 | if ilk(w) <> #window then return retval |
|---|
| 3121 | |
|---|
| 3122 | retval = 1 |
|---|
| 3123 | |
|---|
| 3124 | |
|---|
| 3125 | |
|---|
| 3126 | r = w.rect |
|---|
| 3127 | |
|---|
| 3128 | oldwidth = pStatusMode |
|---|
| 3129 | if On_Off = 1 then pStatusMode = r.width |
|---|
| 3130 | else pStatusMode = 0 |
|---|
| 3131 | |
|---|
| 3132 | tell w |
|---|
| 3133 | |
|---|
| 3134 | spr = sprite(xscr().mGetkanal(#helpTextSprite)) |
|---|
| 3135 | |
|---|
| 3136 | if On_Off = 1 then |
|---|
| 3137 | |
|---|
| 3138 | |
|---|
| 3139 | member("statusOutput").text = "The following operation may take some time..." |
|---|
| 3140 | spr.member = member("statusOutput") |
|---|
| 3141 | |
|---|
| 3142 | newRect = rect(r.left, r.top, r.left + spr.rect.right, r.top + spr.rect.bottom) |
|---|
| 3143 | |
|---|
| 3144 | if (label("withSearch") <> marker(0)) then |
|---|
| 3145 | go "withSearch" |
|---|
| 3146 | end if |
|---|
| 3147 | |
|---|
| 3148 | |
|---|
| 3149 | else |
|---|
| 3150 | |
|---|
| 3151 | spr.member = member("helptext") |
|---|
| 3152 | |
|---|
| 3153 | if ilk(oldwidth) <> #integer then oldwidth = r.width |
|---|
| 3154 | if oldwidth < 1 then oldwidth = r.width |
|---|
| 3155 | |
|---|
| 3156 | newRect = rect(r.left, r.top, r.left + oldwidth, r.top + spr.rect.top - 10) |
|---|
| 3157 | |
|---|
| 3158 | if (label("withoutSearch") <> marker(0)) then go "withoutSearch" |
|---|
| 3159 | |
|---|
| 3160 | end if |
|---|
| 3161 | |
|---|
| 3162 | updatestage |
|---|
| 3163 | end tell |
|---|
| 3164 | |
|---|
| 3165 | w.rect = newRect |
|---|
| 3166 | |
|---|
| 3167 | return retval |
|---|
| 3168 | |
|---|
| 3169 | end |
|---|
| 3170 | |
|---|
| 3171 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3172 | |
|---|
| 3173 | on mDisplayWaitStatusText me, str |
|---|
| 3174 | |
|---|
| 3175 | if pStatusMode = 0 then exit |
|---|
| 3176 | |
|---|
| 3177 | pHandlerMenuWindowName = string(me.pHandlerMenuWindowName) |
|---|
| 3178 | if length(pHandlerMenuWindowName) < 1 then exit |
|---|
| 3179 | w = window(pHandlerMenuWindowName) |
|---|
| 3180 | |
|---|
| 3181 | if ilk(w) <> #window then exit |
|---|
| 3182 | |
|---|
| 3183 | tell w |
|---|
| 3184 | member("statusOutput").setContentsAfter(RETURN & str) |
|---|
| 3185 | updatestage |
|---|
| 3186 | |
|---|
| 3187 | end tell |
|---|
| 3188 | |
|---|
| 3189 | end |
|---|
| 3190 | |
|---|
| 3191 | |
|---|
| 3192 | |
|---|
| 3193 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3194 | on _______________EXTERNAL_PATHS me |
|---|
| 3195 | end |
|---|
| 3196 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3197 | |
|---|
| 3198 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3199 | |
|---|
| 3200 | on mGetExternalScriptEditor me, externalEditors |
|---|
| 3201 | |
|---|
| 3202 | if mCheckForXtra(me, "budapi") <> 1 then |
|---|
| 3203 | alert "You need the buddyApi xtra for this operation" |
|---|
| 3204 | exit |
|---|
| 3205 | end if |
|---|
| 3206 | |
|---|
| 3207 | savePrefs = 0 |
|---|
| 3208 | if ilk(externalEditors) <> #proplist then |
|---|
| 3209 | externalEditors = value(getPref("handlerMenu_externalEditors.txt")) |
|---|
| 3210 | if ilk(externalEditors) <> #proplist then externalEditors = [:] |
|---|
| 3211 | savePrefs = 1 |
|---|
| 3212 | end if |
|---|
| 3213 | |
|---|
| 3214 | if the shiftdown then |
|---|
| 3215 | externalScripteditor = "" |
|---|
| 3216 | savePrefs = 1 |
|---|
| 3217 | else |
|---|
| 3218 | externalScripteditor = string(externalEditors.getaprop(#externalScripteditor)) |
|---|
| 3219 | if baFileExists(externalScripteditor) <> 1 then externalScripteditor = "" |
|---|
| 3220 | end if |
|---|
| 3221 | |
|---|
| 3222 | if length(externalScripteditor) < 1 then |
|---|
| 3223 | |
|---|
| 3224 | alert "Please select an external script editor." |
|---|
| 3225 | externalScripteditor = mGetFilePathFromUser(me) |
|---|
| 3226 | if length(externalScripteditor) < 1 then return "" |
|---|
| 3227 | |
|---|
| 3228 | end if |
|---|
| 3229 | |
|---|
| 3230 | if baFileExists(externalScripteditor) <> 1 then |
|---|
| 3231 | alert "The path to the external script editor seems to have changed. Please try again in order to search the path." |
|---|
| 3232 | externalScripteditor = "" |
|---|
| 3233 | end if |
|---|
| 3234 | |
|---|
| 3235 | externalEditors.setaprop(#externalScripteditor, externalScripteditor) |
|---|
| 3236 | |
|---|
| 3237 | if savePrefs = 1 then setPref("handlerMenu_externalEditors.txt", string(externalEditors)) |
|---|
| 3238 | |
|---|
| 3239 | return externalScripteditor |
|---|
| 3240 | |
|---|
| 3241 | end |
|---|
| 3242 | |
|---|
| 3243 | |
|---|
| 3244 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3245 | |
|---|
| 3246 | on mGetSVNDiffBinaryPath me, workingCopies |
|---|
| 3247 | |
|---|
| 3248 | if (mCheckForXtra(me, "budapi") + (mCheckForXtra(me, "Shell") + mCheckForXtra(me, "ff_shell"))) < 2 then |
|---|
| 3249 | alert "You need the shell xtra and the buddyApi xtra in order to proceed" |
|---|
| 3250 | return "" |
|---|
| 3251 | end if |
|---|
| 3252 | |
|---|
| 3253 | savePrefs = 0 |
|---|
| 3254 | if ilk(workingCopies) <> #proplist then |
|---|
| 3255 | workingCopies = value(getPref("svn_workingCopies_paths.txt")) |
|---|
| 3256 | if ilk(workingCopies) <> #proplist then workingCopies = [:] |
|---|
| 3257 | savePrefs = 1 |
|---|
| 3258 | end if |
|---|
| 3259 | |
|---|
| 3260 | |
|---|
| 3261 | svnBinary = string(workingCopies.getaprop(#svnDiffBinary)) |
|---|
| 3262 | |
|---|
| 3263 | |
|---|
| 3264 | if baFileExists(svnBinary) <> 1 then svnBinary = "" |
|---|
| 3265 | |
|---|
| 3266 | |
|---|
| 3267 | if length(svnBinary) < 1 then |
|---|
| 3268 | |
|---|
| 3269 | alert "There is not yet an application specified to handle file diffs. Please select the applivcation you want to use, e.g. TortoiseMerge in your Tortoise folder, if you are using Tortoise." |
|---|
| 3270 | svnBinary = mGetFilePathFromUser(me) |
|---|
| 3271 | if length(svnBinary) < 1 then return "" |
|---|
| 3272 | |
|---|
| 3273 | end if |
|---|
| 3274 | |
|---|
| 3275 | if baFileExists(svnBinary) <> 1 then |
|---|
| 3276 | alert "The path to the svn diff binary seems to have changed. Please try again in order to search the path." |
|---|
| 3277 | svnBinary = "" |
|---|
| 3278 | end if |
|---|
| 3279 | |
|---|
| 3280 | |
|---|
| 3281 | |
|---|
| 3282 | workingCopies.setaprop(#svnDiffBinary, svnBinary) |
|---|
| 3283 | |
|---|
| 3284 | if savePrefs = 1 then setPref("svn_workingCopies_paths.txt", string(workingCopies)) |
|---|
| 3285 | |
|---|
| 3286 | return svnBinary |
|---|
| 3287 | |
|---|
| 3288 | end |
|---|
| 3289 | |
|---|
| 3290 | |
|---|
| 3291 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3292 | on _______________HELPER_HANDLER me |
|---|
| 3293 | end |
|---|
| 3294 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3295 | |
|---|
| 3296 | -- the following handlers are mostly duplicates from the script "commonMovieScript", |
|---|
| 3297 | -- because we are running in the scope of the stage here, we can not use it directly |
|---|
| 3298 | -- and therefore this script shall be completely self contained. |
|---|
| 3299 | |
|---|
| 3300 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3301 | -- xxxxxxxxxxxxxxxxxx check for availability of scripting xtra by name and store result for further access |
|---|
| 3302 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3303 | |
|---|
| 3304 | on mCheckForXtra me, whichXtra |
|---|
| 3305 | globs = mGetGlobalList(me) |
|---|
| 3306 | theXtras = globs.getaprop(#gXtras) |
|---|
| 3307 | if ilk(theXtras) <> #proplist then |
|---|
| 3308 | theXtras = [:] |
|---|
| 3309 | globs[#gXtras] = theXtras |
|---|
| 3310 | end if |
|---|
| 3311 | xtraPresent = theXtras.getaprop(whichXtra) |
|---|
| 3312 | if voidP(xtraPresent) then |
|---|
| 3313 | xtraPresent = 0 |
|---|
| 3314 | numX = the number of xtras |
|---|
| 3315 | repeat with n = 1 to numX |
|---|
| 3316 | if (the name of xtra n = whichXtra) then |
|---|
| 3317 | xtraPresent = 1 |
|---|
| 3318 | exit repeat |
|---|
| 3319 | end if |
|---|
| 3320 | end repeat |
|---|
| 3321 | theXtras.setaprop(whichXtra, xtraPresent) |
|---|
| 3322 | end if |
|---|
| 3323 | return xtraPresent |
|---|
| 3324 | end |
|---|
| 3325 | |
|---|
| 3326 | |
|---|
| 3327 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3328 | -- xxxxxxxxxxxxxxxxxx Check for file existence |
|---|
| 3329 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3330 | |
|---|
| 3331 | on mCheckFileExists me, aPath |
|---|
| 3332 | if ilk(aPath) <> #string then return 0 |
|---|
| 3333 | if not(aPath.length) then return 0 |
|---|
| 3334 | |
|---|
| 3335 | if the runmode contains "plug" then |
|---|
| 3336 | retValue = 1 -- can't do this check in shockwave |
|---|
| 3337 | |
|---|
| 3338 | else |
|---|
| 3339 | |
|---|
| 3340 | retValue = 0 |
|---|
| 3341 | |
|---|
| 3342 | if mCheckForXtra(me, "BudAPI") then -- if buddy is present... |
|---|
| 3343 | -- -- budApi version: |
|---|
| 3344 | |
|---|
| 3345 | -- alex am 6.03.2004 um 09:06 |
|---|
| 3346 | |
|---|
| 3347 | -- ich weiss nicht wirklich, ob es schlauer ist baShortFileName() zu verwenden |
|---|
| 3348 | -- wegen alten versionen von BudApi, OS9, windows... ??? |
|---|
| 3349 | -- so: handle with care |
|---|
| 3350 | -- retValue = baFileExists(aPath) |
|---|
| 3351 | |
|---|
| 3352 | retValue = (string(baShortFileName(aPath)) <> "") |
|---|
| 3353 | --/ alex am 6.03.2004 um 09:06 |
|---|
| 3354 | |
|---|
| 3355 | else if mCheckForXtra(me, "FileXtra4") then -- if not buddy then try filextra |
|---|
| 3356 | -- -- filextra3 version: |
|---|
| 3357 | fx = (xtra "filextra4").new() |
|---|
| 3358 | if objectP(fx) then retValue = fx.fx_FileExists(aPath) |
|---|
| 3359 | fx = 0 |
|---|
| 3360 | else if mCheckForXtra(me, "fileio") then |
|---|
| 3361 | -- if all else fails, try the slower fileio version by trying to open the file |
|---|
| 3362 | -- -- fileio version: |
|---|
| 3363 | fio = (xtra "fileio").new() |
|---|
| 3364 | if objectP(fio) then |
|---|
| 3365 | fio.openFile(aPath, 0) |
|---|
| 3366 | if fio.status() = 0 then |
|---|
| 3367 | fio.closeFile() |
|---|
| 3368 | retValue = 1 |
|---|
| 3369 | end if |
|---|
| 3370 | end if |
|---|
| 3371 | fio = 0 |
|---|
| 3372 | |
|---|
| 3373 | else |
|---|
| 3374 | retValue = 1 -- in dubio pro reo |
|---|
| 3375 | end if |
|---|
| 3376 | |
|---|
| 3377 | end if |
|---|
| 3378 | |
|---|
| 3379 | return retValue |
|---|
| 3380 | end |
|---|
| 3381 | |
|---|
| 3382 | |
|---|
| 3383 | property pGList |
|---|
| 3384 | |
|---|
| 3385 | on mGetGlobalList me |
|---|
| 3386 | if voidP(pGList) then pGList = [:] |
|---|
| 3387 | return pGList |
|---|
| 3388 | end |
|---|
| 3389 | |
|---|
| 3390 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3391 | |
|---|
| 3392 | on mShellXtraMissing me |
|---|
| 3393 | alertList = [#buttons: #YesNo, #default:1, #title: "Help Miaw missing", #message: "You need the shell xtra for this function, do you want to visit the website of the xtra author (Valentin Schmidt)?", #icon:#question, #movable: 0] |
|---|
| 3394 | mui = new(xtra "MUI") |
|---|
| 3395 | resp = mui.alert(alertList) |
|---|
| 3396 | mui = 0 |
|---|
| 3397 | if resp = 1 then |
|---|
| 3398 | if mCheckForXtra(me, "BudAPI") then |
|---|
| 3399 | -- give BudAPI precedence before gotonetpage |
|---|
| 3400 | baOpenURL("http://staff.dasdeck.de/valentin/xtras/shell/", "normal") |
|---|
| 3401 | else |
|---|
| 3402 | gotonetpage("http://staff.dasdeck.de/valentin/xtras/shell/") |
|---|
| 3403 | end if |
|---|
| 3404 | end if |
|---|
| 3405 | end |
|---|
| 3406 | |
|---|
| 3407 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3408 | |
|---|
| 3409 | on mGetFloatVersionNumber me, prodVers |
|---|
| 3410 | offs = offset(".", prodVers) |
|---|
| 3411 | if offs > 0 then |
|---|
| 3412 | intVers = char 1 to offs of prodVers |
|---|
| 3413 | delete char 1 to offs of prodVers |
|---|
| 3414 | else |
|---|
| 3415 | intVers = "" |
|---|
| 3416 | end if |
|---|
| 3417 | cnt = length(prodVers) |
|---|
| 3418 | repeat with n = 1 to cnt |
|---|
| 3419 | c = prodVers.char[n] |
|---|
| 3420 | if integerP(integer(c)) then |
|---|
| 3421 | put c after intVers |
|---|
| 3422 | else if c <> "." then |
|---|
| 3423 | exit repeat |
|---|
| 3424 | end if |
|---|
| 3425 | end repeat |
|---|
| 3426 | |
|---|
| 3427 | return value(intVers) |
|---|
| 3428 | end |
|---|
| 3429 | |
|---|
| 3430 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3431 | |
|---|
| 3432 | on mGetMemType me, memref |
|---|
| 3433 | if ilk(memref) <> #member then return #empty |
|---|
| 3434 | return memref.type |
|---|
| 3435 | end |
|---|
| 3436 | |
|---|
| 3437 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3438 | |
|---|
| 3439 | -- split a path into its three elements => base directory, basename and extension: |
|---|
| 3440 | |
|---|
| 3441 | on mSplitPath me, fname, delim -- delim optional: default = the systems pathdelimiter |
|---|
| 3442 | |
|---|
| 3443 | olddelim = the itemdelimiter |
|---|
| 3444 | delim = string(delim) |
|---|
| 3445 | if length(delim) < 1 then |
|---|
| 3446 | delim = the last char of the moviepath |
|---|
| 3447 | if length(delim) < 1 then |
|---|
| 3448 | |
|---|
| 3449 | if the runmode contains "plug" then |
|---|
| 3450 | delim = "/" |
|---|
| 3451 | else |
|---|
| 3452 | delim = the last char of the applicationpath |
|---|
| 3453 | end if |
|---|
| 3454 | |
|---|
| 3455 | |
|---|
| 3456 | if length(delim) < 1 then delim = "/" |
|---|
| 3457 | end if |
|---|
| 3458 | end if |
|---|
| 3459 | the itemdelimiter = delim |
|---|
| 3460 | dateiname = the last item of fname |
|---|
| 3461 | delete the last item of fname |
|---|
| 3462 | put delim after fname |
|---|
| 3463 | the itemdelimiter = olddelim |
|---|
| 3464 | |
|---|
| 3465 | |
|---|
| 3466 | len = length(dateiname) |
|---|
| 3467 | ext = "" |
|---|
| 3468 | until = max(1, len-8) -- let's pretend, that a file extension is not langer than 8 chars |
|---|
| 3469 | |
|---|
| 3470 | repeat with n = len down to until |
|---|
| 3471 | this = dateiname.char[n] |
|---|
| 3472 | put this before ext |
|---|
| 3473 | delete char n of dateiname |
|---|
| 3474 | if this = "." then exit repeat |
|---|
| 3475 | end repeat |
|---|
| 3476 | |
|---|
| 3477 | if char 1 of ext <> "." then -- no extension |
|---|
| 3478 | put ext after dateiname |
|---|
| 3479 | ext = "" |
|---|
| 3480 | end if |
|---|
| 3481 | |
|---|
| 3482 | return [#basedir:fname, #basename:dateiname, #extension:ext] |
|---|
| 3483 | |
|---|
| 3484 | end |
|---|
| 3485 | |
|---|
| 3486 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3487 | on ____________CONVERT_CASE |
|---|
| 3488 | end |
|---|
| 3489 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3490 | |
|---|
| 3491 | |
|---|
| 3492 | |
|---|
| 3493 | on mUpperCase me, aString |
|---|
| 3494 | |
|---|
| 3495 | if not(listP(pCaseLists)) then mCreateCaseLists me |
|---|
| 3496 | |
|---|
| 3497 | lowercase = pCaseLists.getaprop(#lowercase) |
|---|
| 3498 | uppercase = pCaseLists.getaprop(#uppercase) |
|---|
| 3499 | |
|---|
| 3500 | repeat with i = length(aString) down to 1 |
|---|
| 3501 | pos = getPos(lowercase, char i of aString) |
|---|
| 3502 | if pos > 0 then |
|---|
| 3503 | put uppercase[pos] into char i of aString |
|---|
| 3504 | end if |
|---|
| 3505 | end repeat |
|---|
| 3506 | |
|---|
| 3507 | return aString |
|---|
| 3508 | |
|---|
| 3509 | end |
|---|
| 3510 | |
|---|
| 3511 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3512 | |
|---|
| 3513 | on mLowerCase me, aString |
|---|
| 3514 | |
|---|
| 3515 | if not(listP(pCaseLists)) then mCreateCaseLists me |
|---|
| 3516 | |
|---|
| 3517 | lowercase = pCaseLists.getaprop(#lowercase) |
|---|
| 3518 | uppercase = pCaseLists.getaprop(#uppercase) |
|---|
| 3519 | |
|---|
| 3520 | repeat with i = length(aString) down to 1 |
|---|
| 3521 | pos = getPos(uppercase, char i of aString) |
|---|
| 3522 | if pos > 0 then |
|---|
| 3523 | put lowercase[pos] into char i of aString |
|---|
| 3524 | end if |
|---|
| 3525 | end repeat |
|---|
| 3526 | |
|---|
| 3527 | return aString |
|---|
| 3528 | end |
|---|
| 3529 | |
|---|
| 3530 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3531 | |
|---|
| 3532 | on mCreateCaseLists me |
|---|
| 3533 | |
|---|
| 3534 | pCaseLists = [:] |
|---|
| 3535 | |
|---|
| 3536 | if the platform contains "Macintosh" then |
|---|
| 3537 | vA = numToChar(229) |
|---|
| 3538 | else |
|---|
| 3539 | vA = numToChar(194) |
|---|
| 3540 | end if |
|---|
| 3541 | |
|---|
| 3542 | -- pUPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZZÃÃ"&vA& "ÃÃÃ |
|---|
| 3543 | ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃâ¬ÃÃÃÅÅž" |
|---|
| 3544 | -- pLowercase = "abcdefghijklmnopqrstuvwxyzáà "&"â"&"ÀãåçéÚêëÃìîïñóòÎöõúùûÌÊÞÅÿ" |
|---|
| 3545 | pCaseLists.setaprop(#uppercase, ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Ã", "Ã", vA, "A", "Ã", "Ã", "Ã |
|---|
| 3546 | ", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "Ã", "U", "Ã", "Ã", "Ã", "Å", "Åž"]) |
|---|
| 3547 | pCaseLists.setaprop(#lowercase, ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "á", "à ", vA, "â", "À", "ã", "Ã¥", "ç", "é", "Ú", "ê", "ë", "Ã", "ì", "î", "ï", "ñ", "ó", "ò", "ÃŽ", "ö", "õ", "ú", "ù", "û", "ÃŒ", "Ê", "Þ", "Å", "ÿ"]) |
|---|
| 3548 | |
|---|
| 3549 | end |
|---|
| 3550 | |
|---|
| 3551 | |
|---|
| 3552 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3553 | |
|---|
| 3554 | on mStripFunnyCharsFromFileName me, theFileName |
|---|
| 3555 | |
|---|
| 3556 | offs = offset(" ", theFileName) |
|---|
| 3557 | repeat while offs > 0 |
|---|
| 3558 | put "_" into char offs of theFileName |
|---|
| 3559 | offs = offset(" ", theFileName) |
|---|
| 3560 | end repeat |
|---|
| 3561 | |
|---|
| 3562 | offs = offset("/", theFileName) |
|---|
| 3563 | repeat while offs > 0 |
|---|
| 3564 | put "_" into char offs of theFileName |
|---|
| 3565 | offs = offset("/", theFileName) |
|---|
| 3566 | end repeat |
|---|
| 3567 | |
|---|
| 3568 | offs = offset(":", theFileName) |
|---|
| 3569 | repeat while offs > 0 |
|---|
| 3570 | put "_" into char offs of theFileName |
|---|
| 3571 | offs = offset(":", theFileName) |
|---|
| 3572 | end repeat |
|---|
| 3573 | |
|---|
| 3574 | offs = offset("\", theFileName) |
|---|
| 3575 | repeat while offs > 0 |
|---|
| 3576 | put "_" into char offs of theFileName |
|---|
| 3577 | offs = offset("\", theFileName) |
|---|
| 3578 | end repeat |
|---|
| 3579 | |
|---|
| 3580 | offs = offset("&", theFileName) |
|---|
| 3581 | repeat while offs > 0 |
|---|
| 3582 | put "_" into char offs of theFileName |
|---|
| 3583 | offs = offset("&", theFileName) |
|---|
| 3584 | end repeat |
|---|
| 3585 | |
|---|
| 3586 | return theFileName |
|---|
| 3587 | |
|---|
| 3588 | end |
|---|
| 3589 | |
|---|
| 3590 | |
|---|
| 3591 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3592 | |
|---|
| 3593 | on mRemoveWhiteSpaces me, theText |
|---|
| 3594 | |
|---|
| 3595 | if mCheckForXtra(me, "Pregex") = 1 then |
|---|
| 3596 | |
|---|
| 3597 | theText = [theText] |
|---|
| 3598 | PRegEx_Replace(theText, "\s" , "g", "") |
|---|
| 3599 | return theText[1] |
|---|
| 3600 | |
|---|
| 3601 | else |
|---|
| 3602 | whitespaces = [" ", RETURN] |
|---|
| 3603 | repeat with ws = count(whitespaces) down to 1 |
|---|
| 3604 | theText = mReplaceChunk(me, theText, whitespaces[ws], "") |
|---|
| 3605 | end repeat |
|---|
| 3606 | end if |
|---|
| 3607 | |
|---|
| 3608 | return theText |
|---|
| 3609 | |
|---|
| 3610 | end |
|---|
| 3611 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3612 | |
|---|
| 3613 | -- using offset() -> no pregex |
|---|
| 3614 | on mReplaceChunk me, srcText, fromChunk, toChunk |
|---|
| 3615 | |
|---|
| 3616 | stelle = offset(fromChunk, srcText) |
|---|
| 3617 | |
|---|
| 3618 | if stelle then |
|---|
| 3619 | |
|---|
| 3620 | len = fromChunk.length |
|---|
| 3621 | newtext = "" |
|---|
| 3622 | replText = toChunk |
|---|
| 3623 | |
|---|
| 3624 | repeat while stelle |
|---|
| 3625 | |
|---|
| 3626 | if stelle > 1 then put char 1 to (stelle - 1) of srcText & replText after newtext |
|---|
| 3627 | else put replText after newtext |
|---|
| 3628 | |
|---|
| 3629 | delete char 1 to (stelle + len - 1) of srcText |
|---|
| 3630 | |
|---|
| 3631 | stelle = offset(fromChunk, srcText) |
|---|
| 3632 | |
|---|
| 3633 | if stelle = 0 then put srcText after newtext |
|---|
| 3634 | |
|---|
| 3635 | end repeat |
|---|
| 3636 | |
|---|
| 3637 | else -- no match |
|---|
| 3638 | |
|---|
| 3639 | return srcText |
|---|
| 3640 | end if |
|---|
| 3641 | |
|---|
| 3642 | return newtext |
|---|
| 3643 | end |
|---|
| 3644 | |
|---|
| 3645 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3646 | |
|---|
| 3647 | on mFindUnixAppInPath me, whichBinaryName |
|---|
| 3648 | |
|---|
| 3649 | binaryPath = mDoShellCmd(me, "which" && whichBinaryName, RETURN, 0, 1) |
|---|
| 3650 | if count(binaryPath) < 1 then |
|---|
| 3651 | binaryPath = mDoShellCmd(me, "for thisBinPath in /usr/bin /bin /usr/sbin /sbin /usr/local/sbin /usr/local/bin /opt/sbin /opt/bin /opt/local/sbin /opt/local/bin /sw/bin /sw/sbin ; do if [ -d $thisBinPath ]; then find $thisBinPath -name " & whichBinaryName & "; fi ; done", RETURN, 0, 1) |
|---|
| 3652 | end if |
|---|
| 3653 | cnt = count(binaryPath) |
|---|
| 3654 | if cnt > 0 then |
|---|
| 3655 | repeat with n = 1 to cnt |
|---|
| 3656 | if count(mDoShellCmd(me, "if [ -e" && binaryPath[n] && "]; then echo 1; fi", RETURN, 0, 1)) > 0 then return binaryPath[n] |
|---|
| 3657 | end repeat |
|---|
| 3658 | end if |
|---|
| 3659 | |
|---|
| 3660 | return "" |
|---|
| 3661 | |
|---|
| 3662 | end |
|---|
| 3663 | |
|---|
| 3664 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 3665 | |
|---|
| 3666 | on getCastlibList me, selectionList, defaultCLNum |
|---|
| 3667 | |
|---|
| 3668 | castlibList = 0 |
|---|
| 3669 | |
|---|
| 3670 | if symbolP(selectionList) then |
|---|
| 3671 | -- #all |
|---|
| 3672 | clnum = the number of castlibs |
|---|
| 3673 | castlibList = [] |
|---|
| 3674 | repeat with n = 1 to clnum |
|---|
| 3675 | castlibList.add(n) |
|---|
| 3676 | end repeat |
|---|
| 3677 | |
|---|
| 3678 | else |
|---|
| 3679 | |
|---|
| 3680 | selectionList = string(selectionList) |
|---|
| 3681 | if length(selectionList) > 0 then |
|---|
| 3682 | |
|---|
| 3683 | offs = offset("'", selectionList) |
|---|
| 3684 | repeat while offs > 0 |
|---|
| 3685 | put QUOTE into char offs of selectionList |
|---|
| 3686 | offs = offset("'", selectionList) |
|---|
| 3687 | end repeat |
|---|
| 3688 | |
|---|
| 3689 | if char 1 of selectionList <> "[" then put "[" before selectionList |
|---|
| 3690 | if the last char of selectionList <> "]" then put "]" after selectionList |
|---|
| 3691 | |
|---|
| 3692 | selectionList = value(selectionList) |
|---|
| 3693 | if listP(selectionList) then |
|---|
| 3694 | clnum = the number of castlibs + 1 |
|---|
| 3695 | castlibList = [] |
|---|
| 3696 | selectionListCnt = count(selectionList) |
|---|
| 3697 | repeat with n = 1 to selectionListCnt |
|---|
| 3698 | |
|---|
| 3699 | cl = castlib(selectionList[n]) |
|---|
| 3700 | if ilk(cl) = #castlib then |
|---|
| 3701 | int = cl.number |
|---|
| 3702 | if castlibList.getPos(int) < 1 then |
|---|
| 3703 | castlibList.add(int) |
|---|
| 3704 | end if |
|---|
| 3705 | else |
|---|
| 3706 | int = integer(selectionList[n]) |
|---|
| 3707 | if integerP(int) then |
|---|
| 3708 | if clnum > int then |
|---|
| 3709 | if castlibList.getPos(int) < 1 then castlibList.add(int) |
|---|
| 3710 | end if |
|---|
| 3711 | end if |
|---|
| 3712 | end if |
|---|
| 3713 | end repeat |
|---|
| 3714 | end if |
|---|
| 3715 | end if |
|---|
| 3716 | end if |
|---|
| 3717 | |
|---|
| 3718 | if not(listP(castlibList)) then castlibList = [] |
|---|
| 3719 | |
|---|
| 3720 | if count(castlibList) < 1 then |
|---|
| 3721 | if ilk(defaultCLNum) = #integer then |
|---|
| 3722 | castlibList.add(defaultCLNum) |
|---|
| 3723 | else if listP(defaultCLNum) then |
|---|
| 3724 | castlibList = defaultCLNum |
|---|
| 3725 | end if |
|---|
| 3726 | end if |
|---|
| 3727 | |
|---|
| 3728 | return castlibList |
|---|
| 3729 | end |
|---|