w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How can I resolve "Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query." error?
use datediff select case when PhaseEnd is not null then round(datediff(day, PhaseStart, PhaseEnd)/30,1) else round(datediff(day, PhaseStart, getdate())/30,1) end as Months from tblT_PHASES or select round( datediff(day, PhaseStart, isnull(PhaseEnd, getdate())) / 30 , 1) as Months from tblT_PHASES

Categories : Sql Server

How to stop implicit conversion to virtual function
If you do not want your derived classes to override the function then there is no reason why you should mark it virtual in base class. The very basis of marking a function virtual is to have polymorphic behavior through derived class function overidding. Good Read: When to mark a function in C++ as a virtual? If you want your code to guard you against accidental overidding in derived classes.You can use the final specifier in C++11.

Categories : C++

How to make two function parameters as implicit
According to the SLS 6.23 Anonymous Functions implicit keyword is allowed only for single argument functions: Expr ::= (Bindings | [‘ implicit ’] id | ‘_’) ‘=>’ Expr ResultExpr ::= (Bindings | ([‘ implicit ’] id | ‘_’) ‘:’ CompoundType) ‘=>’ Block So you can't make two function parameters as implicit. This is the one of reasons to use curried functions: object Wrapper { def apply(block: TypeA => TypeB => String) = ??? } Wrapper { implicit a => implicit b => functionThatUseImplicitAB() }

Categories : Scala

Implicit argument conversion ambiguity in non-member functions overloads with std::function?
You did not provide self-contained repro so it's hard to say what's wrong. But here are a couple of guesses: You have a bug in compiler (unlikely) You don't call character overload properly. You should call it like that: myFunc('c'). You provided incorrect calling code or incorrect method signature(s). I guess following code snippet should explain what should be happening and how to declare and call methods properly. Note myOtherFunc trick with capturing literal. It can be done better w/o template function, with smart wrapper around string, but I'll leave that out. You can also try it on your compiler and see if it works, then we'll know if you have compiler problem. Live code: http://codepad.org/gzB7xWs2 #include <string> #include <iostream> using namespace std; voi

Categories : C++

Type of a function with Implicit parameters in Scala
The problem is that foo is a method, not a function, and eta-expansion (which converts methods to functions) is not attempted until after implicit application. See section 6.26.2 of the language specification for the details, and this issue for additional discussion. One workaround would be to write something like this: provideCtx((ctx: ExecutionContext) => (a: Int) => foo(a)(ctx)) I'm not sure a more generic solution is possible (at least without some kind of reflection, etc.), since we can't even refer to foo (except in a method call, of course) without an implicit in scope.

Categories : Scala

How do you create scala anonymous function with multiple implicit parameters
You're currying the function inside run2 so run2 still needs a non-curried function. See the code below for a version that works: object Main extends App { type fType = (Object, String, Long) => Object type fType2 = Object => String => Long => Object //curried def run1( f: fType ) { f( new Object, "Second Param", 3) } // Won't work, language spec doesn't allow it run1 { implicit (p1, p2, p3) => println(p1) println(p2) println(p3) new Object() } def run2( f: fType2 ) { f(new Object)("Second Param")(3) } run2 { implicit p1 => implicit p2 => implicit p3 => println(p1) println(p2) println(p3) new Object() } }

Categories : Scala

Is it inefficient to use implicit array creation (a.k.a. shorthand or literal notation) in loops or function parameters?
Performance wise, the difference will be negligible, but implicit creation is usually slightly slower but implicit is far more readable which is more important long term unless you're dealing with some sort of massive scaling problem. Edit: Wrote a quick test script, and I get completely different results. I'd say both are so close, it shouldn't matter, but run the test on your system. I'm running this on a Macbook Pro with CF10, it may vary with your specific implementation. Maybe the resulting java byte output might reveal any structural differences between the two methods. <cfset iterations = 1000000> <cfset start = getTickCount()> <cfloop from="1" to="#iterations#" index="x"> <cfset a[x] = arrayNew(1)> <cfset a[x][1] = x> <cfset a[x][2]

Categories : Arrays

Byte order conversion with mysql native function
For C you can use ntohl() to convert 32bit (that is 4 bytes) integers to host byte order. Its prototype should reside in <arpa/inet.h>. Update The ntoh/hton family of functions is defined by the POSIX standard. It converts network byte order to host bytes order and verse visa. Network byte order is defined to be Big Endian.

Categories : C++

Getting conversion failed error even when CONVERT function is not being called SQL
You can work around this problem by re-formulating your query condition like this: declare @query as varchar(20)='blah' SELECT * FROM testtable WHERE ISDATE(@query) = 0 OR CONVERT(date, dateofbirth) = CASE ISDATE(@query) WHEN 1 THEN CONVERT(date, @query) ELSE NULL END Demo on sqlfiddle. The problem is that logic operators are not short-circuited in SQL, so the optimizer treats CONVERT(date, @query) as something that it can pre-compute to speed up the query. By expanding the condition to a CASE that depends entirely on @query you can eliminate the execution of the CONVERT branch when ISDATE(@query) returns "false".

Categories : Sql Server

Php mysql query and foreach does not work inside function; but outside function the same code works
function vatRates () { $something = "test"; echo $something; global $db; /* Your sql code and foreach goes here*/ } or function vatRates ($db) { $something = "test"; echo $something; /* Your sql code and foreach goes here*/ }

Categories : PHP

function executed by .apply() works with array, but does not the original function
Your function only accepts one argument (numArray), not three—this is why your call to getMaxOfArray is failing. If you are writing a one-liner, you should use call instead of apply for a series of parameters rather than an array, as so: Math.max.apply(null, [1, 3, 9]); Math.max.call(null, 1, 3, 9); For a function, you can use the arguments object for a variable number of parameters, if you do not want the user to pass an array. Here's how you would go about doing it this way. (Note that I still call apply here, because I store all of the arguments called by the user into an array.) function getMaxOfArguments() { var parameters = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; return Math.max.apply(null, parameters); } Now, your second function call should wo

Categories : Javascript

Why does Function have both implicit and explicit prototype references, and can I set the implicit reference?
Consider the diagram from the specification, and the code below it, which tries to reproduce what's going on: function CF() {}; // the constructor CF.P1 = 'foo'; // P1 is an own property of the constructor; P2 is the same var CFp = { CRP1: 'bar' }; // for now, just an object, with a CRP1 property CF.prototype = CFp // set CFp as the 'explicit prototype property' of CF; // only constructors have such a property var cf1 = new CF(); // an instance; var cf2 = new CF(); // another instance; cf3..cf5 are constructed the same way Object.getPrototypeOf(cf1); // CFp; this is the 'implicit prototype link' from cf1 to CFp; // put another way, CFp became the [[Prototype]] of cf1 You

Categories : Javascript

How to pass parameters to a javascript function from the element that calls the function?
yes you do something like this JAVASCRIPT: var elements = document.getElementsByClassName('data-item'); var mouseoverHandler = function() { var name = this.getElementsByClassName('name')[0].textContent, tel = this.getElementsByClassName('tel')[0].textContent; alert('Name - ' + name + " Tel - " + tel); } for( var i = 0; i < elements.length; i++ ) { var current = elements[i]; current.addEventListener('mouseover', mouseoverHandler); } HTML MARKUP: <li id="item1" class="data-item"> <a href="some link"> <span class="hideme">name</span> </a> <p class="hideme"> <span class="name">John Smith</span> <strong class="tel">555-666-777</strong> </p> </li>

Categories : Javascript

How to pass a variable to a function that's part of the parameters of a function call?
This is a little more complicated than you might think, as you must ensure you pass the right value of i, so that the callback doesn't use the value of end of loop. for (var i = 0; i < json.length; i++) { (function(i){ $.Mustache.load('/mustaches.php', function() { // use i. Call a function if necessary //Do Something }); })(i); } About the callback term : it refers to a function you pass as argument so that the function you call can call it back. To understand the code I wrote, you must understand that the callback is called later, when the loop has finished and so when i in the loop has the value of end of loop that the scope of a non global variable is the function call in which it is defined. That's why there's this intermediate

