Search Results

Search found 1862 results on 75 pages for 'matt argyle'.

Page 43/75 | < Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >

  • Recursion with an Array; can't get the right value to return

    - by Matt
    Recursive Solution: Not working! Explanation: An integer, time, is passed into the function. It's then used to provide an end to the FOR statement (counter<time). The IF section (time == 0) provides a base case where the recursion should terminate, returning 0. The ELSE section is where the recursive call occurs: total is a private variable defined in the header file, elsewhere. It's initialized to 0 in a constructor, elsewhere. The function calls itself, recursively, adding productsAndSales[time-1][0] to total, again, and again, until the base call. Then the total is returned, and printed out later. Well, that's what I hoped for anyway. What I imagined would happen is that I would add up all the values in this one column of the array and the value would get returned, and printed out. Instead if returns 0. If I set the IF section to "return 1", I noticed that it returns powers of 2, for whatever value time is. EG: Time = 3, it returns 2*2 + 1. If time = 5, it returns 2*2*2*2 + 1. I don't understand why it's not returning the value I'm expecting. int CompanySales::calcTotals( int time ) { cout << setw( 4 ); if ( time == 0 ) { return 0; } else { return total += calcTotals( productsAndSales[ time-1 ][ 0 ]); } } Iterative Solution: Working! Explanation: An integer, time, is passed into the function. It's then used to provide an end to the FOR statement (counter<time). The FOR statement cycles through an array, adding all of the values in one column together. The value is then returned (and elsewhere in the program, printed out). Works perfectly. int CompanySales::calcTotals( int time ) { int total = 0; cout << setw( 4 ); for ( int counter = 0; counter < time; counter++ ) { total += productsAndSales[counter][0]; } return total0; }

    Read the article

  • What's with "foo" and "bar" [closed]

    - by Matt S.
    Possible Duplicates: When foo and bar is not enough Code examples Foo Bar I've always wondered, why is there always "foo" and "bar" named as variables in most tutorials I've seen. Where did it come from? Why do we call them "foo" and "bar" why not something else?

    Read the article

  • Performing your own runtime analysis of your code in C#

    - by Matt
    I have written a large C# app with many methods in many classes. I'm trying to keep a log of what gets called and how often during my development. (I keep a record in a DB) Every method is padded with the following calls: void myMethod() { log(entering,args[]); log(exiting,args[]); } Since I want to do this for all my methods, is there a better way to do this then having to replicate those lines of code in every method?

    Read the article

  • How do I prevent JAXB from binding superclass methods of the @XmlRootElement when marshalling?

    - by Matt Fisher
    I have a class that is annotated as the @XmlRootElement with @XmlAccessorType(XmlAccessType.NONE). The problem that I am having is that the superclass's methods are being bound, when I do not want them to be bound, and cannot update the class. I am hoping there is an annotation that I can put on the root element class to prevent this from happening. Example: @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) public class Person extends NamedObject { @XmlElement public String getId() { ... } } I would expect that only the methods annotated @XmlElement on Person would be bound and marshalled, but the superclass's methods are all being bound, as well. The resulting XML then has too much information. How do I prevent the superclass's methods from being bound without having to annotate the superclass, itself?

    Read the article

  • Unsure of how to get the right evaluation order

    - by Matt Fenwick
    I'm not sure what the difference between these two pieces of code is (with respect to x), but the first one completes: $ foldr (\x y -> if x == 4 then x else x + y) 0 [1,2 .. ] 10 and the second one doesn't (at least in GHCi): $ foldr (\x (y, n) -> if x == 4 then (x, n) else (x + y, n + 1)) (0, 0) [1,2 .. ] ....... What am I doing wrong that prevents the second example from completing when it hits x == 4, as in the first one? I've tried adding bang-patterns to both the x and to the x == 4 (inside a let) but neither seems to make a difference.

    Read the article

  • casting, converting, and input from textbox controls

    - by Matt
    Working on some .aspx.cs code and decided I would forget how to turn a textbox value into a useable integer or decimal. Be warned I'm pretty new to .asp. Wish I could say the same for c sharp. So the value going into my textbox (strawberryp_textbox) is "1" which I presume I can access with the .text property. Which I then parse into a int. The Error reads Format Exception was unhandled by user code. My other question is can I do operations on a session variable? protected void submit_order_button_Click(object sender, EventArgs e) { int strawberryp; int strawberrys; decimal money1 = decimal.Parse(moneybox1.Text); decimal money2 = decimal.Parse(moneybox2.Text); decimal money3 = decimal.Parse(moneybox3.Text); decimal money4 = decimal.Parse(moneybox4.Text); decimal money5 = decimal.Parse(moneybox5.Text); strawberryp = int.Parse(strawberryp_Textbox.Text); //THE PROBLEM RIGHT HERE! strawberrys = int.Parse(strawberrys_Textbox.Text); // Needs fixed int strawberryc = int.Parse(strawberryc_Textbox.Text); //fix int berryp = int.Parse(berryp_Textbox.Text); //fix int raspberryp = int.Parse(raspberryp_Textbox.Text); /fix decimal subtotal = (money1 * strawberryp) + (money2 * strawberrys) + (money3 * strawberryc) + (money4 * berryp) + (money5 * raspberryp); //check to see if you can multiply decimal and int to get a deciaml!! Session["passmysubtotal"] = subtotal; //TextBox2.Text; (strawberryp_Textbox.Text);//TextBox4.Text; add_my_order_button.Enabled = true; add_my_order_button.Visible = true; submit_order_button.Enabled = false; submit_order_button.Visible = false; strawberryp_Textbox.ReadOnly = false; strawberrys_Textbox.ReadOnly = false; strawberryc_Textbox.ReadOnly = false; berryp_Textbox.ReadOnly = false; raspberryp_Textbox.ReadOnly = false; Response.Redirect("reciept.aspx"); } Thanks for the help

    Read the article

  • Load remote csv into CHCSVParser

    - by Matt
    Hey guys. I'm using Dave DeLong's CHCSVParser to parse a csv. I can parse the csv locally, but I cannot get it load a remote csv file. I have been staring at my MacBook way too long today and the answer is right in front of me. Here's my code: NSString *urlStr = [[NSString alloc] initWithFormat:@"http://www.somewhere.com/LunchSpecials.csv"]; NSURL *lunchFileURL = [NSURL URLWithString:urlStr]; NSStringEncoding encoding = 0; CHCSVParser *p = [[CHCSVParser alloc] initWithContentsOfCSVFile:[lunchFileURL path] usedEncoding:&encoding error:nil]; [p setParserDelegate:self]; [p parse]; [p release]; Thanks for any help that someone can give me.

    Read the article

  • Why does gcc add symbols to non-debug build?

    - by Matt Holgate
    When I do a release build with gcc (i.e. I do not specify -g), I still seem to end up with symbols in the binary, and have to use strip to remove them. In fact, I can still breakpoint functions and get backtraces in gdb (albeit without line numbers). This surprised me - can anyone explain why this happens? e.g. #include <stdio.h> static void blah(void) { printf("hello world\n"); } int main(int argc, char *argv[]) { blah(); return 0; } gcc -o foo foo.c nm foo | grep blah: 08048374 t blah

    Read the article

  • CSS Design question, I've got myself completely turned around.

    - by Matt Dawdy
    Okay, I have a couple of other questions out there, but I think I'd better just ask from the beginning how you CSS experts would do this. Client's page is split into 2 rows -- header has some info, some aligned to left of page, some to right, some in the middle. This is currently done using a table. I'm fine with leaving this alone or changing it. My real question is that I need a page layout to handle the following: 2 columns - column on left is 200px, but can be "close" down to to 10px (not a slider, it's either 200 or 10 px). The column on the right needs to be as big as it needs to be -- which might be larger than the width of the page. When left column is "closed" then the right column slides over of course. Again, this right column might be 300px or it might be 4000 pixels (it's a reporting interface). Now, to add another wrinkle, SOME pages have 3 columns. The first 2 columns are each exactly 200px, and both can be "closed" down to 10 px each. But, the user may not close both columns, maybe just 1. Or none. Or both. The third column needs to act just like I described above, being able to be larger than the page width, and sliding over to take advantage of any of the "closed" left columns. Whew! I'm pretty confused as to how to go about this, as either I get it right but I can't scroll over to the right at all (overflow: hidden) and information is lost, or the right column jumps down below the left 2 columns and just looks plain stupid. My minimum browser requirements are IE8, FF3.5, Chrome and Safari (latest versions of all). Any and all pointers are gladly accepted.

    Read the article

  • How to cache YUI DataSource?

    - by Matt McCormick
    I'm setting up a YUI DataTable with filtering by following the steps on the YUI site However, I am using JSON as the DataSource ResponseType. When I type in a value to filter, the request will be sent to the server again. I find this to be wasteful as all the data has already been retrieved the first time. Is there a way to cache the initial data returned and then filter only according to that data so another AJAX request does not have to be made?

    Read the article

  • How to create a JAX-RS service where the sub-resource @Path doesn't have a leading slash

    - by Matt
    I've created a JAX-RS service (MyService) that has a number of sub resources, each of which is a subclass of MySubResource. The sub resource class being chosen is picked based on the parameters given in the MyService path, for example: @Path("/") @Provides({"text/html", "text/xml"}) public class MyResource { @Path("people/{id}") public MySubResource getPeople(@PathParam("id") String id) { return new MyPeopleSubResource(id); } @Path("places/{id}") public MySubResource getPlaces(@PathParam("id") String id) { return new MyPlacesSubResource(id); } } where MyPlacesSubResource and MyPeopleSubResource are both sub-classes of MySubResource. MySubResource is defined as: public abstract class MySubResource { protected abstract Results getResults(); @GET public Results get() { return getResults(); } @GET @Path("xml") public Response getXml() { return Response.ok(getResults(), MediaType.TEXT_XML_TYPE).build(); } @GET @Path("html") public Response getHtml() { return Response.ok(getResults(), MediaType.TEXT_HTML_TYPE).build(); } } Results is processed by corresponding MessageBodyWriters depending on the mimetype of the response. While this works it results in paths like /people/Bob/html or /people/Bob/xml where what I really want is /people/Bob.html or /people/Bob.xml Does anybody know how to accomplish what I want to do?

    Read the article

  • symfony 1.4 adding a BCC recipient to mailer

    - by Matt
    I know with swift directly you can create a Recipient_List and do -addBcc() . How would i do this same thing in the context of symfony 1.4 $message = $this->getMailer()->compose(); $message->setSubject(sfConfig::get('app_email_welcome_subject')); $message->setTo($user->getUsername()); $message->setFrom(sfConfig::get('app_email_from'));

    Read the article

  • Dynamically Forming a JSON object traversion without using eval.

    - by Matt Willhite
    Given I have the following: (which is dynamically generated and varies in length) associations = ["employer", "address"]; Trying to traverse the JSON object, and wanting to form something like the following: data.employer.address or data[associations[0]][association[1]] Without doing this: eval("data."+associations.join('.')); Finally, I may be shunned for saying this, but is it okay to use eval in an instance like this? Just retrieving data.

    Read the article

  • Adding shortcut for WiX file in a different fragment.

    - by matt
    I'm using heat.exe to generate fragments similar to this: <Fragment> <DirectoryRef Id="INSTALLDIR"> <Component Id="id1" Guid="*"> <File Id="fid1" KeyPath="yes" Source="SourceDir\Foo1.dll" /> </Component> <Component Id="id2" Guid="*"> <File Id="fid2" KeyPath="yes" Source="SourceDir\Foo2.dll" /> </Component> <Component Id="id3" Guid="*"> <File Id="fid3" KeyPath="yes" Source="SourceDir\Bar.exe" /> </Component> </DirectoryRef> </Fragment> <Fragment> <ComponentGroup Id="Components"> <ComponentRef Id="id1" /> <ComponentRef Id="id2" /> <ComponentRef Id="id3" /> </ComponentGroup> </Fragment> These fragments are stored in the auto-generated wxs file. I'm then adding them into my feature (in the main WiX file) like so: <ComponentGroupRef Id="Components"/> This works fine. However, I'd also like to add a shortcut to Bar.exe to my start menu. I ideally want to do this in my main wix file, with the Bar.exe component still residing in the auto-generated wxs file. How would I approach this problem without modifying the auto-generated code?

    Read the article

  • How to get strptime to raise ArgumentError with garbage trailing characters

    - by Matt Briggs
    We have to handle user specified date formats in our application. We decided to go with Date.strptime for parsing and validation, which works great, except for how it just ignores any garbage data entered. Here is an irb session demonstrating the issue ree-1.8.7-2010.01 > require 'date' => true ree-1.8.7-2010.01 > d = Date.strptime '2001-01-01failfailfail', '%Y-%m-%d' => #<Date: 4903821/2,0,2299161> ree-1.8.7-2010.01 > d.to_s => "2001-01-01" what we would like, is behavior more like this ree-1.8.7-2010.01 > d = Date.strptime '2001failfailfail-01-01', '%Y-%m-%d' ArgumentError: invalid date Any suggestions would be appreciated

    Read the article

  • Cannot convert object, recieved from ajax call, into a long

    - by Matt
    I'm using Asp.Net-Mvc, I have this method in my controller: [AcceptVerbs(HttpVerbs.Post)] public ActionResult LinkAccount(string site, object id) { return this.Json(id); } Here's the ajax method that calls it: $.post("/Account/LinkAccount", { site: "Facebook", id: FB.Facebook.apiClient.get_session().uid }, function(result) { alert(result); }, "json" ); returning this.Json(id); makes the alert work... it alerts 7128383 (something similar to that). but if I change this.Json(id) to this.Json(Conver.ToInt64(id)); the alert does not fire... Any idea of why I can't convert an object received from an object to a long? I already know changing the LinkAccount method to accept a long instead works just fine. It's just I need it as an object because some other sites I'm linking up have strings for id's rather than longs. UPDATE: I tried running the code on localhost so I could set a breakpoint. First I changed the line return this.Json(Convert.ToInt64(id)); to long idAsLong = Convert.ToInt64(id));. Here's what the debugger is telling me: When I hover over id it says: "id | {string[1]}" and when I press the plus button is shows: "[0] | '7128383'" When I hover over idAsLong, it says: "idAsLong | 0" Why isn't it converting it properly?

    Read the article

  • Set DllImport attribute dynamically

    - by matt-bond
    I am making use of an external unmanaged dll using PInvoke and the DllImport attribute. eg. [DllImport("mcs_apiD.dll", CharSet = CharSet.Auto)] private static extern byte start_api(byte pid, byte stat, byte dbg, byte ka); I am wondering if it is possible to alter the dll file details (mcs_apiD.dll in this example) dynmically in some manner, if for instance I wanted to build against another dll version

    Read the article

  • ASP.Net AJAX controls, adding via .ashx page

    - by Matt Dawdy
    Okay, this is a continuation of a previous question of mine, but it is distinct enough to be its own question. Based on user interaction, I'm calling a .ashx handler via a jquery ajax call, and that handler is building some html for me that includes some Telerik controls like a masked textbox (masked for a phone number like "(###) ###-####". I got around all the hurdles of using Render() to get the html output of a server control even when it doesn't have a "Page" object or a ScriptHandler object. However, when I show the control to a user, I see the mask in the text of the textbox, but the mask doesn't "work" in the sense that when a user starts typing, it is as if the mask is really just text. So, my question is, after putting the html code out for a masked textbox, how do I tell whatever javascript is supposed to mask the input to really start masking on that specific control? I really hope this made sense. Please tell me if you need any clarification.

    Read the article

< Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >