--- In [email protected], "brucexs" <bruc...@...> wrote: > > I am not sure how the setwith would work, since there is no variable with the > sig to detect in the syntax that PowerPro sees within the with scope. > As I understand with and ., what should happen is this: after processing the > "with", whenever a . is found where a variable name/expression should have > been, pretend the variable/expression defined in the the ".with" occurred > just before the dot. So > > objRange.Font.With > > .Bold = 1 // interpret as objRange.Font.Bold = 1 > > x = 5 + .Bold // interpret as x = 5+ objRange.Font.Bold
Yes. Another way to see it is more restrictive: whatever comes in as an argument to with is a handle to com object. (objRange.Font.With resolves to with(<handle to com object>); if it didn;t, it would be an error). From then until you encounter an endwith, if you see .something, its the same as if you had encountered <handle to com object>.something > A simple way for powerpro to support your . and "with" would be to provide > a pproservice > ppsv->RegisterWithCallback(&func) > > and then call func(pstr) whenever the bare . is found as above. The callback > func would have to return the latest withed variable/expression in the > passed string buffer pstr (which for simplicity will assume that result is > always <532 chars). In above, the return would be the internal handle you > generate for objRange.Font Okay, so I keep try of <handle to com object>, not you. > You would then receive a further call on that handle with the "bold" argument > just as if obRange.Font.Bold had actually appeared. Sounds doable. > When the end_with is executed, plugin would call > ppsv->RegisterWithcallback(NULL). > > Note that only one with callback could be registered at a time. > > Nested withs could be implemented from within the plugin invisibly to > PowerPro (only call registerwithcallback for outermost one) Okay, so simplest version would only handle one level of with; be up to me to figure out how to remember what needs to be remembered for nesting. > Unfortunately, error handling of omitted end_withs is tricky, especially if > the original with is in a script which quits without a corresponding > end_with. I don't have any simple-to-implement ideas for detecting that > error at script exit. Maybe could do something to help by adding more > arguments to to &func so that if one is registered when a script exits, it > gets called with special flag saying end of script, are there any withs open > from this script. > > To see the issues, consider > > function outer > ... > comvar.With > ... > comvar.prop=3 > inner() > com.end_with > quit > > function inner > myvar.with > quit > > With in inner function is wrong but with in outer function is fine. Yeah, nasty. Callback with flag at end-of-script a good idea. > let me know if you want to go further on this. Yeah, let's.
