Call Functions in CakePHP 3 - cakephp-3.0

Using CakePHP3, I have a dynamic set of customer supplied math functions in the file Operations.php (no class since it's a generic customer supplied for many php aps) and have it saved at src/Utils/. At the heading of my controller under the line "use App/Controller/AppController;" I have the line "use App/Utils/Operations;". When I try to call a function it errors with undefined function. How do I call these functions from a controller?

Related

MATLAB | Invalid syntax for calling function 'cond' on the path. Use a valid syntax or explicitly initialize 'cond' to make it a variable

I want to extract data from a table called cond. As you can see from line 75 in the screenshot shown below, data Diameter corresponding to Drake can be successfully extracted using cond('Drake',:).Diameter.
screenshot
However, when I was trying to write this into a function called findCF(), things went wrong at line 78 with an error message
Invalid syntax for calling function 'cond' on the path. Use a valid
syntax or explicitly initialize 'cond' to make it a variable.
Can anybody tell me how to modify my code?
cond() is the name of a built-in function. Matlab tolerates variables whose names collide with functions, but it can result in weird things like this. In the line that produces the error, Matlab thinks you are trying to call the function cond(), not access the variable cond.
Rename the variable to something else.

How to pass rest parameters as input for a custom function?

I'm currently trying to create a vectorSUM function in google scripts, which would sum up all vectors. I've looked into using the arguments method, but would much rather prefer using a rest parameter like the built in SUM function uses. I keep getting the error "missing formal parameter" this is my code. How would I go about using Optional parameters, as well as rest parameters in a custom function?
function vectorAdd(vector1, [vector2, ...]) {}
The built in SUM function uses
(value1, [value2, ...])
How can I achieve this?

How to access to a function of a controller from inside another controller in Symfony2?

I would like to know how to access to a function of a controller from inside another controller in Symfony2. In fact I have two controllers: "EventgroupeController" and "GroupeController". In the code of the controller "EventgroupeController" I put the instruction below:
return GroupeController::AfficheGroupeAction();
But when I run the code (or let's say the project I am developing), it displays this error message in Symfony2:
ContextErrorException: Runtime Notice: Non-static method Ikproj\GroupeBundle\Controller\GroupeController::AfficheGroupeAction() should not be called statically, assuming $this from incompatible context in C:\wamp\www\Wkayet_project\PFESymfony2\src\Ikproj\GroupeBundle\Controller\EventgroupeController.php line 104
After having a look at this link: How to access a different controller from inside a controller Symfony2 in order to know how to access a different controller from inside a controller in Symfony2, I modified the content of the file services.yml as below:
parameters:
# ikproj_groupe.example.class: Ikproj\GroupeBundle\Example
services:
# ikproj_groupe.example:
# class: %ikproj_groupe.example.class%
# arguments: [#service_id, "plain_value", %parameter%]
controllerservice:
class: Ikproj\GroupeBundle\Controller\GroupeController
Then, I replaced the instruction: return GroupeController::AfficheGroupeAction(); by the lines below:
$yourController = $this->get('controllerservice');
$yourController1 = $yourController::AfficheGroupeAction();
return $yourController1;
But I still see this error message:
ContextErrorException: Runtime Notice: Non-static method Ikproj\GroupeBundle\Controller\GroupeController::AfficheGroupeAction() should not be called statically, assuming $this from incompatible context in C:\wamp\www\Wkayet_project\PFESymfony2\src\Ikproj\GroupeBundle\Controller\EventgroupeController.php line 106
So, my question is: how can I resolve this problem and how can I access to the function AfficheGroupeAction() of the controller "GroupeController" from inside the controller "EventgroupeController"?
An action method must not be static.
$this->get('controllerservice')->youMethod();
Should work !
But with a good "application design", you should not have this need except if you want to forward a request from a controller to another ( example : backward compatibility ). In this case you can use the forward method provided by symfony2 base controller. ( http://symfony.com/doc/current/book/controller.html )

Visual Basic 6 - select appropriate function

I'm working on a visual basic 6 and we have product made of VB6 modules that use each other. Every module has it's own exe.
I'm having a problem when I'm referring to one function in one module, which works, and in another module it doesn't.
For instance, in one module I'm calling the original VB6 Round function which takes following params:
Round(number,0)
But in another module there's a function defined as
Function Round(ByVal X As Variant) As Variant
That should be called as
Round(number)
And that causes a compile time error and it says that function call has a wrong number of parameters, while on other modules where this function is undefined there are no errors.
Now, I could use it, but there are other places where I actually need to specify decimal point precision where I call it as
Round(number,2)
Round(number,3)
etc.
How do I disambiguate between these functions to call only and ONLY the original VB6 rounding function?
I would recommend to avoid such ambiguities by choosing better names for your methods. If you canĀ“t change the method name you can use the full qualified name of the function.
VBA.Math.Round number, 2

tkinter command to call function from another Python script

I am having a few issues, calling Python functions defined in another script using tkinter. I would prefer to have a separate script for my functions that the GUI uses when needed. At the moment I am doing it like this.
ttk.Button(mainframe, text="1", command=one).grid(column=1, row=1, sticky=NW)
def one():
code_entry.insert(END,"1")
The above calls the command one on a button click, which will print the character one in a entry field with the GUI. I thought I could create a separate script to hold my functions and call them like this:
ttk.Button(mainframe, text="1", command=functions.one()).grid(column=1, row=1, sticky=NW)
And then simply add an import statement at the top of my GUI, like below:
import functions
This doesn't work and looking for some advice on how to approach this.
You didn't specify any error messages, but it's most likely that you're doing fuctions.one() - actually calling the one() function of that module before the Button is created. It's simply fixed by removing the () part - when you specify a function without (), you are passing a reference of the function object.
Also keep in mind the scope of the code_entry variable - if you were using it as a module level global before (or function local, if one() was inside the same function as your ttk.Button call), it won't be available when you move it to a new namespace without code_entry.
To solve this you should pass code_entry as a parameter to the callback without calling one() at first. The usual approach for this is creating a lambda - essentially creating a function that works on the same scope of the original one(), having access to variables like code_entry, but also calling a function in a different module.
ttk.Button(mainframe, text="1", command=lambda: functions.one(code_entry))
Note that this is basically the same as:
def some_anonymous_function():
functions.one(code_entry)
ttk.Button(mainframe, text="1", command=some_anonymous_function)
Both examples create a function object and pass that object as reference - the functions.one() call of the lambda is actually inside the body of the lambda function, to be called later by tkinter.
Of course you also have to redefine one() to accept this new parameter:
def one(code_entry):
code_entry.insert(END,"1")