Search Results

Search found 34668 results on 1387 pages for 'return'.

Page 6/1387 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • how to return response from post in a variable? jQuery

    - by robertdd
    i use this function to return the response of post: $.sendpost = function(){ return jQuery.post('inc/operations.php', {'operation':'test'}, "json"); }, i want to make something like this: in: $.another = function(){ var sendpost = $.sendpost(); alert(sendpost); } but i get: [object XMLHttpRequest] if i print the object with: jQuery.each(sendpost, function(i, val) { $(".displaydetails").append(i + " => " + val + "<br/>"); }); i get: details abort => function () { x && h.call(x); g("abort"); } dispatchEvent => function dispatchEvent() { [native code] } removeEventListener => function removeEventListener() { [native code] } open => function open() { [native code] } setRequestHeader => function setRequestHeader() { [native code] } onreadystatechange => [xpconnect wrapped nsIDOMEventListener] send => function send() { [native code] } readyState => 4 status => 200 getResponseHeader => function getResponseHeader() { [native code] } responseText => mdaaa from php how to return only the response in the variable?

    Read the article

  • Object inheritance and method parameters/return types - Please check my logic

    - by user2368481
    I'm preparing for a test and doing practice questions, this one in particular I am unsure I did correctly: We are given a very simple UML diagram to demonstrate inheritance: I hope this is clear, it shows that W inherits from V and so on: |-----Y V <|----- W<|-----| |-----X<|----Z and this code: public X method1(){....} method2(new Y()); method2(method1()); method2(method3()); The questions and my answers: Q: What types of objects could method1 actually return? A: X and Z, since the method definition includes X as the return type and since Z is a kind of X is would be OK to return either. Q: What could the parameter type of method2 be? A: Since method2 in the code accepts Y, X and Z (as the return from method1), the parameter type must be either V or W, as Y,X and Z inherit from both of these. Q: What could return type of method3 be? A: Return type of method3 must be V or W as this would be consistent with answer 2.

    Read the article

  • How to get the result for return statement from JSON parsing?

    - by blankon91
    I've follow the code for parsing the value with JSON from here, but I get the problem in my return statement. I want to put the parsing result into my return statement. How to do that? Here is my code: public String MASUK(String user, String password) { SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME); PropertyInfo pi = new PropertyInfo(); pi.setName("ccduser"); pi.setValue(user); pi.setType(String.class); request.addProperty(pi); PropertyInfo pi2 = new PropertyInfo(); pi2.setName("password"); pi2.setValue(password); pi2.setType(String.class); request.addProperty(pi2); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS); try { httpTransport.call(SOAP_ACTION, envelope); SoapObject resultSOAP = (SoapObject) envelope.bodyIn; /* gets our result in JSON String */ String ResultObject = resultSOAP.getProperty(0).toString(); resultSOAP = (SoapObject) envelope.bodyIn; ResultObject = resultSOAP.getProperty(0).toString(); if (ResultObject.startsWith("{")) { // if JSON string is an object JSONObj = new JSONObject(ResultObject); Iterator<String> itr = JSONObj.keys(); while (itr.hasNext()) { String Key = (String) itr.next(); String Value = JSONObj.getString(Key); BundleResult.putString(Key, Value); // System.out.println(bundleResult.getString(Key)); } } else if (ResultObject.startsWith("[")) { // if JSON string is an array JSONArr = new JSONArray(ResultObject); System.out.println("length" + JSONArr.length()); for (int i = 0; i < JSONArr.length(); i++) { JSONObj = (JSONObject) JSONArr.get(i); BundleResult.putString(String.valueOf(i), JSONObj.toString()); // System.out.println(bundleResult.getString(i)); } } } catch (Exception exception) { } return null; }

    Read the article

  • C++ -- return x,y; The point?

    - by Earlz
    Hello, I have been programming in C and C++ for a few years and now I'm taking a college course in it and our book had a function like this int foo(){ int x=0; int y=20; return x,y; //y is always returned } I have never seen such syntax. In fact, I never see the , operator used outside of parameter lists. If y is always returned though, then what is the point? Is there a case where a return statement would need to be created like this? (Also, I tagged C as well because it applies to both, though my book specifically is C++)

    Read the article

  • Return lines in input code causing gaps/whitespace between elements in output?

    - by Jenny Zhang
    I am trying to put images next to each other on a webpage. Here is my HTML: <img class="pt" src="Yellow Tulip.jpg" title="Yellow Tulip" alt="Yellow Tulip" /> <img class="pt" src="Pink Tulip.jpg" title="Pink Tulip" alt="Pink Tulip" /> <img class="pt" src="Purple Tulip.jpg" title="Purple Tulip" alt="Purple Tulip" /> However, on my webpage, this shows a gap between each image. I've noticed that once I remove the return line that makes the elements separate and readable and instead just put all the elements on one line, the gaps go away. <img class="pt" src="Yellow Tulip.jpg" title="Yellow Tulip" alt="Yellow Tulip" /><img class="pt" src="Pink Tulip.jpg" title="Pink Tulip" alt="Pink Tulip" /><img class="pt" src="Purple Tulip.jpg" title="Purple Tulip" alt="Purple Tulip" /> Is there anyway I can achieve the output of the latter but still have the code/input look like the former? I really like the readability that the return lines (enter spaces) bring to the code, but I don't want the whitespace it creates on the actual page. If someone could explain why this is and/or how to fix it, I'd be really grateful! :)

    Read the article

  • How do you return a pointer to a base class with a virtual function?

    - by Nick Sweet
    I have a base class called Element, a derived class called Vector, and I'm trying to redefine two virtual functions from Element in Vector. //element.h template <class T> class Element { public: Element(); virtual Element& plus(const Element&); virtual Element& minus(const Element&); }; and in another file //Vector.h #include "Element.h" template <class T> class Vector: public Element<T> { T x, y, z; public: //constructors Vector(); Vector(const T& x, const T& y = 0, const T& z =0); Vector(const Vector& u); ... //operations Element<T>& plus(const Element<T>& v) const; Element<T>& minus(const Element<T>& v) const; ... }; //sum template <class T> Element<T>& Vector<T>::plus(const Element<T>& v) const { Element<T>* ret = new Vector((x + v.x), (y + v.y), (z + v.z)); return *ret; } //difference template <class T> Element<T>& Vector<T>::minus(const Element<T>& v) const { Vector<T>* ret = new Vector((x - v.x), (y - v.y), (z - v.z)); return *ret; } but I always get error: 'const class Element' has no member named 'getx' So, can I define my virtual functions to take Vector& as an argument instead, or is there a way for me to access the data members of Vector through a pointer to Element? I'm still fairly new to inheritance polymorphism, fyi.

    Read the article

  • Can I make a LaTeX macro 'return' a filename?

    - by drfrogsplat
    I'm writing my thesis/dissertation and since its an on-going work I don't always have the actual images ready for the figures I put into my document, but for various reasons want to automatically have it substitute a dummy figure in place when the included graphics file doesn't exist. E.g. I can do something like \includegraphics[width=8cm]{\chapdir/figures/fluxcapacitor} (where \chapdir is a macro for my 'current' chapter directory, e.g. \def\chapdir{./ch_timetravel} and if there's no ./ch_timetravel/figures/fluxcapacitor.jpg it'll insert ./commands/dummy.jpg instead. I've structured my macros (perhaps naïvely?) so that I have a macro (\figFileOrDummy) that determines the appropriate file to include by checking if the argument provided to it exists, so that I can call \includegraphics[properties]{\figFileOrDummy{\chapdir/figures/fluxcapacitor}}. Except I'm getting various errors depending on how I try to call this, which seem to suggest that I'm approaching the problem in a fundamentally flawed way as far as 'good LaTeX programming' goes. Here's the macro to check if the file exists (and 'return' either filename or the dummy filename): \newcommand{\figFileOrDummy}[1]{% % Figure base name (no extension) to be used if the file exists \def\fodname{#1}% \def\dummyfig{commands/dummy}% % Check if output is PS (.EPS) or PDF (.JPG/.PDF/.PNG/...) figures \ifx\pdfoutput\undefined% % EPS figures only \IfFileExists{\fodname.eps}{}{\def\fodname{\dummyfig}}% \else% % Check existence of various extensions: PDF, TIF, TIFF, JPG, JPEG, PNG, MPS \def\figtest{0}% flag below compared to this value \IfFileExists{\fodname.pdf}{\def\figfilenamefound{1}}{\def\figfilenamefound{0}}% \IfFileExists{\fodname.jpg}{\def\figfilenamefound{1}}{}% \IfFileExists{\fodname.png}{\def\figfilenamefound{1}}{}% % and so on... % If no files found matching the filename (flag is 0) then use the dummy figure \ifx\figfilenamefound\figtest% \def\fodname{\dummyfig}% \fi% \fi% % 'return' the filename \fodname% }% Alternatively, here's a much simpler version which seems to have similar problems: \newcommand{\figFileOrDummy}[1]{% \def\dummyfig{commands/dummy}% \dummyfig% } The \def commands seems to be processed after the expansion of the macro they're trying to define, so it ends up being \def {commands/dummy}... (note the space after \def) and obviously complains. Also it seems to treat the literal contents of the macro as the filename for \includegraphics, rather than resolving/expanding it first, so complains that the file '\def {commands/dummy}... .png' doesn't exist.. I've tried also doing something like \edef\figfilename{\figFileOrDummy{\chapdir/figures/fluxcapacitor}} to try to force it to make \figfilename hold just the value rather than the full macro, but I get an Undefined control sequence error complaining the variables I'm trying to \def in the \figFileOrDummy macro are undefined. So my question is either How do I make this macro expand properly?; or If this is the wrong way of structuring my macros, how should I actually structure such a macro, in order to be able to insert dummy/real figures automatically?; or Is there a package that already handles this type of thing nicely that I've overlooked? I feel like I'm missing something pretty fundamental here...

    Read the article

  • Does Ruby have a special stack for return value?

    - by prosseek
    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 code work without returning something?

    Read the article

  • Python C API return more than one value / object without building a tuple [migrated]

    - by Grisu
    I got the following problem. I have written a C-Extension to Python(2.7 / 3.2) to interface a self written software library. Unfortunately I need to return two values from the function where the last one is optional. In Python I tried def func(x,y): return x+y, x-y test = func(13,4) but test is a tuple. If I write test1,test2 = func(13,4) I got both values separated. Is there a possibility to return only one value without unpacking the tuple, i.e. the second(,.. third, ..fourth) value gets neglected? And if such a solution existst, how does it look for the C-API? Because return Py_BuildValue("ii",x+y,x-y); results in a tuple as well.

    Read the article

  • Should I return iterators or more sophisticated objects?

    - by Erik
    Say I have a function that creates a list of objects. If I want to return an iterator, I'll have to return iter(a_list). Should I do this, or just return the list as it is? My motivation for returning an iterator is that this would keep the interface smaller -- what kind of container I create to collect the objects is essentially an implementation detail On the other hand, it would be wasteful if the user of my function may have to recreate the same container from the iterator which would be bad for performance.

    Read the article

  • Is it better to return NULL or empty values from functions/methods where the return value is not present?

    - by P B
    I am looking for a recommendation here. I am struggling with whether it is better to return NULL or an empty value from a method when the return value is not present or cannot be determined. Take the following two methods as an examples: string ReverseString(string stringToReverse) // takes a string and reverses it. Person FindPerson(int personID) // finds a Person with a matching personID. In ReverseString(), I would say return an empty string because the return type is string, so the caller is expecting that. Also, this way, the caller would not have to check to see if a NULL was returned. In FindPerson(), returning NULL seems like a better fit. Regardless of whether or not NULL or an empty Person Object (new Person()) is returned the caller is going to have to check to see if the Person Object is NULL or empty before doing anything to it (like calling UpdateName()). So why not just return NULL here and then the caller only has to check for NULL. Does anyone else struggle with this? Any help or insight is appreciated.

    Read the article

  • How to accomplish covariant return types when returning a shared_ptr?

    - by Kyle
    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 this, if there is one?

    Read the article

  • Can a Perl subroutine return data but keep processing?

    - by Perl QuestionAsker
    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 that? and why don't you just ...?, but I really would like to know if this is possible. Thank you so much in advance.

    Read the article

  • How to amend return value design in OO manner?

    - by FrontierPsycho
    Hello. I am no newb on OO programming, but I am faced with a puzzling situation. I have been given a program to work on and extend, but the previous developers didn't seem that comfortable with OO, it seems they either had a C background or an unclear understanding of OO. Now, I don't suggest I am a better developer, I just think that I can spot some common OO errors. The difficult task is how to amend them. In my case, I see a lot of this: if (ret == 1) { out.print("yadda yadda"); } else if (ret == 2) { out.print("yadda yadda"); } else if (ret == 3) { out.print("yadda yadda"); } else if (ret == 0) { out.print("yadda yadda"); } else if (ret == 5) { out.print("yadda yadda"); } else if (ret == 6) { out.print("yadda yadda"); } else if (ret == 7) { out.print("yadda yadda"); } ret is a value returned by a function, in which all Exceptions are swallowed, and in the catch blocks, the above values are returned explicitly. Oftentimes, the Exceptions are simply swallowed, with empty catch blocks. It's obvious that swalllowing exceptions is wrong OO design. My question concerns the use of return values. I believe that too is wrong, however I think that using Exceptions for control flow is equally wrong, and I can't think of anything to replace the above in a correct, OO manner. Your input, please?

    Read the article

  • Is it possible to return a list of numbers from a Sybase function?

    - by ps_rs4
    I'm trying to overcome a very serious performance issue in which Sybase refuses to use the primary key index on a large table because one of the required fields is specified indirectly through another table - or, in other words; SELECT ... FROM BIGTABLE WHERE KFIELD = 123 runs in ms but SELECT ... FROM BIGTABLE, LTLTBL WHERE KFIELD = LTLTBL.LOOKUP AND LTLTBL.UNIQUEID = 'STRINGREPOF123' takes 30 - 40 seconds. I've managed to work around this first problem by using a function that basically lets me do this; SELECT ... FROM BIGTABLE WHERE KFIELD = MYFUNC('STRINGREPOF123') which also runs in ms. The problem, however, is that this approach only works when there is a single value returned by MYFUNCT but I have some cases where it may return 2 or 3 values. I know that the SQL SELECT ... FROM BIGTABLE WHERE KFIELD IN (123,456,789) also returns in millis so I'd like to have a function that returns a list of possible values rather than just a single one - is this possible? Sadly the application is running on Sybase ASA 9. Yes I know it is old and is scheduled to be refreshed but there's nothing I can do about it now so I need logic that will work with this version of the DB. Thanks in advance for any assistance on this matter.

    Read the article

  • Spotlight: How Scandinavia's Largest Nuclear Power Plant Increased Productivity and Reduced Costs wi

    - by [email protected]
    Ringhals nuclear power plant, which is part of the Vattenfall Group, is located about 60 km south-west of the beautiful coastal city of Gothenburg in Sweden. A deep concern to reduce environmental impact coupled with an effort to increase plant safety and operational efficiency have led to a recent surge in investments and initiatives around plant modification and plant optimization at Ringhals. A multitude of challenges were faced by the users in various groups that were involved in these projects. First, it was very difficult for users to easily access complex and layered asset and engineering information, which was critical to increased productivity and completing projects on time. Moreover, the 20 or so different solutions that were being used to view various document formats, not only resulted in collaboration complexity but also escalated IT administration costs and woes. Finally, there was a considerable non-engineering community comprising non-CAD specialists that needed easy access to plant data in an effort to minimize engineering disruption. Oracle's AutoVue significantly simplified the ability to efficiently view and use digital asset information by providing a standardized visualization solution for the enterprise. The key benefits achieved by Ringhals include: Increased productivity of plant optimization and plant modification by 3% Saved around $ 500 K annually Cut IT maintenance costs by 50% by using a single solution Reduced engineering disruption by allowing non-CAD users easy access to digital plant data The complete case-study can be found here

    Read the article

  • Using Sub-Types And Return Types in Scala to Process a Generic Object Into a Specific One

    - by pr1001
    I think this is about covariance but I'm weak on the topic... I have a generic Event class used for things like database persistance, let's say like this: class Event( subject: Long, verb: String, directobject: Option[Long], indirectobject: Option[Long], timestamp: Long) { def getSubject = subject def getVerb = verb def getDirectObject = directobject def getIndirectObject = indirectobject def getTimestamp = timestamp } However, I have lots of different event verbs and I want to use pattern matching and such with these different event types, so I will create some corresponding case classes: trait EventCC case class Login(user: Long, timestamp: Long) extends EventCC case class Follow( follower: Long, followee: Long, timestamp: Long ) extends EventCC Now, the question is, how can I easily convert generic Events to the specific case classes. This is my first stab at it: def event2CC[T <: EventCC](event: Event): T = event.getVerb match { case "login" => Login(event.getSubject, event.getTimestamp) case "follow" => Follow( event.getSubject, event.getDirectObject.getOrElse(0), event.getTimestamp ) // ... } Unfortunately, this is wrong. <console>:11: error: type mismatch; found : Login required: T case "login" => Login(event.getSubject, event.getTimestamp) ^ <console>:12: error: type mismatch; found : Follow required: T case "follow" => Follow(event.getSubject, event.getDirectObject.getOrElse(0), event.getTimestamp) Could someone with greater type-fu than me explain if, 1) if what I want to do is possible (or reasonable, for that matter), and 2) if so, how to fix event2CC. Thanks!

    Read the article

  • How do I return a perl variable to a .ksh script?

    - by Dave
    I have a .ksh script that calls a perl pgm. The perl pgm creates some important data that the .ksh script needs to act on. Example: .ksh pgm #!/usr/bin/ksh abc.pl > $logFile # perl pgm creates variable $importantData See below. # HOW DO I GET THE .KSH SCRIPT TO SEE $importantData ??? def.ksh $importantData # send important data to another .ksh script exit . Perl pgm $importantData = somefunction(); exit;

    Read the article

  • Named output parameters vs return values

    - by Abyx
    Which code is better: // C++ void handle_message(...some input parameters..., bool& wasHandled) void set_some_value(int newValue, int* oldValue = nullptr) // C# void handle_message(...some input parameters..., out bool wasHandled) void set_some_value(int newValue, out int oldValue) or bool handle_message(...some input parameters...) ///< Returns -1 if message was handled //(sorry, this documentation was broken a year ago and we're too busy to fix it) int set_some_value(T newValue) // (well, it's obvious what this function returns, so I didn't write any documentation for it) The first one doesn't have and need any documentation. It's a self-documenting code. Output value clearly says what it means, and it's really hard to make a change like this: - void handle_message(Message msg, bool& wasHandled) { - wasHandled = false; - if (...) { wasHandled = true; ... + void handle_message(Message msg, int& wasHandled) { + wasHandled = -1; + if (...) { wasHandled = ...; With return values such change could be done easily /// Return true if message was handled - bool handle_message(Message msg) { + int handle_message(Message msg) { ... - return true; + return -1; Most of compilers don't (and can't) check documentation written in comments. Programmers also tend to ignore comments while editing code. So, again, the question is: if subroutine has single output value, should it be a procedure with well-named self-documenting output parameter, or should it be a function which returns an unnamed value and have a comment describing it?

    Read the article

  • PHP user created function return values problem

    - by faX
    Okay I'm new here and I have been trying to figure this out all day I have two functions one calling the other but my functions only returns the last value for example 29 when it should return multiple values. As wondering how can I fix this problem so that my functions return all the values. Here is my PHP code. function parent_comments(){ if(articles_parent_comments_info($_GET['article_id']) !== false){ foreach(articles_parent_comments_info($_GET['article_id']) as $comment_info){ $comment_id = filternum($comment_info['comment_id']); reply_comment_count($comment_id); } } } function reply_comment_count($parent_id){ if(articles_reply_comments_info($_GET['article_id']) !== false){ foreach(articles_reply_comments_info($_GET['article_id']) as $reply_info){ $comment_id = filternum($reply_info['comment_id']); $reply_id = filternum($reply_info['parent_id']); if($parent_id === $reply_id){ reply_comment_count($comment_id); } } } return $comment_id; }

    Read the article

  • How To return md5 salted hash? [closed]

    - by user1790627
    Here is the function and this function returns value for sessionGuid. Example, User1 login and join chat then the value of User1 for sessionGuid is. 1 User2 value for sessionGuid is. 2 User3 . value .3 i want this function return md5 salted hash to avoid hacks. function get_current_online_session_login() { $oSrvSec = &App::getModuleService('Account', 'Security'); $login = $oSrvSec->getCurrentUserLogin(); $aReq = getRow(App::getT('online_session'), 'online_session_user = "' . $login . '"'); // return $aReq['online_session_login']; return $aReq['online_session_id']; }

    Read the article

  • Exiting from the Middle of an Expression Without Using Exceptions

    - by Jon Purdy
    Is there a way to emulate the use of flow-control constructs in the middle of an expression? Is it possible, in a comma-delimited expression x, y, for y to cause a return? Edit: I'm working on a compiler for something rather similar to a functional language, and the target language is C++. Everything is an expression in the source language, and the sanest, simplest translation to the destination language leaves as many things expressions as possible. Basically, semicolons in the target language become C++ commas. In-language flow-control constructs have presented no problems thus far; it's only return. I just need a way to prematurely exit a comma-delimited expression, and I'd prefer not to use exceptions unless someone can show me that they don't have excessive overhead in this situation. The problem of course is that most flow-control constructs are not legal expressions in C++. The only solution I've found so far is something like this: try { return x(), // x(); (1 ? throw Return(0) : 0); // return 0; } catch (Return& ret) { return ref.value; } The return statement is always there (in the event that a Return construct is not reached), and as such the throw has to be wrapped in ?: to get the compiler to shut up about its void result being used in an expression. I would really like to avoid using exceptions for flow control, unless in this case it can be shown that no particular overhead is incurred; does throwing an exception cause unwinding or anything here? This code needs to run with reasonable efficiency. I just need a function-level equivalent of exit().

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >