Search Results

Search found 7294 results on 292 pages for 'parameters'.

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

  • Meaning of parameters in a Google query?

    - by blinry
    Are there any ressources on what the parameters in a Google query mean? Any analysis how the Google search pages work internally? Examples would be http://www.google.com/#hl=en&source=hp&q=lol&aq=f&aqi=&aql=&oq=&fp=45675624562456 or http://www.google.com/url?sa=t&source=web&ct=res&cd=11&ved=KJSGHFKSDJF&url=sfdgagasdgasdgasgasg&rct=j&q=fghthwrteghedgf&ei=asdfasdfsa&usg=asdfasdfasf

    Read the article

  • How to use a method with more than one parameters to create custom buttons

    - by iphonix
    I am repeating my codes few times to create custom buttons, I am trying to create a method and create all my required buttons just by called that method and using two parameters, btnTitle and btnAction. My Codes for the method -(void) addnewButton:(NSString *) btnTitle withAction:UIAction btnAction; { // Add a custom edit navigation button editButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString((btnTitle), @"") style:UIBarButtonItemStyleBordered target:self action:@selector(btnAction)] autorelease]; self.navigationItem.rightBarButtonItem = editButton; } Now how shall I call this method to create a button?

    Read the article

  • Get the parameters in Request

    - by Appps
    Hi All, How do I get the parameters that are available in the request Header? When I login to a site, I need to see the values that are available in the request header.Is it possible to get that information using any Addons? Can someone please help me to find this? Thanks in advance

    Read the article

  • Override Javascript Function Based on Passed Parameters

    - by George
    Is it possible to override a function based on the number of parameters that you are passing into it? For instance: function abc(name) { document.write ('My name is' + name); } function abc(name,friend) { document.write ('My name is' + name + 'and my best friend\'s name is' + friend); } So in the HTML if I just called abc(george) it would use the first version of the function, but if I called abc(george,john) it would use the second version. There may be other ways to accomplish the example I used, but I'm just wondering if the concept is sound in javascript.

    Read the article

  • Send parameters in order in HTTPService

    - by Suraj Chandran
    I am trying to work with a simple HTTPService. The problem is that my webservice is conscious of the order of arguments it gets. I will tell the problem with an example: var service:HTTPService = new HTTPService(); var params:Object = new Object(); params.rows = 0; params.facet = "true"; service.send(params); Note that in the above code I have mentioned the parameter rows before facet, but the url I recieve is facet=true&rows=0. So I recieve the argument rows before facet and hence my webservice does not work. I figured out that the contents of array is always sent in alphabetical order, which I dont want. Is there any way I can achieve explict ordering of parameters sent? Note that I am not in power of changing the logic of webservice(its basically a RPC service supporting both desktop and web client). Thanks.

    Read the article

  • UriBuilder incorrectly encoding Query Parameters value ?

    - by Fred
    Lets consider the following code sample where a path and single parameter are encoded... Parameter name: "param" Parameter value: "foo/bar?aaa=bbb&ccc=ddd" (happens to be a url with query parameters) String test = UriBuilder.fromPath("https://dummy.com"). queryParam("param", "foo/bar?aaa=bbb&ccc=ddd"). build().toURL().toString(); The encoded URL string returned is: "https://dummy.com?param=foo/bar?aaa%3Dbbb&ccc%3Dddd" Is this correct ? Should not the character "&" (and may be even "?") be encoded in the parameter value string ? Would not the URL produced be interpreted as follow: One first parameter, name="param", value = "ar?aaa%3Dbbb" followed by a second parameter, name="ccc%3Dddd", without value.

    Read the article

  • Page auto reload with parameters

    - by Mithil Deshmukh
    I am trying to autoreload my page after every 20 seconds. I am using JavaScript for this instead of the <meta. I have <body onload="SetTimer()" and here is my JavaScript function function SetTimer(){ setTimeout('window.location.replace(window.location.pathname)', 20000) } Now my problem is I also pass a parameter within the querystring when this page is loaded first. But when the page relaods again (window.location.pathname does not include the parameter) hence I am not able to assign values to the labels on the page which is based on the parameters passed.

    Read the article

  • Ajax call with jQuery in ASP.NET MVC does not pass parameters

    - by desmati
    The Route is: routes.MapRoute( "Ajax", // Route name "BizTalk/Services/{action}", // URL with parameters new { // Parameter defaults controller = "BizTalk" } ); My Controller is: public JsonResult AjaxTest(string s, int i, bool b) { return Json("S: " + s + "," + "I: " + i + "," + "B: " + b); } My jQuery Code: $(document).ready(function() { $("#btn_test").click(function() { var s = "test"; var i = 8; var b = true; $.ajax({ type: "POST", cache: false, url: "/BizTalk/Services/AjaxTest", data: { i: i, s: s, b: b }, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { } }); }); });

    Read the article

  • C# thread with multiple parameters

    - by Lucas B
    Does anyone know how to pass multiple parameters into a Thread.Start routine? I thought of extending the class, but the C# Thread class is sealed. Here is what I think the code would look like: ... Thread standardTCPServerThread = new Thread(startSocketServerAsThread); standardServerThread.Start( orchestrator, initializeMemberBalance, arg, 60000); ... } static void startSocketServerAsThread(ServiceOrchestrator orchestrator, List<int> memberBalances, string arg, int port) { startSocketServer(orchestrator, memberBalances, arg, port); } Thank you in advance. BTW, I start a number of threads with different orchestrators, balances and ports. Please consider thread safety also.

    Read the article

  • SQL optional parameters through VB.net

    - by ScaryJones
    I've a document search page with three listboxes that allow multiple selections. They're: Category A Year Category B Only category A is mandatory, the others are optional parameters and might be empty. Each document can belong to multiple options in Category A and multiple options Category B but each document only has one year associated with it. I've kind of got this working through building up a dynamic SQL string but it's messy and I hate using it so I thought I'd ask here if anyone could see an easier way of doing this. An example of the kind of dynamic SQL query i end up with follows: select * from library where libraryID in (select distinct libraryID from categoryAdocs where categoryAdocID in (4)) or year in (2004)

    Read the article

  • Set Java Application's virtual machine max memory without access to VM parameters because of custom

    - by Tom
    I'm using a Java application which allows you to import custom files. On import, these files are loaded into memory. The problem is that the files I want to import are very big, this causes an OutOfMemory exception. The crash log also informs me that the VM was started with the java parameter "-Xmx512m", I want to alter this to "-Xmx1024m" so that I got double the memory available. The problem is that this application is using it's own JRE folder and that there's a launcher written in C which is calling the jvm.dll file. In any way, java.exe or javaw.exe are never called and thus I cannot set these parameters myself (if I delete these executables it doesn't matter, can still run the application - this is not the case with the dll). So, my question is, can I set this VM parameter in an other way? I'm even willing to alter the JRE files if there is no other way.

    Read the article

  • how to add parameters with mulitselection enabled in ssrs 2008

    - by Sheikh Usman
    Hi, I have a table called Resource, and i am making a line chart (the chart is complicated, so just assume its a simple xy line chart). I want to execute the report with different resources. I have added a new parameter and bound it to a dataset to return a dropdownlist of resource names. Can i do a mulitiple selection of resource. for example if i want to make chart with ResourceA and ResourceB, only, can i select these two resources from the dropdownlist of parameters. cheers, Oz

    Read the article

  • What is the right way to pass class parameters to a method

    - by Schneider
    Let's suppose I have three classes A, B and C public class A { public int A1; public string A2; } public class B { public char B1; public double B2; public decimal B3; } public class C { public string DoSomething(A a, B b) { var a1 = a.A1; var b2 = b.B2; var b3 = b.B3; // DoSomething return string.Empty; } } If DoSomething() is using just some fields of the A and B classes, do you prefer to pass the whole object in parameters or create an intermediate class that has just the needed fields by the DoSomething method ?

    Read the article

  • Tokyo Cabinet Tuning Parameters

    - by user235478
    Hello, I have been trying to find a better Tokyo Cabinet (or Tokyo Tyrant) configuration for my application, but I don't know exactly how. I know what some parameters mean but I want to have a fine tuning control, so I need to know the impact of each one. The Tokyo documentation is really good but not at this point. Does any one can help me? Thanks. TCHDB -> *bool tchdbtune(TCHDB *hdb, int64_t bnum, int8_t apow, int8_t fpow, uint8_t opts);* How do I use: bnum, apow and fpow? TCBDB -> *bool tcbdbtune(TCBDB *bdb, int32_t lmemb, int32_t nmemb, int64_t bnum, int8_t apow, int8_t fpow, uint8_t opts);* How do I use: lmemb, nmemb, bnum, apow and fpow? TCFDB -> *bool tcfdbtune(TCFDB *fdb, int32_t width, int64_t limsiz);* How do I use: width and limsiz? Note: I am only putting this to get all types of database in the topic, this one is really simple. TCTDB -> *bool tctdbtune(TCTDB *tdb, int64_t bnum, int8_t apow, int8_t fpow, uint8_t opts);* How do I use: bnum, apow and fpow?

    Read the article

  • C# Execute Method (with Parameters) with ThreadPool

    - by washtik
    We have the following piece of code (idea for this code was found on this website) which will spawn new threads for the method "Do_SomeWork()". This enables us to run the method multiple times asynchronously. The code is: var numThreads = 20; var toProcess = numThreads; var resetEvent = new ManualResetEvent(false); for (var i = 0; i < numThreads; i++) { new Thread(delegate() { Do_SomeWork(Parameter1, Parameter2, Parameter3); if (Interlocked.Decrement(ref toProcess) == 0) resetEvent.Set(); }).Start(); } resetEvent.WaitOne(); However we would like to make use of ThreadPool rather than create our own new threads which can be detrimental to performance. The question is how can we modify the above code to make use of ThreadPool keeping in mind that the method "Do_SomeWork" takes multiple parameters and also has a return type (i.e. method is not void). Also, this is C# 2.0.

    Read the article

  • Passing control references as ref parameters

    - by Enmanuel
    Hi everyone. Please help me out here because im getting kind of confused.. I have a form in a C# winforms project and a couple of methods that are suposed to perform some tasks for this particular form and all derived ones, so one of those helper methods can make the example.. this one should fill comboboxes with a dataset. Its working properly now but when i coded the method with this signature protected void FillComboBox(kComboBox target, IEntClass_DA entity) { target.DataSource = entity.GetList().Tables[0]; target.DisplayMember = "name"; target.ValueMember = "id"; } I saw that the displayMember and ValueMember in the comboboxes were not holding the values after the method call. I just thought I should use ref parameters so the asignments are not wasted in read-only reference variables. It was ok by then but later, making an exercise of passing the whole form as a parameter I was warned by the compiler with the notice that this could not be passed as a ref parameter because it is read-only. Fine then, I keep working and see that even without the ref keyword i can use the ref variable from the form, update some properties and see the changes. So whats happening here: passing a reference of the control to the helper method gives me ability to change its members even when not using the ref parameter?? Thanks.

    Read the article

  • Passing parameters in MVC

    - by Avinash
    Thare is two forms in a page first one for searching and another for deleting.... <table><tr><td> <% using(Html.BeginForm("ViewList","ControllerName", [values],FormMethod.Post,new{id="viewListForm"})) { %> Name: <%=Html.TextBox("Name", "[value]", new { maxlength = "250" })%> Location: <%=Html.TextBox("Location", "[Value]", new { maxlength = "250" })%> <input type="submit" id="Search" name="Search" value="Search" /> <% } %> </td></tr> <tr><td> <% using(Html.BeginForm("DeleteList","ControllerName", new { name=?,location=? },[values],FormMethod.Post, new{id="deleteListForm"})) { %> [here the code for all items displayed in a table.] <input type="submit" id="Delete" name="Delete" value="Delete" /> When delete buttom pressed i need to pass two parameters ie name and location. The values of name and location are in the above viewListForm. How i take this value from the viewListForm at run time ? <% } %> </td></tr><table>

    Read the article

  • PHP Redirection with Post Parameters

    - by arik-so
    Hello, I have a webpage. This webpage redirects the user to another webpage, more or less the following way: <form method="post" action="anotherpage.php" id="myform"> <?php foreach($_GET as $key => $value){ echo "<input type='hidden' name='{$key}' value='{$value}' />"; } ?> </form> <script> document.getElementById('myform').submit(); </script> Well, you see, what I do is transferring the GET params into POST params. Do not tell me it is bad, I know that myself, and it is not exactly what I really do, what is important is that I collect data from an array and try submitting it to another page via POST. But if the user has JavaScript turned off, it won't work. What I need to know: Is there a way to transfer POST parameters by means of PHP so the redirection can be done the PHP way (header('Location: anotherpage.php');), too? It is very important for me to pass the params via POST. I cannot use the $_SESSION variable because the webpage is on another domain, thus, the $_SESSION variables differ. Anyway, I simply need a way to transfer POST variables with PHP ^^ Thanks in advance!

    Read the article

  • C++ Constructor With Parameters Won't Initialize, Errors C2059 and C2228

    - by Some Girl
    I'm a C# programmer trying to muddle through C++ to create a Windows Forms Application. I have a Windows Form that makes use of a user-created class. Basically I'm trying to use a constructor that takes parameters, but my form won't let me initialize the object with parameter. Here's the code, hopefully somebody can explain the problem to me because I'm completely baffled... Here's my header file: BankAcct.h public ref class BankAcct { private: int money; public: BankAcct(); BankAcct(int); void Deposit(int); void GetBalance(int&); }; And my definition file: BankAcct.cpp #include "StdAfx.h" #include "BankAcct.h" BankAcct::BankAcct() { money = 0; } BankAcct::BankAcct(int startAmt) { money = startAmt; } void BankAcct::Deposit(int depAmt) { money += depAmt; } void BankAcct::GetBalance(int& balance) { balance = money; } And finally my main form. Won't copy the whole thing, of course, but I'm trying to declare the new bank account object, and start it with a balance of say $50. private: BankAcct myAccount(50); //does not work! WHY?? //private: //BankAcct myAccount; //works then in the form constructor my code is this: public: frmBank(void) { InitializeComponent(); int bal; myAccount.GetBalance(bal); lblBankBalance->Text += Convert::ToString(bal); } I've included the BankAcct.h file at the top of my frmBank.h, what else am I doing wrong here? It works great if I use the default constructor (the one that starts the bank balance at zero). I get the following error messages: error C2059: syntax error: 'constant' and error C2228: left of '.GetBalance' must have class/struct/union Thank you for any and all help on this one!!

    Read the article

  • Using Sitecore RenderingContext Parameters as MVC controller action arguments

    - by Kyle Burns
    I have been working with the Technical Preview of Sitecore 6.6 on a project and have been for the most part happy with the way that Sitecore (which truly is an MVC implementation unto itself) has been expanded to support ASP.NET MVC. That said, getting up to speed with the combined platform has not been entirely without stumbles and today I want to share one area where Sitecore could have really made things shine from the "it just works" perspective. A couple days ago I was asked by a colleague about the usage of the "Parameters" field that is defined on Sitecore's Controller Rendering data template. Based on the standard way that Sitecore handles a field named Parameters, I was able to deduce that the field expected key/value pairs separated by the "&" character, but beyond that I wasn't sure and didn't see anything from a documentation perspective to guide me, so it was time to dig and find out where the data in the field was made available. My first thought was that it would be really nice if Sitecore handled the parameters in this field consistently with the way that ASP.NET MVC handles the various parameter collections on the HttpRequest object and automatically maps them to parameters of the action method executing. Being the hopeful sort, I configured a name/value pair on one of my renderings, added a parameter with matching name to the controller action and fired up the bugger to see... that the parameter was not populated. Having established that the field's value was not going to be presented to me the way that I had hoped it would, the next assumption that I would work on was that Sitecore would handle this field similar to how they handle other similar data and would plug it into some ambient object that I could reference from within the controller method. After a considerable amount of guessing, testing, and cracking code open with Redgate's Reflector (a must-have companion to Sitecore documentation), I found that the most direct way to access the parameter was through the ambient RenderingContext object using code similar to: string myArgument = string.Empty; var rc = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull; if (rc != null) {     var parms = rc.Rendering.Parameters;     myArgument = parms["myArgument"]; } At this point, we know how this field is used out of the box from Sitecore and can provide information from Sitecore's Content Editor that will be available when the controller action is executing, but it feels a little dirty. In order to properly test the action method I would have to do a lot of setup work and possible use an isolation framework such as Pex and Moles to get at a value that my action method is dependent upon. Notice I said that my method is dependent upon the value but in order to meet that dependency I've accepted another dependency upon Sitecore's RenderingContext.  I'm a big believer in, when possible, ensuring that any piece of code explicitly advertises dependencies using the method signature, so I found myself still wanting this to work the same as if the parameters were in the request route, querystring, or form by being able to add a myArgument parameter to the action method and have this parameter populated by the framework. Lucky for us, the ASP.NET MVC framework is extremely flexible and provides some easy to grok and use extensibility points. ASP.NET MVC is able to provide information from the request as input parameters to controller actions because it uses objects which implement an interface called IValueProvider and have been registered to service the application. The most basic statement of responsibility for an IValueProvider implementation is "I know about some data which is indexed by key. If you hand me the key for a piece of data that I know about I give you that data". When preparing to invoke a controller action, the framework queries registered IValueProvider implementations with the name of each method argument to see if the ValueProvider can supply a value for the parameter. (the rest of this post will assume you're working along and make a lot more sense if you do) Let's pull Sitecore out of the equation for a second to simplify things and create an extremely simple IValueProvider implementation. For this example, I first create a new ASP.NET MVC3 project in Visual Studio, selecting "Internet Application" and otherwise taking defaults (I'm assuming that anyone reading this far in the post either already knows how to do this or will need to take a quick run through one of the many available basic MVC tutorials such as the MVC Music Store). Once the new project is created, go to the Index action of HomeController.  This action sets a Message property on the ViewBag to "Welcome to ASP.NET MVC!" and invokes the View, which has been coded to display the Message. For our example, we will remove the hard coded message from this controller (although we'll leave it just as hard coded somewhere else - this is sample code). For the first step in our exercise, add a string parameter to the Index action method called welcomeMessage and use the value of this argument to set the ViewBag.Message property. The updated Index action should look like: public ActionResult Index(string welcomeMessage) {     ViewBag.Message = welcomeMessage;     return View(); } This represents the entirety of the change that you will make to either the controller or view.  If you run the application now, the home page will display and no message will be presented to the user because no value was supplied to the Action method. Let's now write a ValueProvider to ensure this parameter gets populated. We'll start by creating a new class called StaticValueProvider. When the class is created, we'll update the using statements to ensure that they include the following: using System.Collections.Specialized; using System.Globalization; using System.Web.Mvc; With the appropriate using statements in place, we'll update the StaticValueProvider class to implement the IValueProvider interface. The System.Web.Mvc library already contains a pretty flexible dictionary-like implementation called NameValueCollectionValueProvider, so we'll just wrap that and let it do most of the real work for us. The completed class looks like: public class StaticValueProvider : IValueProvider {     private NameValueCollectionValueProvider _wrappedProvider;     public StaticValueProvider(ControllerContext controllerContext)     {         var parameters = new NameValueCollection();         parameters.Add("welcomeMessage", "Hello from the value provider!");         _wrappedProvider = new NameValueCollectionValueProvider(parameters, CultureInfo.InvariantCulture);     }     public bool ContainsPrefix(string prefix)     {         return _wrappedProvider.ContainsPrefix(prefix);     }     public ValueProviderResult GetValue(string key)     {         return _wrappedProvider.GetValue(key);     } } Notice that the only entry in the collection matches the name of the argument to our HomeController's Index action.  This is the important "secret sauce" that will make things work. We've got our new value provider now, but that's not quite enough to be finished. Mvc obtains IValueProvider instances using factories that are registered when the application starts up. These factories extend the abstract ValueProviderFactory class by initializing and returning the appropriate implementation of IValueProvider from the GetValueProvider method. While I wouldn't do so in production code, for the sake of this example, I'm going to add the following class definition within the StaticValueProvider.cs source file: public class StaticValueProviderFactory : ValueProviderFactory {     public override IValueProvider GetValueProvider(ControllerContext controllerContext)     {         return new StaticValueProvider(controllerContext);     } } Now that we have a factory, we can register it by adding the following line to the end of the Application_Start method in Global.asax.cs: ValueProviderFactories.Factories.Add(new StaticValueProviderFactory()); If you've done everything right to this point, you should be able to run the application and be presented with the home page reading "Hello from the value provider!". Now that you have the basics of the IValueProvider down, you have everything you need to enhance your Sitecore MVC implementation by adding an IValueProvider that exposes values from the ambient RenderingContext's Parameters property. I'll provide the code for the IValueProvider implementation (which should look VERY familiar) and you can use the work we've already done as a reference to create and register the factory: public class RenderingContextValueProvider : IValueProvider {     private NameValueCollectionValueProvider _wrappedProvider = null;     public RenderingContextValueProvider(ControllerContext controllerContext)     {         var collection = new NameValueCollection();         var rc = RenderingContext.CurrentOrNull;         if (rc != null && rc.Rendering != null)         {             foreach(var parameter in rc.Rendering.Parameters)             {                 collection.Add(parameter.Key, parameter.Value);             }         }         _wrappedProvider = new NameValueCollectionValueProvider(collection, CultureInfo.InvariantCulture);         }     public bool ContainsPrefix(string prefix)     {         return _wrappedProvider.ContainsPrefix(prefix);     }     public ValueProviderResult GetValue(string key)     {         return _wrappedProvider.GetValue(key);     } } In this post I've discussed the MVC IValueProvider used to map data to controller action method arguments and how this can be integrated into your Sitecore 6.6 MVC solution.

    Read the article

  • get GET parameters in JSF's managed bean

    - by mykola
    Hello! Can someone tell me how to catch parameters passed from URI in JSF's managed bean? I have a navigation menu all nodes of which link to some navigation case. And i have two similar items there: Acquiring products and Issuing products. They have the same page but one different parameter: productType. I try to set it just by adding it to URL in "to-view-id" element like this: <navigation-case> <from-outcome>acquiring|products</from-outcome> <to-view-id>/pages/products/list_products.jspx?productType=acquiring</to-view-id> </navigation-case> <navigation-case> <from-outcome>issuing|products</from-outcome> <to-view-id>/pages/products/list_products.jspx?productType=issuing</to-view-id> </navigation-case> But i can't get this "productType" from my managed bean. I tried to get it through FacesContext like this: FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("productType") And like this: HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); request.getParameter("productType"); And i tried to include it as a parameter of managed bean in faces-config.xml and then getting it through ordinary setter: <managed-bean> <managed-bean-name>MbProducts</managed-bean-name> <managed-bean-class>my.package.product.MbProducts</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>productType</property-name> <value>#{param.productType}</value> </managed-property> </managed-bean> ... public class MbProducts { ... public void setProductType(String productType) { this.productType = productType; } ... } But neither of these ways have helped me. All of them returned null. How can i get this productType? Or how can i pass it some other way?

    Read the article

  • Python constructor does weird things with optional parameters

    - by christangrant
    Can you help me understand of the behaviour and implications of the python __init__ constructor. It seems like when there is an optional parameter and you try and set an existing object to a new object the optional value of the existing object is preserved and copied. Ok that was confusing... so look at an example I concocted below. In the code below I am trying to make a tree structure with nodes and possibly many children . In the first class NodeBad, the constructor has two parameters, the value and any possible children. The second class NodeGood only takes the value of the node as a parameter. Both have an addchild method to add a child to a node. When creating a tree with the NodeGood class, it works as expected. However, when doing the same thing with the NodeBad class, it seems as though a child can only be added once! The code below will result in the following output: Good Tree 1 2 3 [< 3 >] Bad Tree 1 2 2 [< 2 >, < 3 >] Que Pasa? Here is the Example: #!/usr/bin/python class NodeBad: def __init__(self, value, c=[]): self.value = value self.children = c def addchild(self, node): self.children.append(node) def __str__(self): return '< %s >' % self.value def __repr__(self): return '< %s >' % self.value class NodeGood: def __init__(self, value): self.value = value self.children = [] def addchild(self, node): self.children.append(node) def __str__(self): return '< %s >' % self.value def __repr__(self): return '< %s >' % self.value if __name__ == '__main__': print 'Good Tree' ng = NodeGood(1) # Root Node rootgood = ng ng.addchild(NodeGood(2)) # 1nd Child ng = ng.children[0] ng.addchild(NodeGood(3)) # 2nd Child print rootgood.value print rootgood.children[0].value print rootgood.children[0].children[0].value print rootgood.children[0].children print 'Bad Tree' nb = NodeBad(1) # Root Node rootbad = nb nb.addchild(NodeBad(2)) # 1st Child nb = nb.children[0] nb.addchild(NodeBad(3)) # 2nd Child print rootbad.value print rootbad.children[0].value print rootbad.children[0].children[0].value print rootbad.children[0].children

    Read the article

  • URL Multiple Query Parameters Encoded with HTML Entities

    - by BRADINO
    I came across a situation where a URL with multiple query parameters was encoded using htmlentities() and PHP was not recognizing the query parameters using $_GET. A common case for encoding urls using htmlentities() is to use them inside XML documents. So a url with multiple query parameters, encoded using htmlentities() would look like this: http://www.bradino.com/?color=white&amp;size=medium&amp;quantity=3 and when that url is accessed the second and third query parameters are not recognized because instead of separating the subsequent variables with an & that character gets converted into &amp;. I could not find a good way to resolve this, so basically I just encoded the query string back to normal using html_entity_decode() and then slammed the parameters back into the $_GET array using parse_str(). $query = html_entity_decode($_SERVER['QUERY_STRING']); parse_str($query,$_GET); There must be a better way! Anyone come across this before?

    Read the article

  • Try/Catch or test parameters

    - by Ondra Morský
    I was recently on a job interview and I was given a task to write simple method in C# to calculate when the trains meet. The code was simple mathematical equation. What I did was that I checked all the parameters on the beginning of the method to make sure, that the code will not fail. My question is: Is it better to check the parameters, or use try/catch? Here are my thoughts: Try/catch is shorter Try/catch will work always even if you forget about some condition Catch is slow in .NET Testing parameters is probably cleaner code (Exceptions should be exceptional) Testing parameters gives you more control over return values I would prefer testing parameters in methods longer than +/- 10 lines, but what do you think about using try/catch in simple methods just like this – i.e. return (a*b)/(c+d); There are many similar questions on stackexchnage, but I am interested in this particular scenario.

    Read the article

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