Search Results

Search found 7418 results on 297 pages for 'argument passing'.

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

  • Returns an associative array comprising a function's argument list in php

    - by diEcho
    Hello All, in php func_get_args — Returns an array comprising a function's argument list it returns numeric index array is there any function/way in php by which we get associative array i.e. key=value pair i m explaining with example: test.php <?php function foo() { include './fga.inc'; } $x=20; $y=30; foo($x, $y); ?> fga.inc <?php $args = func_get_args(); echo "<pre>"; print_r($args); echo "</pre>"; ?> which should returns array ( 'x'=> 20, 'y' => 30, )

    Read the article

  • Passing a DefaultHttpClient between activites

    - by searchMaker
    Hi all, I am trying to maintain my session variables that I get back in a cookie from my website in my DefaultHttpClient by passing the client between activities. Simply put how can I pass this object between activities to maintain my session variables? Bundle.put... doesn't seem to support this object. If it does how does it work with DefaultHttpClient? Thanks in advance to anyone who can help.

    Read the article

  • what functions are called when passing value to function

    - by Tim
    In C++, if an object of a class is passed as a parameter into a function, the copy constructor of the class will be called. I was wondering if the object is of nonclass type, what function will be called? Similarly in C, what function is called when passing values or address of variables into a function? Thanks and regards!

    Read the article

  • Passing data between asp.net pages

    - by user204588
    Hello, I'm wondering the opinion of what is the best way to pass a lot of values between pages. I was thinking of either saving the values to a database, using context.Items[], or Session[]. I'm not sure about what is the best method. I'm passing probably around 40 variables.

    Read the article

  • C++ Using a class template argument as a template argument for another type

    - by toefel
    Hey Everyone, I'm having this problem while writing my own HashTable. It all works, but when I try to templatize the thing, it gave me errors. I recreated the problem as follows: THIS CODE WORKS: typedef double Item; class A { public: A() { v.push_back(pair<string, Item>("hey", 5.0)); } void iterate() { for(Iterator iter = v.begin(); iter != v.end(); ++iter) cout << iter->first << ", " << iter->second << endl; } private: vector<pair<string, double> > v; typedef vector< pair<string, double> >::iterator Iterator; }; THIS CODE DOES NOT: template<typename ValueType> class B { public: B(){} void iterate() { for(Iterator iter = v.begin(); iter != v.end(); ++iter) cout << iter->first << ", " << iter->second << endl; } private: vector<pair<string, ValueType> > v; typedef vector< pair<string, ValueType> >::iterator Iterator; }; the error messages: g++ -O0 -g3 -Wall -c -fmessage-length=0 -omain.o ..\main.cpp ..\main.cpp:50: error: type std::vector<std::pair<std::string, ValueType>, std::allocator<std::pair<std::string, ValueType> > >' is not derived from typeB' ..\main.cpp:50: error: ISO C++ forbids declaration of `iterator' with no type ..\main.cpp:50: error: expected `;' before "Iterator" ..\main.cpp: In member function `void B::iterate()': ..\main.cpp:44: error: `Iterator' was not declared in this scope ..\main.cpp:44: error: expected `;' before "iter" ..\main.cpp:44: error: `iter' was not declared in this scope Does anybody know why this is happening? Thanks!

    Read the article

  • Warning: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a

    - by johnny
    Hi, the following code produces the error in the title. I've tried to google it, but all I got were pages who got the same error (and not an explanation thereof). This isn't really a problem since it's actually working and cancelling the error out with the @ works out just fine. Though I'm still wondering why I haven't been able to execute array_multisort just once without getting this error. public function getMostRelevant(){ list($occurrences, $keywords) = $this->occurr_keyw_array; array_multisort($occurrences, SORT_DESC, SORT_NUMERIC, $keywords); $return_array = array( array($occurrences[0], $keywords[0]), array($occurrences[1], $keywords[1]), array($occurrences[2], $keywords[2]) ); return $return_array; }

    Read the article

  • Problem using void pointer as a function argument

    - by Nazgulled
    Hi, I can't understand this result... The code: void foo(void * key, size_t key_sz) { HashItem *item = malloc(sizeof(HashItem)); printf("[%d]\n", (int)key); ... item->key = malloc(key_sz); memcpy(item->key, key, key_sz); } void bar(int num) { foo(&num, sizeof(int)); } And I do this call: bar(900011009); But the printf() output is: [-1074593956] I really need key to be a void pointer, how can I fix this?

    Read the article

  • C# out parameter value passing..

    - by Pandiya Chendur
    I am using contactsreader.dll to import my gmail contacts... One of my method has out parameter... I am doing this, Gmail gm = new Gmail(); DataTable dt = new DataTable(); string strerr; gm.GetContacts("[email protected]", "******", true, dt,strerr); // It gives invalid arguments error.. and my gmail class has, public void GetContacts(string strUserName, string strPassword,out bool boolIsOK, out DataTable dtContatct, out string strError); Am i passing the correct values for out parameters...

    Read the article

  • Ruby - Call method passing values of array as each parameter

    - by Markus Orreilly
    I'm currently stuck on this problem. I've hooked into the method_missing function in a class I've made. When a function is called that doesn't exist, I want to call another function I know exists, passing the args array as all of the parameters to the second function. Does anyone know a way to do this? For example, I'd like to do something like this: class Blah def valid_method(p1, p2, p3, opt=false) puts "p1: #{p1}, p2: #{p2}, p3: #{p3}, opt: #{opt.inspect}" end def method_missing(methodname, *args) if methodname.to_s =~ /_with_opt$/ real_method = methodname.to_s.gsub(/_with_opt$/, '') send(real_method, args) # <-- this is the problem end end end b = Blah.new b.valid_method(1,2,3) # output: p1: 1, p2: 2, p3: 3, opt: false b.valid_method_with_opt(2,3,4) # output: p1: 2, p2: 3, p3: 4, opt: true (Oh, and btw, the above example doesn't work for me)

    Read the article

  • Unpacking Argument Lists and Instantiating WTForms objects from web.py

    - by Morris Cornell-Morgan
    After a bit of searching, I've found that it's possible to instantiate a WTForms object in web.py using the following code: form = my_form(**web.input()) web.input() returns a "dictionary-like" web.storage object, but without the double asterisks WTForms will raise an exception: TypeError: formdata should be a multidict-type wrapper that supports the 'getlist' method From the Python documentation I understand that the two asterisks are used to unpack a dictionary of named arguments. That said, I'm still a bit confused about exactly what is going on. What makes the web.storage object returned by web.input() "dictionary-like" enough that it can be unpacked by ** but not "dictionary-like" enough that it can be passed as-is to the WTForms constructor? I know that this is an extremely basic question, but any advice to help a novice programmer would be greatly appreciated!

    Read the article

  • $.(ajax) wrapper for Jquery - passing parameters to delegates

    - by gnomixa
    I use $.(ajax) function extensively in my app to call ASP.net web services. I would like to write a wrapper in order to centralize all the ajax calls. I found few simple solutions, but none address an issue of passing parameters to delegates, for example, if i have: $.ajax({ type: "POST", url: "http://localhost/TemplateWebService/TemplateWebService/Service.asmx/GetFoobar", data: jsonText, contentType: "application/json; charset=utf-8", dataType: "json", success: function(response) { var results = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d; OnSuccess(results, someOtherParam1, someOtherParam2); }, error: function(xhr, status, error) { OnError(); } }); The wrapper to this call would have to have the way to pass someOtherParam1, someOtherParam2 to the OnSuccess delegate...Aside from packing the variables into a generic array, I can't think of other solutions. How did you guys address this issue?

    Read the article

  • Passing expression as a parameter in Call by reference

    - by darkie15
    All, When we are passing an expression as a parameter, how does the evaluation occur? Here is a small example. This is just a pseudocode kind of example: f (x,y) { y = y+1; x = x+y; } main() { a = 2; b = 2; f(a+b, a) print a; } When accessing variable x in f, does it access the address of the temp variable which contains the result of a+b or will it access the individual addresses of a and b and then evaluate the value of a+b Please help. Regards, darkie15

    Read the article

  • PHP: passing GET between multiple pages

    - by aterimperator
    I'm building a set of pages where I have a number of GET variables and it is often valuable to keep passing it along to the next page. This leads to ugly code where I have to have "if this $_GET variable is set, dynamically add it to this hyperlink". This is, in many senses, not a problem; but I had the thought "there must be a better way to do this", I mean after all basically all I want is to take the '?' and everything after it and append it to the links on that page, it would seem this should be rather simple (or at least possible to do in a for loop). I tried google searching but couldn't find anything, so I figured I'd see if any of you happen to know. Why not use SESSION? Because these pages need to be capable of being bookmarked. Thank you.

    Read the article

  • Passing an empty IEnumerable argument to a method

    - by avance70
    I have this method (simplified): void DoSomething(IEnumerable<int> numbers); And I invoke it like this: DoSomething(condition==true?results:new List<int>()); The variable results is formed with a LINQ select condition (IEnumerable). I was wondering is this List<int>() the best way (the fastest?) to pass an empty collection, or is new int[0] better? Or, something else would be faster, a Collection, etc.? In my example null wouldn't be ok.

    Read the article

  • Passing an array argument from C# to a C++/CLI method

    - by jco
    I know only very little about C++/CLI, but I have a simple problem that needs a solution. I have a C++/CLI class method that takes a byte-array as a parameter. The array is of a pre-determined length, and can be allocated in C# beforehand. The array is supposed to be filled with data by the C++/CLI method. How do I declare the method and then call it from C#? I tried something like having the following in my C++/CLI class: public ref class C { public: void FillBytes(array<BYTE^>^ bytes); }; And then, in C#: o = new C(); var bytes = new byte[3]; o.FillBytes(bytes); But that didn't work at all :).

    Read the article

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

    - by user321605
    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 * afterURL 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 this new data. I then want afterURL to point to a location within the new string. My issue is getting the actual pointer that is passed in to this function to point to the new data. Thanks in advance! Rob

    Read the article

  • Passing Variable Length Arrays to a function

    - by David Bella
    I have a variable length array that I am trying to pass into a function. The function will shift the first value off and return it, and move the remaining values over to fill in the missing spot, putting, let's say, a -1 in the newly opened spot. I have no problem passing an array declared like so: int framelist[128]; shift(framelist); However, I would like to be able to use a VLA declared in this manner: int *framelist; framelist = malloc(size * sizeof(int)); shift(framelist); I can populate the arrays the same way outside the function call without issue, but as soon as I pass them into the shift function, the one declared in the first case works fine, but the one in the second case immediately gives a segmentation fault. Here is the code for the queue function, which doesn't do anything except try to grab the value from the first part of the array... int shift(int array[]) { int value = array[0]; return value; } Any ideas why it won't accept the VLA? I'm still new to C, so if I am doing something fundamentally wrong, let me know.

    Read the article

  • R: Pass by reference

    - by Pierre
    Can you pass by reference with "R" ? for example, in the following code: setClass("MyClass", representation( name="character" )) instance1 <-new("MyClass",name="Hello1") instance2 <-new("MyClass",name="Hello2") array = c(instance1,instance2) instance1 array instance1@name="World!" instance1 array the output is > instance1 An object of class “MyClass” Slot "name": [1] "World!" > array [[1]] An object of class “MyClass” Slot "name": [1] "Hello1" [[2]] An object of class “MyClass” Slot "name": [1] "Hello2" but I wish it was > instance1 An object of class “MyClass” Slot "name": [1] "World!" > array [[1]] An object of class “MyClass” Slot "name": [1] "World!" [[2]] An object of class “MyClass” Slot "name": [1] "Hello2" is it possible ? Thanks Pierre

    Read the article

  • How to pass values between two Custom UITableViewCells in iphone

    - by Mithun
    I have two customized cells in an iphone UITableViewController and would like to capture the data in one cell into another..... I am currently unable to post images and pls assume the following points. There are two custom UITableViewcells 1) Notes Textfield in one customcell 2) Submit button in another text field. Now i want to pass data typed in the notes textfield to be available when I click the Submit button.... Is this possible? Please help....:(

    Read the article

  • Passing variables, creating instances, self, The mechanics and usage of classes: need explenation

    - by Baf
    I've been sitting over this the whole day and Im a little tired already so please excuse me being brief. Im new to python. I just rewrrote a working program, into a bunch of functions in a class and everzthings messed up. I dont know if its me but Im very surprised i couldn t find a beginners tutorial on how to handle classes on the web so I have a few questions. First of all, in the init section of the class i have declared a bunch of variables with self.variable=something. Is it correct that i should be able to access/modify these variables in every function of the class by using self.variable in that function? In other words by declaring self.variable i have made these variables, global variables in the scope of the class right? If not how do i handle self. ? Secondly how do i correctly pass arguments to the class? some example code would be cool. thirdly how do i call a function of the class outside of the class scope? some example code would be cool. fouthly how do I create an Instance of the class INITIALCLASS in another class OTHERCLASS, passing variables from OTHERCLASS to INITIALCLASS? some example code would be cool. I Want to call a function from OTHERCLASS with arguments from INITIALCLASS. What Ive done so far is. class OTHERCLASS(): def __init__(self,variable1,variable2,variable3): self.variable1=variable1 self.variable2=variable2 self.variable3=variable3 def someotherfunction(self): something=somecode(using self.variable3) self.variable2.append(something) print self.variable2 def somemorefunctions(self): self.variable2.append(variable1) class INITIALCLASS(): def __init__(self): self.variable1=value1 self.variable2=[] self.variable3='' self.DoIt=OTHERCLASS(variable1,variable2,variable3) def somefunction(self): variable3=Somecode #tried this self.DoIt.someotherfunctions() #and this DoIt.someotherfunctions() I clearly havent understood how to pass variables to classes or how to handle self, when to use it and when not, I probably also havent understood how to properly create an isntance of a class. In general i havent udnerstood the mechanics of classes So please help me and explain it to me like i have no Idea( which i dont it seems). Or point me to a thorough video, or readable tutorial. All i find on the web is super simple examples, that didnt help me much. Or just very short definitions of classes and class methods instances etc. I can send you my original code if you guys want, but its quite long. Thanks for the Help Much appreciated!

    Read the article

  • Passing char * into fopen with C.

    - by Rhys
    Hey there, I'm writing a program that passes data from a file into an array, but I'm having trouble with fopen (). It seems to work fine when I hardcode the file path into the parameters (eg fopen ("data/1.dat", "r");) but when I pass it as a pointer, it returns NULL. Note that line 142 will print "data/1.dat" if entered from command line so parse_args () appears to be working. 132 int 133 main(int argc, char **argv) 134 { 135 FILE *in_file; 136 int *nextItem = (int *) malloc (sizeof (int)); 137 set_t *dictionary; 138 139 /* Parse Arguments */ 140 clo_t *iopts = parse_args(argc, argv); 141 142 printf ("INPUT FILE: %s.\n", iopts->input_file); /* This prints correct path */ 143 /* Initialise dictionary */ 144 dictionary = set_create (SET_INITAL_SIZE); 145 146 /* Use fscanf to read all data values into new set_t */ 147 if ((in_file = fopen (iopts->input_file, "r")) == NULL) 148 { 149 printf ("File not found...\n"); 150 return 0; 151 } Thanks! Rhys

    Read the article

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