Forgot to say. Client Server 1000 tests in under a second with 1600 methods in host or 800 methods in component.
Regards, Wayne [image: --] Wayne Stewart [image: http://]about.me/waynestewart <http://about.me/waynestewart> On 19 April 2017 at 12:07, Wayne Stewart <[email protected]> wrote: > David, > > Using a bit of discipline you can easily set this up > > Create a method in each component like this, just change the suffix on the > method name. > > // ---------------------------------------------------- > > // Project Method: MethodExists_Comp (Method Name) --> Boolean > > > // Checks if a method exists in the component > > > // Access: Shared > > > // Parameters: > > // $1 : Text : The method name to check for in component > > > // Returns: > > // $0 : Boolean : True if the method exists in the component > > > // Created by Wayne Stewart (2017-04-18T14:00:00Z) > > // [email protected] > > // ---------------------------------------------------- > > > > *C_BOOLEAN*(*$0*) > > *C_TEXT*(*$1*) > > > *C_BOOLEAN*($exists_b) > > *C_TEXT*($methodName_t) > > > *ARRAY TEXT*($MethodNames_at;0) > > > $methodName_t:=*$1* > > > *METHOD GET NAMES*($MethodNames_at;$methodName_t) // No * => Component > method > > > $exists_b:=(*Size of array*($MethodNames_at)>0) > > > *$0*:=$exists_b > > > Then you can create a method in the host database like this: > > // ---------------------------------------------------- > > // Project Method: MethodExists (Method Name {; Context}) --> Boolean > > > // Checks if a method exists in the host > > // Optionally you can pass a context > > // Either the component Prefix (eg Find or LBOX etc) > > // or "Host" > > > // Access: Shared > > > // Parameters: > > // $1 : Text : Method Name > > // $2 : Text : Context (optional) > > > // Returns: > > // $0 : Boolean : True if the method exists > > > // Created by Wayne Stewart (2017-04-18T14:00:00Z) > > // [email protected] > > // ---------------------------------------------------- > > > *C_BOOLEAN*(*$0*) > > *C_TEXT*(*$1*;*$2*) > > > *C_BOOLEAN*($exists_b) > > *C_TEXT*($methodName_t;$Context_t;$CmptMethodExists_t) > > > *ARRAY TEXT*($MethodNames_at;0) > > > $methodName_t:=*$1* > > $Context_t:="Host" > > > *If *(*Count parameters*=2) > > $Context_t:=*$2* > > *End if * > > > *If *($Context_t="Host") > > *METHOD GET NAMES*($MethodNames_at;$methodName_t;*) // * => Check host > methods (which it would do anyway) > > $exists_b:=(*Size of array*($MethodNames_at)>0) > > > *Else * > > $CmptMethodExists_t:="MethodExists_"+$Context_t > > *EXECUTE METHOD*($CmptMethodExists_t;$exists_b;$methodName_t) > > > *end if* > > > *$0*:=$exists_b > > > > > > > Regards, > > Wayne > > > [image: --] > Wayne Stewart > [image: http://]about.me/waynestewart > <http://about.me/waynestewart> > > > On 19 April 2017 at 09:36, David Adams <[email protected]> wrote: > >> Hey Wayne, >> >> Thanks for the idea. I like the way you flip things around from how I >> think, it's great. In this case, your suggestion doesn't apply, but I'm >> adding your suggestion to your other idea about manufactured methods to my >> "things to think about" list. >> >> Anyway, I haven't explained my constraints clearly enough to give you a >> chance to help. Rather than waste more of your time, I'll explain more >> about my circumstances. I'm using CALL FORM and CALL WORKER. These accept a >> window reference or worker reference, a method name, and (optionally) >> method parameters. >> >> The recipient identifier (window or worker) ways *where* to run the >> code. >> The method name says *what* code to run. >> The parameters work just like with new process, etc, they get fed into >> the instance of the method that runs. >> >> The method name has to be a method name - but 4D treats it as a string. >> There is no validation done when you make the call. >> >> CALL PROCESS("MyWonderfulWorker";"D'oh! No Such Method Exists") >> >> There's no error set here, no OK variable, etc. It's on the *recipient* >> side that you run into trouble. 4D takes the string and adds it to the end >> of the code stack (whatever you call that) in the target's context. So, if >> it's a worker, your method call is added to the end of that process and run >> once any existing code finishes. Same with a worker, your code is appended >> there. What happens after that is just like what would happen if you ran an >> EXECUTE in that context by hand. Namely, you get an error if you run a bad >> method name. >> >> So, the error is caused by the sender but occurs in the recipient. There >> is *no* On Call Received-like event/function/method/hook on the recipient >> side to inspect the code before it's run. That's all under the hood. 4D >> checks it and tosses an error, if the method name is bad. If I want to >> prevent bad calls from being sent, I need to error check the method name on >> the *sender* side. My component is acting as a message hub for a >> publish-subscribe system (I'll show it to you when I see you in May), which >> makes is an entirely sensible place to do the validation. >> >> Okay, that's more background. So what I need to check for when it comes >> to method names: >> >> * The method exists. >> * The method exists in the right context (component or host) >> * The method name is unique in the component and host. >> >> Possible outcomes if you don't check these things are: >> >> a) There's no problem and 4D runs the code. (The method name exists and >> is unique.) >> b) 4D throws an error because the method name doesn't exist. >> c) 4D runs the wrong copy (in the component) because of a redundant name. >> >> My goal is to find an efficient way to know if a method name call >> originating from a component is safe. >> >> > ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

