Search Results

Search found 3518 results on 141 pages for 'arguments'.

Page 23/141 | < Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >

  • Using generics in dotnet for functions with any number of arguments?

    - by Zarigani
    I would like to have a function that can "wrap" any other function call. In this particular case, it would allow me to write some more generic transaction handling around some specific operations. I can write this for any particular number of arguments, e.g. for one argument: Public Shared Sub WrapFunc(Of T)(ByVal f As Action(Of T), ByVal arg As T) ' Test some stuff, start transaction f(arg) ' Test some stuff, end transaction End Sub ... but I was hoping to have this handle any number of arguments without having to have duplicate code for 0 args, 1 arg, 2 args, etc. Is there a way of doing this?

    Read the article

  • Passing arguments to javascript file, how does it work?

    - by vietean
    From the tutorial ScriptJSONOptions of FirebugLite page, I found the below: Script JSON options It is possible to set options using a JSON object inside the linked script: <script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"> { overrideConsole: false, startInNewWindow: true, startOpened: true, enableTrace: true } </script> It means that we can pass the arguments to javascript file. But I don't know how does it work? Update: My question is how to get the arguments inside the js file? P/S: I also looked into code, but I could not find the code is implemented this feature.

    Read the article

  • How to convert non key, value java arguments to applet params? (args like -Xmx64m)

    - by bwizzy
    I'm trying to use xvpviewer (based on TightVNC) to VNC into my VMs running on Citirx XenServer. There are a couple of caveats required with trusting the certificate from XenServer which I've got working. Essentially I'm trying to convert the java command below (which works on the command line to launch VncViewer) for use in an applet that can be accessed via HTML page. java -Djavax.net.ssl.trustStore=/tmp/kimo.jks -Xmx64m -jar VncViewer.jar HOST "/console?ref=OpaqueRef:141f4204-2240-4627-69c6-a0c7d9898e6a&session_id=OpaqueRef:91a483c4-bc40-3bb0-121c-93f2f89acc3c" PORT 443 PROXYHOST1 192.168.0.5 PROXYPORT1 443 SocketFactory "HTTPSConnectSocketFactory" I know I can put the HOST, PORT etc arguments into param tags for the applet but I'm not sure how to apply the two initial argments.

    Read the article

  • C# 4.0 Optional/Named Parameters Beginner&rsquo;s Tutorial

    - by mbcrump
    One of the interesting features of C# 4.0 is for both named and optional arguments.  They are often very useful together, but are quite actually two different things.  Optional arguments gives us the ability to omit arguments to method invocations. Named arguments allows us to specify the arguments by name instead of by position.  Code using the named parameters are often more readable than code relying on argument position.  These features were long overdue, especially in regards to COM interop. Below, I have included some examples to help you understand them more in depth. Please remember to target the .NET 4 Framework when trying these samples. Code Snippet using System;   namespace ConsoleApplication3 {     class Program     {         static void Main(string[] args)         {               //C# 4.0 Optional/Named Parameters Tutorial               Foo();                              //Prints to the console | Return Nothing 0             Foo("Print Something");             //Prints to the console | Print Something 0             Foo("Print Something", 1);          //Prints to the console | Print Something 1             Foo(x: "Print Something", i: 5);    //Prints to the console | Print Something 5             Foo(i: 5, x: "Print Something");    //Prints to the console | Print Something 5             Foo("Print Something", i: 5);       //Prints to the console | Print Something 5             Foo2(i3: 77);                       //Prints to the console | 77         //  Foo(x:"Print Something", 5);        //Positional parameters must come before named arguments. This will error out.             Console.Read();         }           static void Foo(string x = "Return Nothing", int i = 0)         {             Console.WriteLine(x + " " + i + Environment.NewLine);         }           static void Foo2(int i = 1, int i2 = 2, int i3 = 3, int i4 = 4)         {             Console.WriteLine(i3);         }     } }

    Read the article

  • Most common parts of a SELECT SQL query?

    - by jnrbsn
    I'm writing a function that generates a SELECT SQL query. (I'm not looking for a tool that already does this.) My function currently takes the following arguments which correspond to different parts of the SELECT query (the base table name is already known): where order fields joins group limit All of these arguments will be optional so that the function generates something like this by default: SELECT * FROM `table_name` I want to order the arguments so that the most often used parts of a SELECT query are first. That way the average call to the function will use as few of the arguments as possible rather than passing a null value or something like that to skip an argument. For example, if someone wanted to use the 1st and 3rd arguments but not the rest, they might have to pass a null value as the 2nd argument in order to skip it. So, for general purpose use, how should I order the arguments? Edit: To be more precise, out of the query parts I listed above, what is the order from most used to least used? Also, I'm not looking for solutions that allow me to not have to specify the order. Edit #2: The "fields" argument will default to "*" (i.e all fields/columns).

    Read the article

  • Understanding clojure keywords

    - by tjb1982
    I'm taking my first steps with Clojure. Otherwise, I'm somewhat competent with JavaScript, Python, Java, and a little C. I was reading this artical that describes destructuring vectors and maps. E.g. => (def point [0 0]) => (let [[x y] point] => (println "the coordinates are:" x y)) the coordinates are: 0 0 but I'm having a difficult time understanding keywords. At first glance, they seem really simple, as they just evaluate to themselves: => :test :test But they seem to be used is so many different ways and I don't understand how to think about them. E.g., you can also do stuff like this: => (defn full-name [& {first :first last :last}] => (println first last)) => (full-name :first "Tom" :last "Brennan") Tom Brennan nil This doesn't seem intuitive to me. I would have guessed the arguments should have been something more like: (full-name {:first "Tom" :last "Brennan"}) because it looks like in the function definition that you're saying "no required arguments, but a variable number of arguments comes in the form of a single map". But it seems more like you're saying "no required arguments, but a variable number of arguments comes which should be a list of alternating keywords and values... ?" I'm not really sure how to wrap my brain around this. Also, things like this confuse me too: => (def population {:humans 5 :zombies 1000}) => (:zombies population) 1000 => (population :zombies) 1000 How do maps and keywords suddenly become functions? If I could get some clarification on the use of keywords in these two examples, that would be really helpful. Update I've also seen http://stackoverflow.com/questions/3337888/clojure-named-arguments and while the accepted answer is a great demonstration of how to use keywords with destructuring and named arguments, I'm really looking more for understanding how to think about them--why the language is designed this way and how I can best internalize their use.

    Read the article

  • How can I find out if two arguments are instances of the same, but unknown class?

    - by Ingmar
    Let us say we have a method which accepts two arguments o1 and o2 of type Object and returns a boolean value. I want this method to return true only when the arguments are instances of the same class, e.g.: foo(new Integer(4),new Integer(5)); Should return true, however: foo(new SomeClass(), new SubtypeSomeClass()); should return false and also: foo(new Integer(3),"zoo"); should return false. I believe one way is to compare the fully qualified class names: public boolean foo(Object o1, Object o2){ Class<? extends Object> c1 = o1.getClass(); Class<? extends Object> c2 = o2.getClass(); if(c1.getName().equals(c2.getName()){ return true;} return false; } An alternative conditional statement would be : if (c1.isAssignableFrom(c2) && c2.isAssignableFrom(c1)){ return true; } The latter alternative is rather slow. Are there other alternatives to this problem?

    Read the article

  • Prevent coersion to a single type in unlist() or c(); passing arguments to wrapper functions

    - by Leo Alekseyev
    Is there a simple way to flatten a list while retaining the original types of list constituents?.. Is there a way to programmatically construct a heterogeneous list?.. For instance, I want to create a simple wrapper for functions like png(filename,width,height) that would take device name, file name, and a list of options. The naive approach would be something like my.wrapper <- function(dev,name,opts) { do.call(dev,c(filename=name,opts)) } or similar code with unlist(list(...)). This doesn't work because opts gets coerced to character, and the resulting call is e.g. png(filename,width="500",height="500"). If there's no straightforward way to create heterogeneous lists like that, is there a standard idiomatic way to splice arguments into functions without naming them explicitly (e.g. do.call(dev,list(filename=name,width=opts["width"]))? -- Edit -- Gavin Simpson answered both questions below in his discussion about constructing wrapper functions. Let me give a summary of the answer to the title question: It is possible to construct a heterogeneous list with c() provided the arguments to c() are lists. To wit: > foo <- c("a","b"); bar <- 1:3 > c(foo,bar) [1] "a" "b" "1" "2" "3" > c(list(foo),list(bar)) [[1]] [1] "a" "b" [[2]] [1] 1 2 3 > c(as.list(foo),as.list(bar)) ## this creates a flattened heterogeneous list [[1]] [1] "a" [[2]] [1] "b" [[3]] [1] 1 [[4]] [1] 2 [[5]] [1] 3

    Read the article

  • Saving in mongoDb with Mongoose, unexpected elements saved

    - by guiomie
    When I write in my mongoDB with mongoose the operation is treated with success, my document is saved, but there is also all kind of weird other sutff written down. It seems to be mongoose code. What could cause this? I add stuff in a specific array with: resultReference.ref[arrayLocation].allEvents.push(theEvent); {id: 11, allEvents: [] } is the structure of a ref element, and I push theEvent in the allEvents array. I then resultReference.save() I use express, mongoose and mongoHQ for database. I tried on a local mongo server, and this annoyance is still there. I've print in my console the document to write before save() and non of this weird code is there. { id 11 allEvents [ 0 { _events { maxListeners 0 } _doc { _id {"$oid": "4eb87834f54944e263000003"} title "Test" allDay false start 2011-11-10 13:00:00 UTC end 2011-11-10 15:00:00 UTC url "/test/4eb87834f54944e263000002" color "#99CCFF" ref "4eb87834f54944e263000002" } _activePaths { paths { title "modify" allDay "modify" start "modify" end "modify" url "modify" color "modify" ref "modify" } states { init { } modify { title true allDay true start true end true url true color true ref true } require { } } stateNames [ 0 "require" 1 "modify" 2 "init" ] } _saveError null _validationError null isNew true _pres { save [ 0 function (next) { // we keep the error semaphore to make sure we don't // call `save` unnecessarily (we only need 1 error) var subdocs = 0 , error = false , self = this; var arrays = this._activePaths .map('init', 'modify', function (i) { return self.getValue(i); }) .filter(function (val) { return (val && val instanceof DocumentArray && val.length); }); if (!arrays.length) return next(); arrays.forEach(function (array) { subdocs += array.length; array.forEach(function (value) { if (!error) value.save(function (err) { if (!error) { if (err) { error = true; next(err); } else --subdocs || next(); } }); }); }); } 1 "function checkForExistingErrors(next) { if (self._saveError){ next(self._saveError); self._saveError = null; } else { next(); } }" 2 "function validation(next) { return self.validate.call(self, next); }" ] } _posts { save [ ] } save function () { var self = this , hookArgs // arguments eventually passed to the hook - are mutable , lastArg = arguments[arguments.length-1] , pres = this._pres[name] , posts = this._posts[name] , _total = pres.length , _current = -1 , _asyncsLeft = proto[name].numAsyncPres , _next = function () { if (arguments[0] instanceof Error) { return handleError(arguments[0]); } var _args = Array.prototype.slice.call(arguments) , currPre , preArgs; if (_args.length && !(arguments[0] === null && typeof lastArg === 'function')) hookArgs = _args; if (++_current < _total) { currPre = pres[_current] if (currPre.isAsync && currPre.length < 2) throw new Error("Your pre must have next and done arguments -- e.g., function (next, done, ...)"); if (currPre.length < 1) throw new Error("Your pre must have a next argument -- e.g., function (next, ...)"); preArgs = (currPre.isAsync ? [once(_next), once(_asyncsDone)] : [once(_next)]).concat(hookArgs); return currPre.apply(self, preArgs); } else if (!proto[name].numAsyncPres) { return _done.apply(self, hookArgs); } } , _done = function () { var args_ = Array.prototype.slice.call(arguments) , ret, total_, current_, next_, done_, postArgs; if (_current === _total) { ret = fn.apply(self, args_); total_ = posts.length; current_ = -1; next_ = function () { if (arguments[0] instanceof Error) { return handleError(arguments[0]); } var args_ = Array.prototype.slice.call(arguments, 1) , currPost , postArgs; if (args_.length) hookArgs = args_; if (++current_ < total_) { currPost = posts[current_] if (currPost.length < 1) throw new Error("Your post must have a next argument -- e.g., function (next, ...)"); postArgs = [once(next_)].concat(hookArgs); return currPost.apply(self, postArgs); } }; if (total_) return next_(); return ret; } }; if (_asyncsLeft) { function _asyncsDone (err) { if (err && err instanceof Error) { return handleError(err); } --_asyncsLeft || _done.apply(self, hookArgs); } } function handleError (err) { if ('function' == typeof lastArg) return lastArg(err); if (errorCb) return errorCb.call(self, err); throw err; } return _next.apply(this, arguments); } errors null } ] } ]

    Read the article

  • how to resolve this .Net 3.5 warning/error?

    - by 5YrsLaterDBA
    I have three machines. one installed VS2008 another two installed SDK6 and Framework3.5 (one of these two is a build machine). When I use MSBuild to build our application, all of them get this warning: C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. and the build machine comes with some errors: scsm\SCSM.cs(234,13): error CS1501: No overload for method 'Invoke' takes '1' arguments scsm\SCSM.cs(235,13): error CS1501: No overload for method 'Invoke' takes '1' arguments scsm\SCSM.cs(304,13): error CS1501: No overload for method 'Invoke' takes '1' arguments scsm\SCSM.cs(314,13): error CS1501: No overload for method 'Invoke' takes '1' arguments scsm\SCSM.cs(317,13): error CS1501: No overload for method 'Invoke' takes '1' arguments scsm\SCSM.cs(323,17): error CS1501: No overload for method 'Invoke' takes '1' arguments scsm\SCSM.cs(324,17): error CS1501: No overload for method 'Invoke' takes '1' arguments scsm\SCSM.cs(325,17): error CS1501: No overload for method 'Invoke' takes '1' arguments but other machines are passed without error. Resources are identical in those three machines. searched online but cannot find answer. Anybody here can help me resolve this? thanks

    Read the article

  • How can JVM arguments be passed to apps started through java webstart in MacOS?

    - by siva
    We have a application which is triggered from browser. This application consumes around 800 mb of memory. This works perfectly when invoked from any browsers in windows OS. The same application when triggered from MacOS throws an out of memory exception which occurs when the application is short of memory. Is there any way to increase the memory allocated for apps running in mac os environment. Also please let me know how JVM arguments can be passed to apps started through java webstart in macOS.

    Read the article

  • Windows is not passing command line arguments to Python programs executed from the shell.

    - by mckoss
    I'm having trouble getting command line arguments passed to Python programs if I try to execute them directly as executable commands from a Windows command shell. For example, if I have this program (test.py): import sys print "Args: %r" % sys.argv[1:] And execute: >test foo Args: [] as compared to: >python test.py foo Args: ['foo'] My configuration has: PATH=...;C:\python25;... PATHEXT=...;.PY;.... >assoc .py .py=Python.File >ftype | grep Python Python.CompiledFile="C:\Python25\python.exe" "%1" %* Python.File="C:\Python25\python.exe" "%1" %* Python.NoConFile="C:\Python25\pythonw.exe" "%1" %*

    Read the article

  • I get the warning "Format not a string literal and no format arguments" at NSLog -- how can I correc

    - by dsobol
    Hello, I get the warning "Format not a string literal and no format arguments" on the NSLog call in the following block: (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog([NSString stringWithFormat:@"%d", buttonIndex]); } I have read in another post here that this error message indicates an insecure use of NSLog. Could someone point me in the direction of a properly formatted string for this? Thanks for any and all assistance! Regards, Steve O'Sullivan

    Read the article

  • Simple prolog program. Getting error: >/2: Arguments are not sufficiently instantiated

    - by user1279812
    I made a prolog program posAt(List1,P,List2) that tests whether the element at position P of List1 and List2 are equal: posAt([X|Z],1,[Y|W]) :- X=Y. posAt([Z|X],K,[W|Y]) :- K1, Kr is K - 1, posAt(X,Kr,Y). When testing: ?- posAt([1,2,3],X,[a,2,b]). I expected an output of X=2 but instead I got the following error: ERROR: /2: Arguments are not sufficiently instantiated Why am I getting this error?

    Read the article

  • PHP get all function arguments as $key => $value array?

    - by web lover
    <?php function register_template(){ print_r(func_get_args()); # the result was an array ( [0] => my template [1] => screenshot.png [2] => nice template .. ) } register_template( # unkown number of arguments $name = "my template", $screenshot = "screenshot.png", $description = "nice template .. " ) ?> BUT , I want the result array as $key = $value form , $key represents the parameter name.

    Read the article

  • Is there a phrase or word to describe an algorithim or programme is complete in that given any value for its arguments there is a predictable outcome?

    - by Mrk Mnl
    Is there a phrase to describe an algorithim or programme is complete in that given any possible value for its arguments there is a predicatable outcome? i.e. all the ramifications have been considered whatever the context? A simple example would be the below function: function returns string get_item_type(int type_no) { if(type_no < 10) return "hockey stick" else if (type_no < 20) return "bulldozer" else return "unknown" } (excuse the dismal pseudo code) No matter what number is supplied all possibiblites are catered for. My question is: is there a word to fill the blank here: "get_item_type() is ______ complete" ? (The answer is not Turing Complete - that is something quite different - but I annoyingly always think of something as "Turing Complete" when I am thinking of the above).

    Read the article

  • Is there a phrase or word to describe an algorithim or program is complete in that given any value for its arguments there is a defined outcome?

    - by Mrk Mnl
    Is there a phrase or word to describe an algorithim or programme is complete in that given any value for its arguments there is a defined outcome? i.e. all the ramifications have been considered whatever the context? A simple example would be the below function: function returns string get_item_type(int type_no) { if(type_no < 10) return "hockey stick" else if (type_no < 20) return "bulldozer" else return "unknown" } (excuse the dismal pseudo code) No matter what number is supplied all possibiblites are catered for. My question is: is there a word to fill the blank here: "get_item_type() is ______ complete" ? (The answer is not Turing Complete - that is something quite different - but I annoyingly always think of something as "Turing Complete" when I am thinking of the above).

    Read the article

  • How do I recursively define a Hash in Ruby from supplied arguments?

    - by Sarah Beckham
    This snippet of code populates an @options hash. values is an Array which contains zero or more heterogeneous items. If you invoke populate with arguments that are Hash entries, it uses the value you specify for each entry to assume a default value. def populate(*args) args.each do |a| values = nil if (a.kind_of? Hash) # Converts {:k => "v"} to `a = :k, values = "v"` a, values = a.to_a.first end @options[:"#{a}"] ||= values ||= {} end end What I'd like to do is change populate such that it recursively populates @options. There is a special case: if the values it's about to populate a key with are an Array consisting entirely of (1) Symbols or (2) Hashes whose keys are Symbols (or some combination of the two), then they should be treated as subkeys rather than the values associated with that key, and the same logic used to evaluate the original populate arguments should be recursively re-applied. That was a little hard to put into words, so I've written some test cases. Here are some test cases and the expected value of @options afterwards: populate :a => @options is {:a => {}} populate :a => 42 => @options is {:a => 42} populate :a, :b, :c => @options is {:a => {}, :b => {}, :c => {}} populate :a, :b => "apples", :c => @options is {:a => {}, :b => "apples", :c => {}} populate :a => :b => @options is {:a => :b} # Because [:b] is an Array consisting entirely of Symbols or # Hashes whose keys are Symbols, we assume that :b is a subkey # of @options[:a], rather than the value for @options[:a]. populate :a => [:b] => @options is {:a => {:b => {}}} populate :a => [:b, :c => :d] => @options is {:a => {:b => {}, :c => :d}} populate :a => [:a, :b, :c] => @options is {:a => {:a => {}, :b => {}, :c => {}}} populate :a => [:a, :b, "c"] => @options is {:a => [:a, :b, "c"]} populate :a => [:one], :b => [:two, :three => "four"] => @options is {:a => :one, :b => {:two => {}, :three => "four"}} populate :a => [:one], :b => [:two => {:four => :five}, :three => "four"] => @options is {:a => :one, :b => { :two => { :four => :five } }, :three => "four" } } It is acceptable if the signature of populate needs to change to accommodate some kind of recursive version. There is no limit to the amount of nesting that could theoretically happen. Any thoughts on how I might pull this off?

    Read the article

  • How to debug/reformat C printf calls with lots of arguments in vim?

    - by Costi
    I have a function call in a program that I'm maintaining has 28 arguments for a printf call. It's printing a lot of data in a CSV file. I have problems following finding where what goes and I have some mismatches in the parameters types. I enabled -Wall in gcc and I get warnings like: n.c:495: warning: int format, pointer arg (arg 15) n.c:495: warning: format argument is not a pointer (arg 16) n.c:495: warning: double format, pointer arg (arg 23) The function is like this: fprintf (ConvFilePtr, "\"FORMAT3\"%s%04d%s%04d%s%s%s%d%s%c%s%d%c%s%s%s%s%s%s%s%11.lf%s%11.lf%s%11.lf%s%d\n", some_28_arguments_go_here); I would like to know if there is a vim plugin that highlights the printf format specifier when i go with the cursor over a variable. Other solutions? How to better reformat the code to make it more readable?

    Read the article

< Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >