> > Another bit of syntactic sugar I may already have metnioned: many >languages > that do the dot syntax support with/endwith: > > > objRange.Font.With > .Bold = 1 > .Animation = 3 > .Size = 30 > com.end_with()
> >If you wanted to do this, simplest would be to support a single >level of >with/endwith, probably by providing another callback > > ppsv->SetWith(LPSTR sig, DWORD (*with)(LPSTR han, BOOL bStart)); > > which means you'd have to be watching for > > .method(xxx, ...) > .property[(...)] = x > x = .property[(...)] 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 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 You would then receive a further call on that handle with the "bold" argument just as if obRange.Font.Bold had actually appeared. 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) 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. let me know if you want to go further on this. >
