Search Results

Search found 1863 results on 75 pages for 'matt fordham'.

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

  • 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

  • Yield only as many are required from a generator

    - by Matt Joiner
    I wish to yield from a generator only as many items are required. In the following code a, b, c = itertools.count() I receive this exception: ValueError: too many values to unpack I've seen several related questions, however I have zero interest in the remaining items from the generator, I only wish to receive as many as I ask for, without providing that quantity in advance. It seems to me that Python determines the number of items you want, but then proceeds to try to read and store more than that number. How can I yield only as many items as I require, without passing in how many items I want?

    Read the article

  • Why isn't my algorithm for find the biggest and smallest inputs working?

    - by Matt Ellen
    I have started a new job, and with it comes a new language: Ironpython. Thankfully a good language :D Before starting I got to grips with Python on the whole, but that was only a week's worth of learning. Now I'm writing actual code. I've been charged with writing an algorithm that finds the best input parameter to collect data with. The basic algorithm is (as I've been instructed): Set the input parameter to a good guess Start collecting data When data is available stop collecting find the highest point If the point before this (i.e. for the previous parameter value) was higher and the point before that was lower then we've found the max otherwise the input parameter is increased by the initial guess. goto 2 If the max is found then the min needs to be found. To do this the algorithm carries on increasing the input, but by 1/10 of the max, until the current point is greater than the previous point and the point before that is also greater. Once the min is found then the algorithm stops. Currently I have a simplified data generator outputting the sin of the input, so that I know that the min value should be PI and the max value should be PI/2 The main Python code looks like this (don't worry, this is just for my edification, I don't write real code like this): import sys sys.path.append(r"F:\Programming Source\C#\PythonHelp\PythonHelp\bin\Debug") import clr clr.AddReferenceToFile("PythonHelpClasses.dll") import PythonHelpClasses from PHCStruct import Helper from System import Math helper = Helper() def run(): b = PythonHelpClasses.Executor() a = PythonHelpClasses.HasAnEvent() b.Input = 0.0 helper.__init__() def AnEventHandler(e): b.Stop() h = helper h.lastLastVal, h.lastVal, h.currentVal = h.lastVal, h.currentVal, e.Number if h.lastLastVal < h.lastVal and h.currentVal < h.lastVal and h.NotPast90: h.NotPast90 = False h.bestInput = h.lastInput inputInc = 0.0 if h.NotPast90: inputInc = Math.PI/10.0 else: inputInc = h.bestInput/10.0 if h.lastLastVal > h.lastVal and h.currentVal > h.lastVal and h.NotPast180: h.NotPast180 = False if h.NotPast180: h.lastInput, b.Input = b.Input, b.Input + inputInc b.Start(a) else: print "Best input:", h.bestInput print "Last input:", h.lastInput b.Stop() a.AnEvent += AnEventHandler b.Start(a) PHCStruct.py: class Helper(): def __init__(self): self.currentVal = 0 self.lastVal = 0 self.lastLastVal = 0 self.NotPast90 = True self.NotPast180 = True self.bestInput = 0 self.lastInput = 0 PythonHelpClasses has two small classes I wrote in C# before I realised how to do it in Ironpython. Executor runs a delegate asynchronously while it's running member is true. The important code: public void Start(HasAnEvent hae) { running = true; RunDelegate r = new RunDelegate(hae.UpdateNumber); AsyncCallback ac = new AsyncCallback(UpdateDone); IAsyncResult ar = r.BeginInvoke(Input, ac, null); } public void Stop() { running = false; } public void UpdateDone(IAsyncResult ar) { RunDelegate r = (RunDelegate)((AsyncResult)ar).AsyncDelegate; r.EndInvoke(ar); if (running) { AsyncCallback ac = new AsyncCallback(UpdateDone); IAsyncResult ar2 = r.BeginInvoke(Input, ac, null); } } HasAnEvent has a function that generates the sin of its input and fires an event with that result as its argument. i.e.: public void UpdateNumber(double val) { AnEventArgs e = new AnEventArgs(Math.Sin(val)); System.Threading.Thread.Sleep(1000); if (null != AnEvent) { AnEvent(e); } } The sleep is in there just to slow things down a bit. The problem I am getting is that the algorithm is not coming up with the best input being PI/2 and the final input being PI, but I can't see why. Also the best and final inputs are different each time I run the programme. Can anyone see why? Also when the algorithm terminates the best and final inputs are printed to the screen multiple times, not just once. Can someone explain why?

    Read the article

  • How to make sure that Parameters have been updated in a Dataset Provider

    - by Matt
    In a Delphi app we have assigned a dataset provider with a TADOQuery, passing parameters to the Query. When the TADOQuery is refreshed with new parameter values these are not being passed to the Dataset Provider. This seemed to work ok in Delphi 5, but we are migrating our application to Delphi 2010 and it seems to have broken this link. Is there a way of refreshing the parameters against the dataset provider with the new values?

    Read the article

  • R counting the occurance of similar rows of data frame

    - by Matt
    I have data in the following format called DF (this is just a made up simplified sample): eval.num, eval.count, fitness, fitness.mean, green.h.0, green.v.0, offset.0 random 1 1 1500 1500 100 120 40 232342 2 2 1000 1250 100 120 40 11843 3 3 1250 1250 100 120 40 981340234 4 4 1000 1187.5 100 120 40 4363453 5 1 2000 2000 200 100 40 345902 6 1 3000 3000 150 90 10 943 7 1 2000 2000 90 90 100 9304358 8 2 1800 1900 90 90 100 284333 However, the eval.count column is incorrect and I need to fix it. It should report the number of rows with the same values for (green.h.0, green.v.0, and offset.0) by only looking at the previous rows. The example above uses the expected values, but assume they are incorrect. How can I add a new column (say "count") which will count all previous rows which have the same values of the specified variables? I have gotten help on a similar problem of just selecting all rows with the same values for specified columns, so I supposed I could just write a loop around that, but it seems inefficient to me.

    Read the article

  • When to use a module, and when to use a class

    - by Matt Briggs
    I am currently working through the Gregory Brown Ruby Best Practices book. Early on, he is talking about refactoring some functionality from helper methods on a related class, to some methods on module, then had the module extend self. Hadn't seen that before, after a quick google, found out that extend self on a module lets methods defined on the module see each other, which makes sense. Now, my question is when would you do something like this module StyleParser extend self def process(text) ... end def style_tag?(text) ... end end and then refer to it in tests with @parser = Prawn::Document::Text::StyleParser as opposed to just using a class with some class methods on it? is it so that you can use it as a mixin? or are there other reasons I'm not seeing?

    Read the article

  • ODBC vs MySQLClient

    - by Matt
    I'm currently using ODBC to connect to my MySQL database, using C#. I've been told that using the MySql Connector would be better, and faster, and not dependent on Windows. Can someone shed some light on this please? I've been unable to find anything on the net so far

    Read the article

  • Securely persist session between https://secure.yourname.com and http://www.yourname.com on rails ap

    - by Matt
    My rails site posts to a secure host (e.g. 'https://secure.yourname.com') when the user logs into the site. Session data is stored in the database, with the cookie containing only the session ID. The problem is that when the user returns to a non-https page, such as the home page (e.g. 'http://www.yourname.com') the user appears to have logged out. I believe the reason for this is that a separate cookie is stored for each host (www vs. secure). Is this correct? What is the best secure way to persist the session between both the http and https sections of the site? Does anyone know of any plugins that address this problem? The site runs on Heroku.

    Read the article

  • Reliable way to get the "ancestor" of an object with a specific classname, using jQuery

    - by Matt Dawdy
    I've got a javascript function that gets called on change event of a select form element. So, the "this" variable in js refers to the select element. This select element is in a td tag, in a tr tag. The tr tag has a classname of "FilterDetailsRow". Now, I've tested, and if I use this syntax: var filterRow = $(this).parent().parent(); it gets me what I want. However, is there a better way to tell jQuery, "starting with "this" can you please go up my tree of parents until you find one with a classname of "FilterDetailsRow"? Here's what I came up with, but I want to make sure I"m not reinventing the wheel. function GetFilterDetailsRowOfObject(o) { if (o) { if (o.parent()[0].className.indexOf("FilterDetailsRow") != -1) return o; else return GetFilterDetailsRowOfObject(o.parent()); } else { return null; } } Thanks for any advice.

    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

  • send keystrokes from iphone to PC

    - by Matt Facer
    hi guys. I'm looking to create a simple app which will send keystrokes from an iphone to a PC. I understand that I will need to have a program on my PC "listening"... I've been looking in to AsyncSocket and NSStream, but there are no tutorials which really make it clear to understand. Does anyone know if this is right? I basically want to interact with a program on my PC which listens for keystrokes to control it. Does anyone know of a tutorial or place where I could start to learn this? (I've written iphone apps before, but I am new to networking)

    Read the article

  • Return a value if no rows are found SQL

    - by Matt
    Here's my simple query. If I query a record that doesn't exist then I will get nothing returned. I'd prefer that false (0) is returned in that scenario. Looking for the simplist method to account for no records. SELECT CASE WHEN S.Id IS NOT NULL AND S.Status = 1 AND (S.WebUserId = @WebUserId OR S.AllowUploads = 1) THEN 1 ELSE 0 END AS [Value] FROM Sites S WHERE S.Id = @SiteId

    Read the article

  • C/C++ Allegro program causes Windows 7 to switch to Aero Basic

    - by Matt H
    Hi SO, I'm just trying out the allegro library, and here is the code which I've got so far: #include <allegro.h> int main(int argc, char *argv[]) { allegro_init(); // initialize the allegro libraries install_keyboard(); // initialize keyboard functions set_color_depth(16); // set the color depth set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); // set up 640*480px window BITMAP *pic = NULL; pic = load_bitmap("C:/picture.bmp", NULL); // load the picture blit(pic, screen, 0, 0, 0, 0, 1000, 1000); readkey(); destroy_bitmap(pic); return 0; } END_OF_MAIN() It works fine, but when I run it, while the program's window is open, Windows 7 changes the theme from Aero to Aero basic. If you aren't sure what I mean, this pops up (I got this from Google, which is why it says Vista rather than Windows 7): 1) Why? 2) How can I ensure that this doesn't happen?

    Read the article

  • Trouble extending event log messages

    - by Matt H
    Hi. I'm trying to add some extended error codes to the event log but I get the following error. The description for Event ID ( 109 ) in Source ( PumpServer ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: The event log file is corrupt.. The message file looks like this and I added the one on the end:- <---snip---> MessageId= SymbolicName=EVMSG_BADREQUEST Language=English The service received an unsupported request. . MessageId= SymbolicName=EVMSG_DEBUG Language=English %1 . MessageId= SymbolicName=EVMSG_STOPPED Language=English The service was stopped. . MessageId= SymbolicName=EVMSG_INVALIDLICENCE Language=English The service does not have a valid licence. Initialization failed. . It compiles fine. The mc program is running over this file and producing a header file of the same name with my new message id showing. // // MessageId: EVMSG_INVALIDLICENCE // // MessageText: // // The service does not have a valid licence. Initialization failed. // #define EVMSG_INVALIDLICENCE 0x0000006DL Any ideas why it's not finding my message? All the others work.

    Read the article

  • iPhone sdk can't get Mobclix to work

    - by Matt S.
    I followed the guide here, and when I build my application the ad (or anything for that matter) doesn't show up. Nothing, nada. I followed the guide very carefully. I know that it is trying to retrieve an ad (thanks to little snitch), but it doesn't display. Has anybody experienced this and do you know of a fix?

    Read the article

  • PHP templating challenge (optimizing front-end templates)

    - by Matt
    Hey all, I'm trying to do some templating optimizations and I'm wondering if it is possible to do something like this: function table_with_lowercase($data) { $out = '<table>'; for ($i=0; $i < 3; $i++) { $out .= '<tr><td>'; $out .= strtolower($data); $out .= '</td></tr>'; } $out .= "</table>"; return $out; } NOTE: You do not know what $data is when you run this function. Results in: <table> <tr><td><?php echo strtolower($data) ?></td></tr> <tr><td><?php echo strtolower($data) ?></td></tr> <tr><td><?php echo strtolower($data) ?></td></tr> </table> General Case: Anything that can be evaluated (compiled) will be. Any time there is an unknown variable, the variable and the functions enclosing it, will be output in a string format. Here's one more example: function capitalize($str) { return ucwords(strtolower($str)); } If $str is "HI ALL" then the output is: Hi All If $str is unknown then the output is: <?php echo ucwords(strtolower($str)); ?> In this case it would be easier to just call the function (ie. <?php echo capitalize($str) ?> ), but the example before would allow you to precompile your PHP to make it more efficient

    Read the article

  • PHP templating challenge (optimizing front-end templates)

    - by Matt
    Hey all, I'm trying to do some templating optimizations and I'm wondering if it is possible to do something like this: function table_with_lowercase($data) { $out = '<table>'; for ($i=0; $i < 3; $i++) { $out .= '<tr><td>'; $out .= strtolower($data); $out .= '</td></tr>'; } $out .= "</table>"; return $out; } NOTE: You do not know what $data is when you run this function. Results in: <table> <tr><td><?php echo strtolower($data) ?></td></tr> <tr><td><?php echo strtolower($data) ?></td></tr> <tr><td><?php echo strtolower($data) ?></td></tr> </table> General Case: Anything that can be evaluated (compiled) will be. Any time there is an unknown variable, the variable and the functions enclosing it, will be output in a string format. Here's one more example: function capitalize($str) { return ucwords(strtolower($str)); } If $str is "HI ALL" then the output is: Hi All If $str is unknown then the output is: <?php echo ucwords(strtolower($str)); ?> In this case it would be easier to just call the function (ie. <?php echo capitalize($str) ?> ), but the example before would allow you to precompile your PHP to make it more efficient

    Read the article

  • Google Translate translates Javascript Code

    - by Matt
    Hi, I have some PHP code that sends a section of html code including some inline Javascript code by curl to google. When i get it back from Google translated into the language that i chose, the Javascript code has been translated too. Any ideas as to how i can stop Google translating my inline JavaScript code? Thanks, M

    Read the article

  • Best practice. Do I save html tags in DB or store the html entity value?

    - by Matt
    Hi Guys, I was wondering about which way i should do the following. I am using the tiny MCE wysiwyg editor which formats the users data with the right html tags. Now, i need to save this data entered into the editor into a database table. Should I encode the html tags to their corresponding entities when inserting into the DB, then when i get the data back from the table, not have the encode it for XSS purposes but I'd still have to use eval for the html tags to format the text. OR Do i save the html tags into the database, then when i get the data back from the database encode the html tags to their entities, but then as the tags will appear to the user, I'd have to use the eval function to actually format the data as it was entered. My thoughts are with the first option, I just wondered on what you guys thought.

    Read the article

  • Pass variable to Google Custom Search Engine

    - by Matt
    Is it possible to pass a search variable into the Google Custom Search Engine that I have embedded on my website? I can get the search engine to work, but I can't pass it a term via POST (it's coming from a search button on other pages of the website) I tried to hack the code I found here: http://code.google.com/apis/ajax/playground/?exp=search#hello_world And this is what I have so far... ($q is the term I am passing to it) <script type="text/javascript"> google.load('search', '1', {language : 'en'}); function OnLoad() { var customSearchControl = new google.search.CustomSearchControl('***my key****'); customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); customSearchControl.draw('cse'); searchControl.execute("$q"); } google.setOnLoadCallback(OnLoad); </script> Thanks

    Read the article

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