Changeset 112 for branches/beta/castlib1/thisMoviesScript.ls
- Timestamp:
- 01/16/08 10:27:16 (4 years ago)
- File:
-
- 1 edited
-
branches/beta/castlib1/thisMoviesScript.ls (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/beta/castlib1/thisMoviesScript.ls
r103 r112 87 87 88 88 89 -- cache the results in order to avoid parsing the same script over and over 90 pCachedResults = xscr().mGetGlobalValue(#pCachedResults) 91 if ilk(pCachedResults) <> #proplist then 92 pCachedResults = [:] 93 xscr().mSetGlobalValue(#pCachedResults, pCachedResults) 94 end if 89 95 90 96 ---------------- menu divider for better readability: … … 108 114 if memref.type = #script then 109 115 110 thisScriptList = mGetScriptHandlerList(memref, kw, searchmode, len )116 thisScriptList = mGetScriptHandlerList(memref, kw, searchmode, len, pCachedResults) 111 117 112 118 if count(thisScriptList) > 0 then … … 248 254 -- get a list of all handlers which pass through the filter if any, in the format we need for the menu 249 255 250 on mGetScriptHandlerList memref, kw, searchmode, len 256 on mGetScriptHandlerList memref, kw, searchmode, len, pCachedResults 251 257 252 258 scrtext = string(memref.scripttext) … … 262 268 263 269 if len < 1 then 270 271 ----------- unfortunately the modified date doesn't work at all so we can't cache by modified date 272 ----------- we cache instead by scripttext length, which will fail only if the bad chance happens, 273 ----------- that the modification is exactly the same length as the original 274 264 275 -- we cache only the results, if there is no search word 265 276 -- otherwise we would need to cache the result for every different searchword 266 pCachedResults = xscr().mGetGlobalValue(#pCachedResults) 267 if ilk(pCachedResults) <> #proplist then 268 pCachedResults = [:] 269 xscr().mSetGlobalValue(#pCachedResults, pCachedResults) 270 end if 277 278 271 279 cached = pCachedResults.getaprop(string(memref)) 272 280 if ilk(cached) = #proplist then 273 281 theDate = cached.getaprop(#theDate) 274 if theDate = memref.modifiedDate then 282 -- if theDate = memref.modifiedDate then 283 if theDate = scrtext.length then 275 284 found = 1 276 285 thisScriptList.setaprop(#items, cached.getaprop(#items)) … … 279 288 end if 280 289 end if 290 281 291 end if 282 292 if found <> 1 then 283 293 found = mParseScriptText(scrtext, theItems, defaultItem, kw, searchmode, len) 284 294 if len < 1 then 285 pCachedResults = xscr().mGetGlobalValue(#pCachedResults) 286 if ilk(pCachedResults) <> #proplist then 287 pCachedResults = [:] 288 xscr().mSetGlobalValue(#pCachedResults, pCachedResults) 289 end if 290 pCachedResults.setaprop(string(memref), [#theDate:memref.modifiedDate, #items:duplicate(theItems)]) 295 -- pCachedResults.setaprop(string(memref), [#theDate:memref.modifiedDate, #items:duplicate(theItems)]) 296 pCachedResults.setaprop(string(memref), [#theDate:scrtext.length, #items:duplicate(theItems)]) 291 297 end if 292 298 end if … … 366 372 end 367 373 368 369 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx370 on _____________________PROCESS_COMMAND371 end372 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx373 -- process the command, which was chosen374 -- at this point the command string is stored in the gloabllist, as we come here in an asynch process -> MUI dialog375 -- the command and the paramaters are stored in the global list which we get with: call(#mGetGlobalList, mGetXScript())376 -------- the command string is glob.getaprop(#cmd)377 -------- the parameters are in glob.getaprop(#theParams)378 379 380 on mDoCmd dto, dto2381 382 if ilk(dto) = #timeout then dto.forget()383 if ilk(dto2) = #timeout then dto2.forget()384 385 global gRetVal386 glob = call(#mGetGlobalList, mGetXScript())387 388 skipFirstSpace = 0389 390 inst = glob.getaprop(#theTargetInstance)391 if ilk(inst) = #instance then392 theMemberName = glob.getaprop(#theMemberName)393 if glob.getaprop(#copy2ClipBoard) = 2 then394 395 ----------- alex syntax (I have my own "global handler" to create scriptinstances differently):396 -- dostr = "call(#" & symbol(glob.getaprop(#cmd)) & ", mGetXscript(#" & theMemberName & "),"397 if string(theMemberName) = "commonMovieScript" then398 dostr = "xscr()." & glob.getaprop(#cmd) & "("399 else400 dostr = "xscr(#" & theMemberName & ")." & glob.getaprop(#cmd) & "("401 end if402 skipFirstSpace = 1403 del = 0404 else if glob.getaprop(#copy2ClipBoard) = 1 then405 ----------- standard syntax, create new script instance for each call (this is NOT the optimized way !)406 dostr = "call(#" & symbol(glob.getaprop(#cmd)) & ", new(script " & QUOTE & theMemberName & QUOTE & "),"407 408 ----------- better: store the intsance in a variable and reuse it (you will need to delete the new(script foo) lines)409 -- dostr = "theScriptInstance = new(script " & QUOTE & theMemberName & QUOTE & ")" & RETURN & "call(#" & symbol(glob.getaprop(#cmd)) & ", theScriptInstance,"410 del = 1411 else412 dostr = "call(#" & symbol(glob.getaprop(#cmd)) & ", [inst],"413 del = 1414 end if415 416 else417 418 if glob.getaprop(#isBehavior) = 1 then419 theParams = glob.getaprop(#theParams)420 sprnum = theParams.getaprop("spritenum")421 if length(string(sprnum)) < 1 then422 sprnum = 0423 else if not(integerP(integer(sprnum))) then424 sprnum = QUOTE & sprnum & QUOTE425 end if426 theParams.deleteprop("spritenum")427 428 dostr = "sendSprite(" & sprnum & ", #" & glob.getaprop(#cmd) & ","429 del = 1430 else431 dostr = glob.getaprop(#cmd) & "("432 skipFirstSpace = 1433 del = 0434 end if435 end if436 437 theParams = glob.getaprop(#theParams)438 if theParams.count then439 repeat with thisParam in theParams440 441 theVal = value(thisParam)442 if voidP(theVal) then443 if (string(thisParam)).word.count > 0 then444 if skipFirstSpace = 1 then445 put QUOTE&thisParam"E&"," after dostr446 skipFirstSpace = 0447 else448 put " ""E&thisParam"E&"," after dostr449 end if450 else451 put " void," after dostr452 end if453 454 else455 if length(string(thisParam)) > 0 then456 if skipFirstSpace = 1 then457 put thisParam&"," after dostr458 skipFirstSpace = 0459 else460 put " "&thisParam&"," after dostr461 end if462 else463 put " void," after dostr464 end if465 466 end if467 468 del = 1469 470 end repeat471 472 end if473 if del then delete the last char of dostr474 475 put ")" after dostr476 477 if (glob.getaprop(#copy2ClipBoard) = 1) or (glob.getaprop(#copy2ClipBoard) = 2) then478 put "theResult = " before dostr479 480 member("pastefeld").text = dostr481 copyToClipBoard(member("pastefeld"))482 483 else484 485 tell the stage486 res = the result487 do dostr488 if the result <> res then489 gRetVal = the result490 if (string(gRetVal)).length < 100 then put gRetVal491 else put "Too many chars to put in the message window. Get the result from the global variable gRetVal"&RETURN&"put gRetVal"&RETURN492 end if493 end tell494 end if495 496 end497 374 498 375
Note: See TracChangeset
for help on using the changeset viewer.
