Search Results

Search found 5259 results on 211 pages for 'interrupt handling'.

Page 59/211 | < Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >

  • Handling JSON and HTML templates in jQuery

    - by Toby Hede
    I have an ajax-enabled site that presents a lot of dynamic content by interpolating JSON values with HTML. This all works fine. BUT it means I have significant amounts of HTML all through my JavaScript. For example: var template = "<div>Foo: {bar}</div><div>Blah: {vtha}</div>"; template.interpolate({bar:"bar",blah:"vtha"}); I have cut this down a fair bit - some of my dynamic elements have quite a lot of HTML and a lot going on. I am using jQuery and I am building on Rails, so if there is something smart in either framework, that would be great. For reference, the String interpolation function used above is: String.prototype.interpolate = function (o) { return this.replace(/{([^{}]*)}/g, function (a, b) { var r = o[b]; return typeof r === 'string' || typeof r === 'number' ? r : a; } ); };

    Read the article

  • Php string handling triks

    - by Dam
    Hi my question Need to get the 10 word before and 10 words after for the given text . i mean need to start the 10 words before the keyword and end with 10 word after the key word. Given text : "Twenty-three" The main trick : content having some html tags etc .. tags need to keep that tag with this content only . need to display the words from 10before - 10after content is bellow : <div id="hpFeatureBoxInt"><h3><a href="/go/homepage/i/int/news/world/1/-/news/1/hi/world/europe/8592190.stm">Suicide bombings hit Moscow Metro</a></h3><p>Past suicide bombings in Moscow have been blamed on Islamist rebels At least 35 people have been killed after two female suicide bombers blew themselves up on Moscow Metro trains in the morning rush hour,<h2><span class="dy">Top News Story</span></h2> officials say.<img height="150" width="201" alt="Emergency services carry a body from a Metro station in Moscow (29 March 2010)" src="http://wwwimg.bbc.co.uk/feedengine/homepage/images/_47550689_moscowap203_201x150.jpg">Twenty-three died in the first blast at 0756 (0356 GMT) as a<a href="#"> train stood </a>at the central Lubyanka station, beneath the offices of the FSB intelligence agency.About 40 minutes later, a second explosion ripped through a train at Park Kultury, leaving another 12 dead.No-one has said they carried out the worst attack in the capital since 2004. </p><p id="fbilisten"><a href="/go/homepage/i/int/news/heading/-/news/">More from BBC News</a></p></div> Thank you

    Read the article

  • How to get the name of the method that caused the exception

    - by SKumar
    My code looks as below. try { _productRepo.GetAllProductCategories(); } catch (Exception ex) { //Do Something } I need a way to show the method name, suppose in the above case if any exception is thrown in the GetAllProductCategories() method, I need to get this method name i.e. "GetAllProductCategories()" as my result. Can any one suggest me how to do this?

    Read the article

  • Direct flow depending on incoming dynamic type

    - by Improfane
    I have a listener class that accepts GUI change events in one method. The incoming event objects have a superclass of a type of GUI Event, the behaviour should depend on the dynamic type of the incoming variable. I wanted to do do lots of methods like: handleGUIEvent(EventChangedX event) handleGUIEvent(EventChangedY event) I am using a single event listener and receiving objects of various types but the behaviour should be different for each. What would you do? I do not want to use a switch statement as this would get unmaintainable.

    Read the article

  • error handling with .post()

    - by meo
    I have to modify a project written by someone else. Because the code is a mess i can't really change this $.post() (or replace it by $.ajax()). What i need to do, is to know if the post returns something else then json and return it. $.post('balbal.html', json, function(data) { ... my coude ... }, 'json') I can see the post response i the console.log. Is there a simple way to retrieve it?

    Read the article

  • Class destructor memory handling in C++

    - by wyatt
    What potential memory leaks won't an implicit destructor handle? I know that if you have anything stored on the heap it won't handle it, and if you have a connection to a file or a database, that needs to be handled manually. Is there anything else? What about, say, non-base data types like vectors? Also, in an explicit destructor, need you destroy non-heap variables which would have been destroyed by the implicit, or are they handled automatically? Thanks

    Read the article

  • GetWindowLongPtr fails if called when handling WM_CREATE

    - by Semen Semenych
    Calling the GetWindowLongPtr function for a dialog box with the DWL_USER parameter fails when done from the WM_CREATE handler. It gives no error (checked that, the return value is always zero), which, according to the MSDN documentation, occurs only if SetWindowLongPtr has not been called previously. However, I call it after registering the window class, and properly call the SetWindowPos after that. Finally, calling GetWindowLongPtr in any other event handler, that is, later than WM_CREATE, works fine. Is there something I'm missing in the initialization sequence, or maybe the messages are sent in some not so obvious order?

    Read the article

  • How should I handle the case in which a username is already in use?

    - by idealmachine
    I'm a JavaScript programmer and new to PHP and MySQL (want to get into server-side coding). Because I'm trying to learn PHP by building a simple online game (more specifically, correspondence chess), I'm starting by implementing a simple user accounts system. Of course, user registration comes first. What are the best practices for: How I should handle the (likely) possibility that when a user tries to register, the username he has chosen is already in use, particularly when it comes to function return values?($result === true is rather ugly, and I'm not sure whether checking the MySQL error code is the best way to do it either) How to cleanly handle varying page titles?($gPageTitle = '...'; require_once 'bgsheader.php'; is also rather ugly) Anything else I'm doing wrong? In some ways, PHP is rather different from JavaScript... Here is a (rather large) excerpt of the code I have written so far. Note that this is a work in progress and is missing security checks that I will add as my next step. function addUser( $username, $password ) { global $gDB, $gPasswordSalt; $stmt = $gDB->prepare( 'INSERT INTO user(user_name, user_password, user_registration) VALUES(?, ?, NOW())' ); $stmt || trigger_error( 'Failed to prepare statement: ' . htmlspecialchars( $gDB->error ) ); $hashedPassword = hash_hmac( 'sha256', $password, $gPasswordSalt, true ); $stmt->bind_param( 'ss', $username, $hashedPassword ); if( $stmt->execute() ) { return true; } elseif( $stmt->errno == 1062) { return 'exists'; } else { trigger_error( 'Failed to execute statement: ' . htmlspecialchars( $stmt->error ) ); } } $username = $_REQUEST['username']; $password = $_REQUEST['password']; $result = addUser( $username, $password ); if( $result === true ) { $gPageTitle = 'Registration successful'; require_once 'bgsheader.php'; echo '<p>You have successfully registered as ' . htmlspecialchars( $username ) . ' on this site.</p>'; } elseif( $result == 'exists' ) { $gPageTitle = 'Username already taken'; require_once 'bgsheader.php'; echo '<p>Someone is already using the username you have chosen. Please try using another one instead.'; } else { trigger_error('This should never happen'); } require_once 'bgsfooter.php';

    Read the article

  • Confirmation before closing

    - by saeed
    Hi I am using c# .net windows form application. I have a combo box and a text box and a close window button. Now If I make any change in the combo box or textbox and click on the close window button, it should prompt the user to save the modifications.. If no modification are made ( The user will just run the application, doesnt make any modification) then it should not prompt the user. It should close directly.. How can I do this?

    Read the article

  • Handling Complex Rules in in GUI applciations (C++ or C#)

    - by Canacourse
    Im working on a dialog box in which several rules must be satisfied before the OK button is enabled. Currently any action on the page such as entering data or selecting an item from a drop down list (amongst other things) calls a single function called ProcessEvent() - this function handles all logic and either enables or disables the OK button. My problem is I finding it difficult making the rules concise and understandable. Some of the rules can be negated by another action on the dialog and I have now ended up with if else statements all over the place or which are difficult to read and follow & extend. The code below is a simplification of the problem but demonstrates it well. How do I handle this problem better (If its Possible) bool CWorkstation::ProcessEvent(void) { UpdateData(); CharCount = GetDlgItemInt(IDC_CharCount, NULL, FALSE); //get latest if ( IsDlgButtonChecked(IDC_USEDBNAME)) { if (!IsDlgButtonChecked(IDC_MAXDBNAME)) { EnableNext(TRUE); } } if (IsDlgButtonChecked(IDC_MAXDBNAME) && CharCount) { if (IsDlgButtonChecked(IDC_USEXMLNAME)) { if ( PrefixName.IsEmpty() ) { EnableNext(FALSE); } else { EnableNext(TRUE); } } } if (IsDlgButtonChecked(IDC_USEXMLNAME) && PrefixName.GetLength() > 1) { EnableNext(TRUE); } if ( IsDlgButtonChecked(IDC_WSAUTONAME) || IsDlgButtonChecked(IDC_RENAMEIFDUP)) { // TRACE("IDC_WSAUTONAME is Checked\n"); if ( IsDlgButtonChecked(IDC_USEXMLNAME) && PrefixName.GetLength() > 1 ) { if ( IsDlgButtonChecked(IDC_IDC_USESHORTNAME) ) { EnableNext(TRUE); } else if ( IsDlgButtonChecked(IDC_USELONGNAME) ) { EnableNext(TRUE); } else { EnableNext(FALSE); } } if ( !IsDlgButtonChecked(IDC_USEPREFIX) ) { if ( IsDlgButtonChecked(IDC_IDC_USESHORTNAME) || IsDlgButtonChecked(IDC_USELONGNAME) ) { EnableNext(TRUE); } } return false; } }

    Read the article

  • pushd - handling multiple drives from cmd

    - by user673600
    I'm trying to figure out how to install some programs where the components reside on two different drives on a networked path. However whenever I use pushd \\xyz\c$ I get a mapped drive which means I cannot use any knowledge of using for example c:\install e:\mycomponents.dll. Is there anyway that I can do this once I have used the pushd command? How can I ensure that I keep the drives the same for example. I'm in the process of installing services. So it seems that when I install the service, I need to keep the path as the same as the actual location of the .exe which means that I'm running into issues. Is there a way to simply use pushd but at the sametime not actually map drives? As when installing services, when I've been using net use, I've found that there is an issue with installing on drives which are mapped, as the service whilst can be installed doesn't find the actual .exe when it comes to starting up the service. So to expand this, is there a way to solve this using net use or pushd or a combination that lets me install a service as such: c:\windows\..\installutil e:\mynode? So to clarify, I need to somehow be able to see both drives on the remote machine by their relative drives i.e. E:\ and C:\ - if I use a mapped drive letter then it means installing service is a pain because I cannot use the path.

    Read the article

  • ASP .NET Added Event Handlers to buttons on Page_Load. Event handlers do not fire the first click, b

    - by John
    Background: I am customizing an existing ASP .NET / C# application. It has it's own little "framework" and conventions for developers to follow when extending/customizing its functionality. I am currently extending some of it's administrative functionality, to which the framework provides a contract to enforce implementation of the GetAdministrationInterface() method, which returns System.Web.UI.Control. This method is called during the Page_Load() method of the page hosting the GUI interface. Problem: I have three buttons in my GUI, each of which have been assigned an Event Handler. My administration GUI loads up perfectly fine, but clicking any of the buttons doesn't do what I expect them to do. However, when I click them a second time, the buttons work. I placed breakpoints at the the beginning of each event handler method and stepped through my code. On the first click, none of the event handlers are triggered. On the second click, they are triggered. Any ideas? Example of Button Definition Button btn = new Button(); btn.Text = "Click Me Locked Screen"; bth.Click += new EventHandler(Btn_Click); Example of Event Handler Method Definition void Btn_Click(object sender, EventArgs e) { // Do Something }

    Read the article

  • After calling a COM-dll component, C# exceptions are not caught by the debugger

    - by shlomil
    I'm using a COM dll provided to me by 3rd-party software company (I don't have the source code). I do know for sure they used Java to implement it because their objects contain property names like 'JvmVersion'. After I instantiated an object introduced by the provided COM dll, all exceptions in my C# program cannot be caught by the VS debugger and every time an exception occurs I get the default Windows Debugger Selection dialog (And that's while executing my program in debug mode under a full VisualStudio debugging environment). To illustrate: throw new Exception("exception 1"); m_moo = new moo(); // Component taken from the COM-dll throw new Exception("exception 2"); Exception 1 will be caught by VS and show the "yellow exception window". Exception 2 will open a dialog titled "Visual Studio Just-In-Time Debugger" containing the text "An unhandled win32 exception occurred in myfile.vshost.exe[1348]." followed by a list of the existing VS instances on my system to select from. I guess the instantiation of "moo" object overrides C#'s exception handler or something like that. Am I correct and is there a way to preserve C#'s exception handler?

    Read the article

  • Freetype2 (error-)return value documentation

    - by Awaki
    In short, I'm looking for documentation that would limit the error situations to check for after a Freetype library function failed, much like the OpenGL and Win32 APIs document the error codes generated by their respective functions. I can't seem to find such documentation though, so I was wondering how to best handle translation of Freetype errors to typed exceptions. Background: I am currently in the process of implementing font-rendering capability (using Freetype) for my GUI framework, which makes strong use of typed exceptions to indicate error situations. However, the Freetype docs seem to completely omit what errors can be expected from what functions. That, if such documentation does indeed not exist, would basically leave me with two options: either guessing which errors make sense for a certain Freetype function (obviously prone to mistakes on my part), or considering every error code for translation into appropriate exceptions (less verbose since I would have to write the translation only once). Performance isn't really critical in the code that calls the Freetype library, so even the latter option would probably be acceptable, but surely there must be some kind of documentation on which library calls may return what Freetype error? Is there any such documentation which I just somehow managed to not find? Should I go the route of generically expecting every error code for translation? Or are there other ways to approach this problem? By the way, I wanted to avoid introducing some kind of generic FreetypeException (containing a description of the Freetype error) since I intended to completely hide what libraries I'm using (not from a legal point-of-view, mind you), but I guess I can be convinced to do this anyway if the consensus is that it would be the best option. I don't think it matters for this question, but I'm writing in C++.

    Read the article

  • Handling large (object) datasets with PHP

    - by Aron Rotteveel
    I am currently working on a project that extensively relies on the EAV model. Both entities as their attributes are individually represented by a model, sometimes extending other models (or at least, base models). This has worked quite well so far since most areas of the application only rely on filtered sets of entities, and not the entire dataset. Now, however, I need to parse the entire dataset (IE: all entities and all their attributes) in order to provide a sorting/filtering algorithm based on the attributes. The application currently consists of aproximately 2200 entities, each with aproximately 100 attributes. Every entity is represented by a single model (for example Client_Model_Entity) and has a protected property called $_attributes, which is an array of Attribute objects. Each entity object is about 500KB, which results in an incredible load on the server. With 2000 entities, this means a single task would take 1GB of RAM (and a lot of CPU time) in order to work, which is unacceptable. Are there any patterns or common approaches to iterating over such large datasets? Paging is not really an option, since everything has to be taken into account in order to provide the sorting algorithm.

    Read the article

  • MS Exam 70-536 - How to throw and handle exception from thread?

    - by Max Gontar
    Hello! In MS Exam 70-536 .Net Foundation, Chapter 7 "Threading" in Lesson 1 Creating Threads there is a text: Be aware that because the WorkWithParameter method takes an object, Thread.Start could be called with any object instead of the string it expects. Being careful in choosing your starting method for a thread to deal with unknown types is crucial to good threading code. Instead of blindly casting the method parameter into our string, it is a better practice to test the type of the object, as shown in the following example: ' VB Dim info As String = o as String If info Is Nothing Then Throw InvalidProgramException("Parameter for thread must be a string") End If // C# string info = o as string; if (info == null) { throw InvalidProgramException("Parameter for thread must be a string"); } So, I've tried this but exception is not handled properly (no console exception entry, program is terminated), what is wrong with my code (below)? class Program { static void Main(string[] args) { Thread thread = new Thread(SomeWork); try { thread.Start(null); thread.Join(); } catch (InvalidProgramException ex) { Console.WriteLine(ex.Message); } finally { Console.ReadKey(); } } private static void SomeWork(Object o) { String value = (String)o; if (value == null) { throw new InvalidProgramException("Parameter for "+ "thread must be a string"); } } } Thanks for your time!

    Read the article

  • Grails remoteLink handling error codes

    - by soybie
    I'm on grails 1.3.6 and I see the following behavior. <g:javascript library="prototype" /> ... <g:remoteLink action="punch" id="${personInstance.id}" update="damage_${personInstance.id}" on401="alert('foo!');"> generates: <a on401="alert('foo!');" onclick="new Ajax.Updater('damage_5','/blah/person/punch/5',{asynchronous:true,evalScripts:true});return false;" href="/blah/person/punch/5"></a> "on401" isn't a supported event attribute for an anchor tag, so is this a bug in grails?

    Read the article

  • ThreadExceptionEventHandler and invoking delegates

    - by QmunkE
    If I assign a ThreadExceptionEventHandler to Application.ThreadException, why when I invoke a delegate method using a control on the main application thread are any exceptions thrown by that delegate not triggering the event handler? i.e. static void Main() { ... Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); Application.Run(new Form1()); } static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { Console.Error.Write("A thread exception occurred!"); } ... private void Form1_Load(object sender, EventArgs e) { Thread syncThread = new Thread(new ThreadStart(this.ThrowException)); syncThread.Start(); } private void ThrowException() { button1.Invoke(new MethodInvoker(delegate { // Not handled by ThreadExceptionEventHandler? throw new Exception(); })); } The context on this is that I have a background thread started from a form which is throwing an unhandled exception which terminates the application. I know this thread is going to be unreliable since it is network connectivity reliant and so subject to being terminated at any point, but I'm just interested as to why this scenario doesn't play out as I expect?

    Read the article

  • In Asp.net i'm not able to catch any exception properly?

    - by Anand
    In Asp.net (c#),i'm not able to catch exception(FileNotFoundException) properly... i don't know the reason..Actually File s not there..But catch statement fails to catch the exception.. here is the code.. try { System.Drawing.Image imgg1 = System.Drawing.Image.FromFile(Server.MapPath("").ToString() + "\\images\\img1.jpg"); } catch (FileNotFoundException) { Response.Write("<script>alert('Please Select and upload Student's Photo');</script>"); }

    Read the article

  • C# wpf: Need to add mouseclick event to certain text within a textbox

    - by Michael
    I have a textbox with a paragraph of information. There are certain words in the paragraph that i want the user to be able to click on, and when clicked, a different textbox is populated with more information. I know that you can have the event for the whole textbox, but that isn't want i want. I only want to call that event when certain words within the box are clicked.

    Read the article

  • How do I propagate an exception thrown by croak in forked child to parent/foreground process?

    - by Pedro Silva
    Throwing an exception via croak in a forked child process seems to print the error as a background process would. That is, it clobbers the shell prompt. If I die instead of croak, the the error message pops up as a foreground process. I've trying to find out why that is in the Carp documentation without any luck. Here's what I mean. The croak version: $ perl Wrapper.pm $ error: ... does not exist at Wrapper.pm line 624 The die version: $ perl Wrapper.pm error: ... does not exist at Wrapper.pm line 515. I tried trapping the fork and printing $@ to STDERR and exiting, but that didn't have an effect. Any ideas? I'd like to be able to use croak in this particular case.

    Read the article

  • Global Exception Handlers in Java

    - by Samuh
    I am thinking of setting up a global, default Exception handler for my (Android) Mobile application(which uses Java syntax) using Thread.setDefaultUncaughtExceptionHandler(...) call. I am thinking of just displaying an Alert Dialog with appropriate message to the user. Are there any gotchas, caveats and rules that one needs to follow when setting DefaultExceptionHandlers? Any best practices like making sure that the process is killed, full stack trace is written to logs etc. ? Links to documentation, tutorials etc. that can throw some light on this are welcome. Thanks.

    Read the article

  • Handling Messages in Console Apps/DLLs in C++ Win32

    - by vsimon
    I would like to have the ability to process Win32 messages in a console app and/or inside a standalone DLL. I have been able to do it in .NET with the following article and it works great in C# inside a console app and standalone DLL http://msdn.microsoft.com/en-us/magazine/cc163417.aspx Is there a way to do the equivalent with C/C++ Win32 APIs? I have tried doing RegisterClassEx(...) and CreateWindow(...) even passing in HWND_MESSAGE to hWndParent but the trouble is that after the "invisible" window is created messages are not being processed probably due to the lack of a message pump. Where would the message pump go if you had a DLL entry point? I have tried creating another thread in a DLL and put while(GetMesage(..)) there but that did not work either. Any ideas?

    Read the article

  • java Swing Listeners: components listening at each others.

    - by Pierre
    Hi all, I want to code two JList (categories and items). When I click one category it should select all the items for that category and when I click on one item it should select its categories. So both JList will have a ListSelectionListener listening at each other and changing the selection. Should I fear about some a of "loop" ? Is there a way to tell that an Event has been consumed ? how do people manage that kind of situation ? Thanks

    Read the article

< Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >