I am hoping to find a way to do this in vb.net:
Say you have function call getPaint(Color). You want the call to be limited to the parameter values of (red,green,yellow). When they enter that parameter, the user is provided the available options, like how a boolean parameter functions.
Any ideas?
...
How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?
...
The title may not really explain what I'm really trying to get at, couldn't really think of a way to describe what I mean.
I was wondering if it is good practice to check the arguments that a function accepts for nulls or empty before using them. I have this function which just wraps some hash creation like so.
Public Shared Function G...
Using the following query:
SELECT pe.prodtree_element_name_l, MAX(rs.resource_value) AS resource_value
FROM prodtree_element pe
LEFT JOIN resource_shortstrings rs
ON pe.prodtree_element_name_l_rk = rs.resource_key
WHERE rs.language_id = '5'
AND pe.prodtree_element_name_l <> ''
GROUP BY prodtree_elemen...
I want to do something very simple in C++ but i can't find how.
I want to create a function like a for loop where i will ideally enter a variable for the times the iteration should happen and some functions inside brackets my function will execute. I hope i was clear enough. Thanks...
Example
superFor (1)
{
//commands to be executed ...
I have a function that is effectively a replacement for print, and I want to call it without parentheses, just like calling print.
# Replace
print $foo, $bar, "\n";
# with
myprint $foo, $bar, "\n";
In Perl, you can create subroutines with parameter templates and it allows exactly this behavior if you define a subroutine as
sub mypri...
Apparantly, they're "confusing". Is that seriously the reason? Can you think of any others?
...
Could someone explain? I understand the basic concepts behind them but I often see them used interchangeably and I get confused.
And now that we're here, how do they differ from a regular function?
...
Is it possible to call a function from PHP using onsubmit from javascript? If so could someone give me an example of how it would be done?
function addOrder()
{
$con = mysql_connect("localhost", "146687", "password");
if(!$con)
{
die('Could not connect: ' . mysql_error())
}...
We all know that you can overload a function according to the parameters:
int mul(int i, int j) { return i*j; }
std::string mul(char c, int n) { return std::string(n, c); }
Can you overload a function according to the return value? Define a function that returns different things according to how the return value is used:
int n = mul(...
Here is my function (updated):
Public Shared Function shortenUrl(ByVal URL As String) As String
Return shortenUrl(URL, 32)
End Function
Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String
If URL.Length > maxLength Then
String.Format("{0}...{1}", URL.Substring(0, (maxLength / 2)), ...
Hi, I have the following problem using template instantiation [*].
file foo.h
class Foo
{
public:
template <typename F>
void func(F f)
private:
int member_;
};
file foo.cc
template <typename F>
Foo::func(F f)
{
f(member_);
}
file caller.cc
Foo::func(boost::bind(&Bar::bar_func, bar_instance, _1));
While this c...
I have an implicit scalar field defined in 2D, for every point in 2D I can make it compute an exact scalar value but its a somewhat complex computation.
I would like to draw an iso-line of that surface, say the line of the '0' value. The function itself is continuous but the '0' iso-line can have multiple continuous instances and it is n...
I would like to allow the user to enter any equation, like the following, into a text box:
x = x / 2 * 0.07914
x = x^2 / 5
And have that equation applied to telemetry data that is coming from a device connected via a serial port. The incoming data points are represented by x and each data point is processed by the user-specified equa...
Is one more preferred, or performs better over the other?
...
I have a function called FindSpecificRowValue that takes in a datatable and returns the row number that contains a particular value. If that value isn't found, I want to indicate so to the calling function.
Is the best approach to:
Write a function that returns false if not found, true if found, and the found row number as a byref/out...
I'm sure there are a million posts about this out there, but surprisingly I'm having trouble finding something.
I have a simple script where I want to set the onClick handler for an <A> link on initialization of the page.
When I run this I immediately get a 'foo' alert box where I expected to only get an alert when I click on the link...
Is it better to write many small methods (or functions), or to simply write the logic/code of those small processes right into the place where you would have called the small method? What about breaking off code into a small function even if for the time being it is only called from one spot?
If one's choice depends on some criteria, w...
In C++, a function's signature depends partly on whether or not it's const. This means that a class can have two member functions with identical signatures except that one is const and the other is not. If you have a class like this, then the compiler will decide which function to call based on the object you call it on: if it's a cons...
In Python, How do I get the function name as a string without calling the function?
def my_function():
.
.
.
print get_function_name_as_string(my_function) # my_function is not in quotes
output => "my_function"
is this available in python? if not, any idea how to write get_function_name_as_string in python?
...