return-value

php not returning value of false

I cannot get a false value to return here. A true value returns fine. What am I missing? if ((count($this->_brokenRulesCollection)) == 0) { return true; } else { return false; } ...

Getting the overall return value of a function within a loop

What I am doing is looping over an array and running a function on each value of the array (the function returns true on success, false on error). I would like to return false if any of the calls inside the loop returned false, but I want the whole loop to be processed. Probably easier to explain with code: foreach($this->_cacheLocatio...

Actionscript 3 Dictionary returning undefined/null for key that has just been set in a different class

I'm rendering display objects to the stage depending on the given XML elements, as you can see here: PageRenderer.as private static var curElements:Dictionary = new Dictionary(); //renders the current page private static function renderCode(pageCode:XML):void { if (pageCode) { /...

When should RVO kick-in?

From the following code, If RVO has happened, I expect to see the 2 addresses pointing to the same location, however this is not the case (my compiler is MS VC9.0) #include <iostream> #include <string> std::string foo(std::string& s) { std::cout << "address: " << (unsigned int)(&s) << std::endl; return s; } int main() { std::...

Telerik RadWindow Javascript return values to ASP.NET

Hi, I have a parent page that launches a telerik radwindow and passes it an argument. Once the radwindow is done processeing the value, I need it to return it to the parent page, and I would like the parent page to have access to this value in my code behind page. I have tried to pass the value to a hidden field on my page and then tr...

Returning String[] from a method

I want to return two values from a method stored in an array. How can I do it? For example: The method needs to return "un" and "pwd". ...

Can .bat file execute an sql query and return a value?

How can I call a query from a .bat file? (say my query is: select version from system). Can my .bat file save the output that this query returns? I wanna use this output in my NSIS script. ...

PHPDoc: @return void necessary?

Is it really necessary do something like this: /** * ... * * @return void */ I have quite a few methods that don't have a return value, and it seems really redundant to put something like this in the comment. Would it be considered bad form to leave it out? ...

What should an INSERT stored procedure do with the Identity value?

I need to write a stored procedure to insert a row into a table. The table has an Identity column called ID. My question is should I return the value and if so, how? As far as I can see, I could return it as the return value, I could return it as an out parameter, or I could do nothing with it. What would a DB programmer do as a...

Returning Array from ActiveX component to JavaScript

I have an ActiveX component (which I did not write and have no control over). It has several methods I want to use, which return arrays. Every time I attempt to do something of the sort: var arrayValue = axObj.methodWhichReturnsArray(); the arrayValue object is undefined. The component provider tells me that I should not be having any...

Good ASP.NET method for checking, reading and returning file contents

I found a good way to check if a file exists and read the contents if it does, but for some reason I can't create a method out of it. Here's what I have so far: <script runat="server"> void Page_Load(Object s, EventArgs e) { lblFunction.Text = mwbInclude("test.txt"); } string mwbInclude(string fileName) { ...

Are there any optimisations for retrieving of return value in Delphi?

I'm trying to find an elegant way to access the fields of some objects in some other part of my program through the use of a record that stores a byte and accesses fields of another record through the use of functions with the same name as the record's fields. TAilmentP = Record // actually a number but acts like a pointer private Ord...

Python newbie - Input strings, return a value to a web page

Hi, I've got a program I would like to use to input a password and one or multiple strings from a web page. The program takes the strings and outputs them to a time-datestamped text file, but only if the password matches the set MD5 hash. The problems I'm having here are that I don't know how to get this code on the web. I have a serv...

Can I return double * in function?

Can I do something like this? Will this work? double *vec_subtraction (char *a, char *b, int n) { double *result; int i; for(i=0; i<n; i++) result[i] = a[i]-b[i]; return result; } and then in main: double *vec=vec_substraction(a, b, n); for(i=1; i<n; i++) printf("%d", vec[i]); a and b are v...

CloseHandle():Return value check require

I am using CloseHandle() to close handle to a thread. This is done towards the end of the program and hence cleanup operation should be irrespective of the return value of the CloseHandle(); pc-lint reports error that , ignoring return value of function. Kindly let me know if there will be any issue if ignoring the return value ...

What is a good general approach for deciding return values in C?

My program is written in C for Linux, and has many functions with different patterns for return values: 1) one or two return n on success and -1 on failure. 2) some return 0 on success and -1 on failure. 3) some return 1 on success and 0 on failure (I generally spurn using a boolean type). 4) pointers return 0 on failure (I generally sp...

Is returning null after exception is caught bad design

Hello, I always come across the same problem that when an exception is caught in a function that has a non-void return value I don't know what to return. The following code snippet illustrates my problem. public Object getObject(){ try{ ... return object; } catch(Exception e){ //I have to return something here but wha...

Return a const reference or a copy in a getter function?

What's better as default, to return a copy (1) or a reference (2) from a getter function? class foo { public: std::string str () { // (1) return str_; } const std::string& str () { // (2) return str_; } private: std::string str_; }; I know 2) could be faster but don't have to due to (N)RVO. 1) is ...

When your method fails, but succeeds... Would you return a failure or a success?

I doubt a definite answer exists but I'm quite interested in different opinions on the subject. A communiti wiki therefore. You're designing a method. It serves a purpose, that's why you're designing it in the first place. A caller uses your method and the method fails, but, lo and behold, the ultimate purpose that exuse the existence o...

AS3 Functions: is it possible to return a value inside of a loop?

I am trying to find the index from an array using a loop function, but I am getting an error: private function findMatch(matchValue:int):int { for (var i:int = 0; i < playersList.length; i++) { if (playersList[i].value + matchValue == levelTarget) { return i; } ...