Categories : Javascript

Can I create a function in PHP that works as a system function (as echo,die, etc)
Actually, you need to make a module with your function. Other ways: make autoload. http://www.php.net/manual/en/language.oop5.autoload.php put only this function to other file and include it everytime you need.

Categories : PHP

Source a file within a function takes function parameters
EDIT: Based on your comment and edited question: #!/bin/bash # bar.sh function f() { # save $1 arg1="$1" # unset $1 shift # source your script; prints default source ./foo.sh # restore $1 set -- $arg1 # should print bar echo $1 echo "Do something else with $1, after foo.sh is sourced." } f bar

Categories : Bash

Use of prototype to add a property to a function causes the function parameters to become undefined
Your closure attempt suffers from the fact that the only way to create a new variable scope in JavaScript is to invoke a function. While you are creating a function in the loop, all the functions are being created in the same variable scope. To remedy this, you need to invoke a function in every iteration of the loop, pass in the value that needs to be held in that new variable scope, and create the callback function in that same scope. That way each function created in the loop is created in a unique function scope. The clearest way IMO to do this is to move the code that needs the scope into a new function, and invoke it in the loop. struct.PortionsUsed = struct.PortionsUsed.sort(); i = 0; while (i < struct.PortionsUsed.length) { j = i + 1; while (j < struct.Portions

Categories : Javascript

passing callback function and parameters to a javascript function
You would just pass in the function reference. You don't want to call the function by ending it will () while passing the callback, instead of the function reference the call back would end up being the result of the function (if nothing is returned it will be undefined). populatePlatforms inside getAvailablePlatforms: function (platform, callback) { So you would want to go with: helper.getAvailablePlatforms('', this.populatePlatforms); For passing in the context use ecmascript5 function.prototype.bind function. helper.getAvailablePlatforms('', this.populatePlatforms.bind(this));

Categories : Javascript

pass c++ function that contains struct to C# and convert it to c# function with Marshal.PtrToStructure
On the C++ side, you need to wrap everything in extern "C", including the struct: extern "C" { struct a { int i; }; }; On the C# side, you'll need to specify the calling convention properly: [DllImport("library.dll", CallingConvention=CallingConvention.Cdecl))] public static extern a1 retNumber(); Once you do that, there is no need for the Marshal.PtrToStructure call. Just do: a1 test = retNumber(); Console.WriteLine(a1.i); // Should print 22

Categories : C#

shared_ptr : "call of an object of a class type without appropriate operator() or conversion function to pointer-to-function type"
boost::shared_ptr<A> ptrA(new A); Calls conversion constructor which converts A* into the shared_ptr. This is a default way to construct the ptr. ptrA(new A); Calls operator(). This is used for a lot of reasons, one being to make objects emulate functions, i.e functors. But this is not used with shared_ptr. The constructor exists, operator() doesnt.

Categories : C++

Passing a function with parameters as parameter of another function
To pass a function to be executed with arguments, you can use a lambda. The lambda is passed as the parameter func. Example: (this is the invocation of caller - text, who, dowhat, and mycode are parameters/variables. the lambda still has access to who, dowhat, and mycode because of closures) caller(text, function () { whathappen(who, dowhat, mycode); }); As for "would that anonymous func. called twice?", if I understand what you mean, no. Maybe you have seen syntax like (function () { ... })(); Which is a lambda that is called immediately after creation (notice the parenthesis at the end "invoking" the lambda). In the first example, you are only creating and passing the anonymous function (functions are first class objects in Javascript).

Categories : Javascript

Convert javascript function to c function for loadrunner scripting
Reproduce the code in LoadRunner (if Necessary). Since this is a client-side captcha and not a server-side captcha you may have to do nothing since the value is not received from nor passed to the server and all it serves is to be a local gatekeeper before the next request is made. As you have already recorded the next request, which would be the result of a positive captcha then you may have to do nothing except run the script again, not withstanding any other non-captcha dynamic data which needs to be in place to execute the next page.

Categories : Javascript

Convert an asynchronous function to a synchronous function
If you want to put a bunch of tasks in a certain order, you could you the async framework (npm install async). There is a specific feature for synchronizing async functions called "series". It sounds like you are having a problem using both sync and async functions. In that case, I think you should wrap all sync functions in an async function like so function asyncFunc(args, callback){ process.nextTick(function() { callback(syncFunc(args)); }); } Then you should chain them together using the async module. It looks like this may make an asynchronous function synchronous. waitfor on github

Categories : Node Js

Why does my sql not work with the Abs function when it works with the Max function?
In SQL, in "HAVING" statment, you can only use columns defined in "GROUP BY". For other columns, you must use then within Aggregate Functions, which are: - AVG() - Returns the average value - COUNT() - Returns the number of rows - FIRST() - Returns the first value - LAST() - Returns the last value - MAX() - Returns the largest value - MIN() - Returns the smallest value - SUM() - Returns the sum

Categories : Mysql

Node sequelize callback promises expect a function, is there a method for removing declared function with a function call
Omit the parentheses: for (index = 0; index < models.length; index++) { model = models[index]; //don't _invoke_ dropTableCompleteCheck, just _reference_ it model.drop().success(dropTableCompleteCheck); }

Categories : Javascript

how can I call a function from an included .as file when the function is defined as a public function in the parent mxml document?
Hope this will helps. includes.as - included file // ActionScript file public function includedFunction(item:Object):String{ var data = parentFunction(item); //call function from parent mxml return data; } AS3 way (but not bindable) <fx:Script> <![CDATA[ include "includes.as"; public function parentFunction(data:Object):String{ return "Hello From Main MXML"; } ]]> </fx:Script> <s:DataGrid dataProvider="{new ArrayCollection(new Array(1,2,3))}"> <s:columns> <s:ArrayList> <s:GridColumn> <s:itemRenderer> <fx:Component> <s:GridItemRenderer> <s:Label text="{outerDocument['includedFu

Categories : Actionscript

Is implicit function declaration legal in C89?
Is implicit function declaration legal in C89? Yes. From section 3.3.2.2: If the expression that precedes the parenthesized argument list in a function call consists solely of an identifier, and if no declaration is visible for this identifier, the identifier is implicitly declared exactly as if, in the innermost block containing the function call, the declaration extern int identifier(); appeared.

Categories : C

Scala implicit function parameterized
If you will rewrite your implicits like ths: implicit val dble = (x: Int) => x + x implicit val stringer = (x: String) => x + " no not a pity" implicit val myclass = (x: Testimplcl) => new Testimplcl(x.a +1) then you will immediately see the reason for this behavior. Now you have the problem with ambiguous implicit values: scala: ambiguous implicit values: both method conforms in object Predef of type [A]=> <:<[A,A] and value stringer in object ReflectionTest of type => String => String match expected type String => String println(implctest[String]("oh what a pity")) ^ This generally tells you that Predef already defined an implicit function T => T, so it conflicts with your definitions. I will recommend you not to use such general t

Categories : Function

Implicit declaration of function "..." is invalid in C99?
You are not declaring a function; but a instance method, so to call it you must send it as a message to self; [self updatedisplay]; EDIT As @rmaddy pointed out (thanks for that) it is declared as instance method not class method. To make the things clear; - (return_type)instance_method_name.... is called via 'self' or pointer to object instance. + (return_type)class_method_name.... is called directly on the class (static).

Categories : Objective C

Implicit declaration of function '...' is invalid on C99
As the build log says these two symbols are missing: AudioServicesCreateSystemSoundID and AudioServicesPlaySystemSound The simple solution is that it looks like you need to add the "AudioToolbox" framework to your project.

Categories : IOS

Matlab - Check if function handle is a particular function or function type
How about using func2str? If this is an inbuilt function, it should just return a string containing the function name; if it is an anonymous function it should return the anonymous function (including @). h1 = @(x) x.^2; h2 = @mean; str1 = func2str(h1); %str1 = "@(x) x.^2" str2 = func2str(h2); %str2 = "mean" You can also use isequal to compare two function handles (ETA: this will not work to compare two anonymous functions unless one was created as a copy of the other): isequal(h1,@mean); % returns 0 isequal(h2,@mean); % returns 1

Categories : Matlab

Implicit declaration of function 'completionHandler' is invalid in C99
The method argument is called handler and not completionHandler, so you probably want to call handler() inside your method. "completionHandler:" is part of the method signature and is called "label" of the argument , if I remember correctly.

Categories : Objective C

implicit declaration of function '_strnicmp' is invalid in C99
Quite simply, your C runtime doesn't have the function _strnicmp, which is a Microsoft-specific function, not a standard C function. You should remove that #define and use the function strncasecmp, since strncasecmp is a POSIX function, and iOS is POSIX-compliant.

Categories : IOS

Not sure why the compiler is complaining ... implicit declaration of function strchrnul
If you are using gcc compiler, don't use -std=c89 or -std=c99 but rather use -std=gnu89 or -std=gnu99 as strchrnul is a GNU extension.

Categories : C

which option gives me better performance: a variable declaration or an implicit function in iOS
The allocated memory on the heap is the same, i.e. the one required by the UIAlertView instance. The latter would save you a variable declaration on the stack, which is definitely neglectable with respect to the context you're working in. There won't be any noticeable speed improvement, so just stick with good coding style, make a variable and save yourself a headache when reading back your own code.

Categories : Iphone

Add extra arguments to implicit S4 generic for a primitive function
The generic is available as > getGeneric("names") standardGeneric for "names" defined from package "base" function (x) standardGeneric("names", .Primitive("names")) <environment: 0x459c9c0> Methods may be defined for arguments: x Use showMethods("names") for currently available ones. so from the signature you can see that the short answer is that you can't add arguments. You'd definitely not want to create your own function names. A hack would use a package-global variable getOption("pkg_names_ordered") but I wouldn't partake of that solution myself. In some ways the contract set out by names does not say anything about order (for instance, names and numerical indecies are often used to subset; are the numerical indices for the ordered names, or the unordered names?), so y

Categories : R

MySQL interprets system function call as schema function call (Error Code 1305: Function does not exist)
Make sure you are using MySQL 5.6.1 or later. ST_Contains was added in 5.6.1. From the doc you cited: As of MySQL 5.6.1, corresponding versions are available that use precise object shapes. These versions are named with an ST_ prefix. For example, Contains() uses object bounding rectangles, whereas ST_Contains() uses object shapes. Previous versions of MySQL provide a Contains function which uses the MBR of the two geometries, not their exact shape, for the test. This may work for you if you are unable to upgrade MySQL.

Categories : Mysql

gcc inline assembler implicit function declaration on Powerpc arch
According to the C standard (appendix J.5.10), asm is a common language extension. In gcc it is disallowed (together with all gcc extensions), if you use a flag like -std=c90, -std=c99 or -ansi. If you want C99 with gcc extensions, use -std=gnu99 instead.

Categories : C

access variable of a function in another function like function().var in python
The code you posted is rather crude, and without a lot more context it is hard to give you a good advise on how to proceed. What you should at least do is pass data around as arguments and return values instead of using global variables. This makes the code easier to read and test. That is: def regular(c): data = c.rev() ... # Code that you already have return data def data_process(c): data = regular(c) ... # Code that you already have It may or may not be a good idea to use a class here, that depends on what you are trying to accomplish and what your background is.

Categories : Sockets

Passing function pointer to a function + function arguments
Did you read the entire error message? You have some const- and other type mismatches (e. g. a pointer-to-struct instead of void *, etc.) in the signature of the two functions. Function types are compatible only if their signatures match exactly.

Categories : C



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.