return-value

Can actionPerformed return a value?

In my application I use a FileChooser to chose a file. The name of the selected file should be returned to another class. how to do this in eclipse? ...

What is wrong with this c# method?

I use this method to get file extension, public string ReturnExtension(string fileExtension) { switch (fileExtension) { case ".doc": case ".docx": return "application/ms-word"; } } When i compile it i got the error BaseClass.ReturnExtension(string)': not all code ...

Set argument pointer to point to new memory inside a function (without returning it) IN C

Hello, Hopefully my title was descriptive enough to attract the right help. I want to write a function that will return 1 thing, and modify a provided pointer in another. My current function declaration is . . . char * replaceURLS(char * body) What I want to do is copy all of body's data into a new string, and set body to point to ...

Have macro 'return' a value

I'm using a macro and I think it works fine - #define CStrNullLastNL(str) {char* nl=strrchr(str,'\n'); if(nl){*nl=0;}} So it works to zero out the last newline in a string, really its used to chop off the linebreak when it gets left on by fgets. So, I'm wondering if I can "return" a value from the macro, so it can be called like f...

Why does my Perl script return a zero return code when I explicitly call exit with a non-zero parameter?

I have a Perl script which calls another script. The Perl script should be propagating the script's return code but seems to be returning zero to its caller (a Java application) desipte the explicit call to exit $scriptReturnCode. Code and output as follows (I realise that <=> could/should be != but that's what I have): print "INFO: Ca...

Exiting from the Middle of an Expression Without Using Exceptions

Solved: I figured out a clean way to do it with setjmp()/longjmp(), requiring only a minimal wrapper like: int jump(jmp_buf j, int i) { longjmp(j, i); return 0; } This allows jump() to be used in conditional expressions. So now the code: if (A == 0) return; output << "Nonzero.\n"; Is correctly translated to: return ((A == 0) && ju...

How to accomplish covariant return types when returning a shared_ptr?

using namespace boost; class A {}; class B : public A {}; class X { virtual shared_ptr<A> foo(); }; class Y : public X { virtual shared_ptr<B> foo(); }; The return types aren't covariant (nor are they, therefore, legal), but they would be if I was using raw pointers instead. What's the commonly accepted idiom to work around thi...

Returning an anonymous class that uses a final primitive. How does it work?

Hi, I was wondering if someone could explain how the following code works: public interface Result { public int getCount(); public List<Thing> getThings(); } class SomeClass { ... public Result getThingResult() { final List<Thing> things = .. populated from something. final int count = 5; return new Result { ...

Java - Returning a value from function !

How does returning a value from a function internally works ? See this example.. ...

how to return response from post in a variable? jQuery

edited: This is what i need: sendpost = function(a,b,c){ return jQuery.post('inc/operations.php', {a:b}, c, "json"); }, rotate = function(callback){ //.... alert(callback); } sendpost('operation', 'test', rotate) old post: i use this function to return the response of post: $.sendpost = function(){ return jQuery.pos...

Does Ruby have a special stack for returning a value?

The following Ruby code def a(b,c) b+c end is the same as follows with Python def a(b,c): return b+c It looks like that ruby has the special stack that stores the final evaluation result and returns the value when a function is called. If so, what's the name of the stack, and how can I get that stack? If not, how does the Ruby ...

Can a Perl subroutine return data but keep processing?

Is there any way to have a subroutine send data back while still processing? For instance (this example used simply to illustrate) - a subroutine reads a file. While it is reading through the file, if some condition is met, then "return" that line and keep processing. I know there are those that will answer - why would you want to do tha...

See return value in C#

Hi, Consider the following piece of code: As you can see we are on line 28. Is there any way to see the return value of the function at this point, without letting the code return to the caller function? Foo.Bar() is a function call which generates a unique path (for example). So it's NOT constant. Entering ?Foo.Bar() in the immidi...

What is the difference between array parameters in C

Hi, what is the difference between following function declarations, which create and return the array in C/C++? Both methods create the array and fill it with proper values and returns true if everything passed. bool getArray(int* array); bool getArray(int* array[]); Thanks Best Regards, STeN ...

GDB disas question about address values

I'm working with a binary file that I disas'd in gdb. Right now I'm just examining the return value of a function. 0x08048604 <playGame+78>: ret Is the address shown the address where ret is stored in the function? Or is it just the address of the instruction to return the ret value? ...

What is the best way to return two values from a method?

When I have to write methods which return two values, I usually go about it as in the following code which returns a List<string>. Or if I have to return e.g. a id and string, then I return a List<object> and then pick them out with index number and recast the values. This recasting and referencing by index seems inelegant so I want to ...

How to take a user entered number, perform a calculation and display the result in action script?

Hi there, I basically want to know how to take a user entered number, then take another user entered number and times it by a predefined number and then display the result when submit is clicked. E.g. 200 + 300 x 0.4 = xxxx Im sure this must be fairly simple so if anyone is able to help me out it would be greatly appreciated! If thi...

Class; Struct; Enum confusion, what is better?

I have 46 rows of information, 2 columns each row ("Code Number", "Description"). These codes are returned to the client dependent upon the success or failure of their initial submission request. I do not want to use a database file (csv, sqlite, etc) for the storage/access. The closest type that I can think of for how I want these code...

Javascript AJAX function returns undefined instead of true / false

I have a function that issues an AJAX call (via jQuery). In the complete section I have a function that says: complete: function(XMLHttpRequest, textStatus) { if(textStatus == "success") { return(true); } else { return(false); } } However, if I call this like so: if(callajax()) { // Do som...

Store return value of function in reference C++

Is it valid to store the return value of an object in a reference? class A { ... }; A myFunction() { A myObject; return myObject; } //myObject goes out of scope here void mySecondFunction() { A& mySecondObject = myFunction(); } Is it possible to do this in order to avoid copying myObject to mySecondObject? myObject is not...