return-value

Function Should Return Value Question

Given a function like so bool RequestStatus() { ... if (code == myCode) { return true; } else { return false; } } Why would the compiler complain that "Function should return value". Unless I am missing something, how else could it not return true or false? Is it because the value of myCode is runtime...

Returning after throwing exceptions

Is it in any way beneficial to return a value after throwing an exception? If not, can the return statement be left out and is it somehow possible to remove compiler error C4715: not all control paths return a value? Thanks in advance. Edit: (sample code) for (ushort i = 0; i < itsNumUnits; ++i) if (unitFormation[i] == unit) {...

Standard @RETURN_VALUE's are in SQL Server 2005?

Can anyone point me to a list/description of standard @RETURN_VALUES in SQL Server 2005 (if such a thing exists)? I have searched multiple times and can't find any reference. Interestingly, I was debugging a stored procedure earlier today using Visual Studion 2008 and received this in the results--"@RETURN_VALUE = -6". Wondering what ...

recursive method - not all code paths return a value!

it says not all code paths return a value private string Fisrt(string nonTerminal) { for (int j = 0; j < 6; j++) { if (Tokens[j, 0] == nonTerminal) { if (char.IsLower((char)Tokens[j, 3][0])) return (Tokens[j, 3]); else Fis...

Multi-Index Insert Failure Return (Boost)

I'm currently using Boost's multi-index to help keep track of how many times a packet passes through a system. Each time a system touches the packet, its IP address is added to a string, separated by commas. I go through that string then, tokenize it and add each IP found to a multi-index. Since the IPs are set to be unique right now, ...

Why do I have to cast the return parameter value for a SQL query?

I have a method that either adds or updates a record in a DB (SQL Server), and it returns the RecordID as an (Int32) Output Parameter, and a success/failure result as (Int32) Return Value. Given that I'm specifying the type of these parameters, why do I have to cast them when they are returned? I expected to used the following: enquir...

How to return values from a dynamic SQL Stored Procedure to the Entity Framework?

I have a Stored Procedure which executes some dynamic SQL. I want to use this Stored Procedure in entity framework 4, but when I try to create a complex type the procedure returns no columns. Is there any way I can force it to return my values and get the entity framework to receive them? Here is a much-simplified example of what I want ...

How to identify if an object returned was created during the execution of a method - Java

Original Question: Given a method I would like to determine if an object returned is created within the execution of that method. What sort of static analysis can or should I use? Reworked Questions: Given a method I would like to determine if an object created in that method may be returned by that method. So, if I go through and add a...

STL container function return values

When looking over the member functions of the STL containers, an odd thought occurred to me. Why don't functions like std::vector<T>::push_back(T) not have an (optional) return value (iterator or even a reference to the appended object)? I know std::string functions like insert and erase return iterators, but that's for obvious reasons. ...

C# Random.Next suddenly stops returning random values

Possible Duplicate: System.Random keeps on returning the same value I'm refactoring and expanding a small C# agent-based model to help some biology professors predict the spread of a disease. Each year of the simulation each individual agent randomly travels to a nearby population node, possibly spreading the disease. I'm br...

function return not assigned to a variable

What if you call a (non-void) function, but don't assign its return value to a variable? e.g., getchar(); I've always wondered what happens to such a value. I've heard humorous explanations like "its gone to the ether" and so forth, but I'd really like to know really. Would there be any way to recover such a value? Thanks ...

C/C++: which school of reporting function failures is better.

Very often you have a function, which for given arguments can't generate valid result or it can't perform some tasks. Apart from exceptions, which are not so commonly used in C/C++ world, there are basically two schools of reporting invalid results. First approach mixes valid returns with a value which does not belong to codomain of a f...

Value from one view's form to other view

Can I perform in django such operation, that in one view I assign a value of return from other view, that renders its own form template and basing on it returns value ? (So in other words if on this form rendered by the other function user clicks ok, I return true, and if user clicks cancel I return false) Sample code : Main function: ...

Not able to read return value from spamassassin when launched from C# console

Hi! I have a windows server 2008 with a mail server installed. For every emails that comes in, a C# application is launched that pipes the message through a set of optional filters and then decides whether or not to let it throught. I have alrealdy a couple of "homemade" filters implemented but I would like to add one to take advantag...

How to return a string value from a bash function

I'd like to return a string from a bash function. I'll write the example in java to show what I'd like to do: public String getSomeString() { return "tadaa"; } String variable = getSomeString(); The example below works in bash, but is there a better way to do this? function getSomeString { echo "tadaa" } VARIABLE=$(getSomeS...

Return value indicating update success/failure of SQL Server stored procedure via ADO/VBA

I have a SQL Server 2008 stored procedure that updates values in a table. I would like to have the stored procedure return an integer value indicating that the update was successful (return 0) or not (returns error number). What would be the best way to accomplish this via ADO and VBA? Here some of my code in simplified form that perform...

Static method for XMLLoader class... how to return XML data after Event.COMPLETE function?

I am attempting to build a generic XMLLoader class with a static LOAD method, with the intent to use it as follows... private var _data:XML = XMLLoader.LOAD("path/to/xml_file.xml"); Then I could use it in any client and go-to-town with e4x. The general problem I am having is with the URLLoader's COMPLETE event, which necessarily cal...

Return code from Mac app

I'm trying to create a Mac app, which should return an error code in some cases. This is an Intel bundle. (It's a Carbon C++ project, but this is probably irrelevant.) The standard way to do it in C++ would be to have the main function return the value, and that's what I do, so I think that part is correct. (I also tried explicitly calli...

best practice for return value in WCF services.

I have a WCF service sitting in the cloud. And my application makes several calls to this WCF service. Is it a best practise: 1] to always use return value as bool which indicates if the operation was sucessful or not. 2] returning the values you meant to return as the OUT parameters ...

Multiple returns versus Exit for

I have the following VB.NET code (but for each loops are in most languages, thus the language-agnostic tag): Public Function VerifyServiceName(ByRef sMachineName As String, ByRef sServiceName As String) As Boolean Dim asServices As System.ServiceProcess.ServiceController() = System.ServiceProcess.ServiceController.GetServices(sMa...