Farbflash projects: Imaging lingo table | 3-D scene list | Find all | Handler menu | Lingo message window

Ignore:
Timestamp:
01/16/08 10:27:16 (4 years ago)
Author:
alex
Message:

transferred bugfixes from trunk version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/beta/castlib1/thisMoviesScript.ls

    r103 r112  
    8787   
    8888   
     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 
    8995   
    9096  ---------------- menu divider for better readability: 
     
    108114        if memref.type = #script then 
    109115           
    110           thisScriptList = mGetScriptHandlerList(memref, kw, searchmode, len) 
     116          thisScriptList = mGetScriptHandlerList(memref, kw, searchmode, len, pCachedResults) 
    111117           
    112118          if count(thisScriptList) > 0 then 
     
    248254-- get a list of all handlers which pass through the filter if any, in the format we need for the menu 
    249255 
    250 on mGetScriptHandlerList memref, kw, searchmode, len 
     256on mGetScriptHandlerList memref, kw, searchmode, len, pCachedResults 
    251257   
    252258  scrtext = string(memref.scripttext) 
     
    262268     
    263269    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       
    264275      -- we cache only the results, if there is no search word 
    265276      -- 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       
    271279      cached = pCachedResults.getaprop(string(memref)) 
    272280      if ilk(cached) = #proplist then 
    273281        theDate = cached.getaprop(#theDate) 
    274         if theDate = memref.modifiedDate then 
     282        -- if theDate = memref.modifiedDate then 
     283        if theDate = scrtext.length then 
    275284          found = 1 
    276285          thisScriptList.setaprop(#items, cached.getaprop(#items)) 
     
    279288        end if 
    280289      end if 
     290       
    281291    end if 
    282292    if found <> 1 then 
    283293      found = mParseScriptText(scrtext, theItems, defaultItem, kw, searchmode, len) 
    284294      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)]) 
    291297      end if 
    292298    end if 
     
    366372end 
    367373 
    368  
    369 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    370 on _____________________PROCESS_COMMAND 
    371 end 
    372 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    373 -- process the command, which was chosen 
    374 -- at this point the command string is stored in the gloabllist, as we come here in an asynch process -> MUI dialog 
    375 -- 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, dto2 
    381    
    382   if ilk(dto) = #timeout then dto.forget() 
    383   if ilk(dto2) = #timeout then dto2.forget() 
    384    
    385   global gRetVal 
    386   glob = call(#mGetGlobalList, mGetXScript()) 
    387    
    388   skipFirstSpace = 0 
    389    
    390   inst = glob.getaprop(#theTargetInstance) 
    391   if ilk(inst) = #instance then 
    392     theMemberName = glob.getaprop(#theMemberName) 
    393     if glob.getaprop(#copy2ClipBoard) = 2 then 
    394        
    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" then 
    398         dostr = "xscr()." & glob.getaprop(#cmd) & "(" 
    399       else 
    400         dostr = "xscr(#" & theMemberName & ")." & glob.getaprop(#cmd) & "(" 
    401       end if 
    402       skipFirstSpace = 1 
    403       del = 0 
    404     else if glob.getaprop(#copy2ClipBoard) = 1 then 
    405       ----------- 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 = 1 
    411     else 
    412       dostr = "call(#" & symbol(glob.getaprop(#cmd)) & ", [inst]," 
    413       del = 1 
    414     end if 
    415      
    416   else 
    417      
    418     if glob.getaprop(#isBehavior) = 1 then 
    419       theParams = glob.getaprop(#theParams) 
    420       sprnum = theParams.getaprop("spritenum") 
    421       if length(string(sprnum)) < 1 then 
    422         sprnum = 0 
    423       else if not(integerP(integer(sprnum))) then 
    424         sprnum = QUOTE & sprnum & QUOTE 
    425       end if 
    426       theParams.deleteprop("spritenum") 
    427        
    428       dostr = "sendSprite(" & sprnum & ", #" & glob.getaprop(#cmd) & "," 
    429       del = 1 
    430     else 
    431       dostr = glob.getaprop(#cmd) & "(" 
    432       skipFirstSpace = 1 
    433       del = 0 
    434     end if 
    435   end if 
    436    
    437   theParams = glob.getaprop(#theParams) 
    438   if theParams.count then 
    439     repeat with thisParam in theParams 
    440        
    441       theVal = value(thisParam) 
    442       if voidP(theVal) then 
    443         if (string(thisParam)).word.count > 0 then 
    444           if skipFirstSpace = 1 then 
    445             put QUOTE&thisParam&QUOTE&"," after dostr 
    446             skipFirstSpace = 0 
    447           else 
    448             put " "&QUOTE&thisParam&QUOTE&"," after dostr 
    449           end if 
    450         else 
    451           put " void," after dostr 
    452         end if 
    453          
    454       else 
    455         if length(string(thisParam)) > 0 then 
    456           if skipFirstSpace = 1 then 
    457             put thisParam&"," after dostr 
    458             skipFirstSpace = 0 
    459           else 
    460             put " "&thisParam&"," after dostr 
    461           end if 
    462         else 
    463           put " void," after dostr 
    464         end if 
    465          
    466       end if 
    467        
    468       del = 1 
    469        
    470     end repeat 
    471      
    472   end if 
    473   if del then delete the last char of dostr 
    474    
    475   put ")" after dostr 
    476    
    477   if (glob.getaprop(#copy2ClipBoard) = 1) or (glob.getaprop(#copy2ClipBoard) = 2) then 
    478     put "theResult = " before dostr 
    479      
    480     member("pastefeld").text = dostr 
    481     copyToClipBoard(member("pastefeld")) 
    482      
    483   else 
    484      
    485     tell the stage 
    486       res = the result 
    487       do dostr 
    488       if the result <> res then 
    489         gRetVal = the result 
    490         if (string(gRetVal)).length < 100 then put gRetVal 
    491         else put "Too many chars to put in the message window. Get the result from the global variable gRetVal"&RETURN&"put gRetVal"&RETURN 
    492       end if 
    493     end tell 
    494   end if 
    495    
    496 end 
    497374 
    498375 
Note: See TracChangeset for help on using the changeset viewer.