Search Results

Search found 8286 results on 332 pages for 'defined'.

Page 208/332 | < Previous Page | 204 205 206 207 208 209 210 211 212 213 214 215  | Next Page >

  • Java's PipedReader / PipedWriter equivalents in C#?

    - by devoured elysium
    I have defined a Pipe class in Java, making use of PipedReader and PipedWriter. I am now trying to port this same class to C#. Is it possible to accomplish the same as shown in the following code in C#? public final class Pipe { private final PipedReader pipedReader = new PipedReader(); private final PipedWriter pipedWriter = new PipedWriter(); public Pipe() { pipedWriter.connect(pipedReader); } ... } I am guessing what I'll want to use in C# for PipedReader and PipedWriter will be StreamReader and StreamWriter? Is there something like a connect() method? Thanks

    Read the article

  • How to perform .select() on jQuery masked text input

    - by dllhell
    I'm using http://digitalbush.com/projects/masked-input-plugin/ plugin. There is an input text with defined mask: <input type="text" id="txtMyInput" class="FocusSense"/> and a script: $(document).ready(function () { jQuery(function ($) { $("#txtMyInput").mask("?9.99"); }); $(".FocusSense").focus(function () { this.select(); }); }) As you can see, I would like select all in txtMyInput on focus but but alas! On focus, mask appears and loose .select(). What should I do to preserve mask and .select()?

    Read the article

  • function declaration

    - by robUK
    Hello, gcc 4.1.2 c89 I am reviewing some code and I have come across the following function. I have never seen a function declared like this before. There are no data types for the paraemeters. My best guess is that the function is using a list of data types separated by semi-colons. The return type seems to be returning a function with those parameters. However, the read function is not defined anywhere. What is the advantage and purpose of declaring a function like this? Many thanks for any advice, int my_read(fd, ptr, cnt) int fd; char *ptr; unsigned cnt; { printf("Read\n"); return(read(fd, ptr, cnt)); }

    Read the article

  • Windows C++: LPCTSTR vs const TCHAR

    - by mrl33t
    In my application i'm declaring a string variable near the top of my code to define the name of my window class which I use in my calls to RegisterClassEx, CreateWindowEx etc.. Now, I know that an LPCTSTR is a typedef and will eventually follow down to a TCHAR (well a CHAR or WCHAR depending on whether UNICODE is defined), but I was wondering whether it would be better to use this: static LPCTSTR szWindowClass = TEXT("MyApp"); Or this: static const TCHAR szWindowClass[] = TEXT("MyApp"); I personally prefer the use of the LPCTSTR as coming from a JavaScript, PHP, C# background I never really considered declaring a string as an array of chars. But are there actually any advantages of using one over the other, or does it in fact not even make a difference as to which one I choose? Thank you, in advanced, for your answers.

    Read the article

  • Missing the Rails gem. Please `gem install -v=2.3.4 rails`

    - by Brian Roisentul
    I was trying to fix this error and I ended up with a new one. I have installed ruby 1.8.6, but using Built-in JRuby 1.4.0 for my app. Everything was working fine until I updated every gem(as specified by the answer I got from that link) and everything crashed: ever since I tried to start the app I received the following error message: Missing the Rails 2.3.4 gem. Please gem install -v=2.3.4 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed. Then, I tried to uninstall the updates(to v2.3.8, most of them), so the last version is 2.3.4. In my config/environment.rb file I have this: RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION so I guess everything is as I left it before the update. The question is....why do I keep getting the error and I can't start the app?

    Read the article

  • question about comlen function in java

    - by davit-datuashvili
    in c or c++ function comlen is defined such int comlen(char *p,char *q){ int i=0; while *p && (*p++==*q++) i++; return i; is this code equivalent of this function int comlen(String s,String m){ int i=0; while (i<s.length() && s.charAt(i)==m.charAt(i)){ i++; } return i; ? please help

    Read the article

  • mysql_close(): supplied argument is not a valid MySQL-Link resource

    - by maxedison
    I'm trying to get the hang of using custom session handlers to store session data in a MySQL database. However, I keep getting the following warning: mysql_close(): supplied argument is not a valid MySQL-Link resource Here's the code I'm using, which I got from here: function _open(){ global $_sess_db; $_sess_db = mysql_connect("localhost", "root", "******"); if ($_sess_db) { return mysql_select_db('style', $_sess_db); } return false; } function _close(){ global $_sess_db; return mysql_close($_sess_db); //error happens here } The full text of the error message ultimately points to the final "return mysql_close($_sess_db);" line. I can confirm that the mysql_connect info does in fact work, and I do have the rest of the session handler functions defined as well. And in case it helps, I get these errors immediately upon page load, without actually calling any of the session handler functions, and without having any current sessions open.

    Read the article

  • Javascript - use to load xml data from URL

    - by spenf
    I have this url with some xml data in it: http://64.182.231.116/~spencerf/union_college/Upperclass_Sample_Menu.xml And I would like to load this xml data into my javascript script so I can parse it. I am using parse.com Javascript SDK, in there cloud code. Here is the code I have tried: Parse.Cloud.define("next", function(request, response) { response.success("Hello world!"); $.ajax({ url: 'http://64.182.231.116/~spencerf/union_college/Upperclass_Sample_Menu.xml', // name of file you want to parse dataType: "xml", // type of file you are trying to read success: parse, // name of the function to call upon success error: function(){alert("Error: Something went wrong");} }); }); But when I run this I get an error: $ is not defined at main.js:

    Read the article

  • You have an error in your SQL syntax; check the manual that corresponds to your MySQL

    - by LuisEValencia
    I am trying to run a mysql query to find all occurences of a text. I have a syntax error but dont know where or how to fix it I am using sqlyog to execute this script DECLARE @url VARCHAR(255) SET @url = '1720' SELECT 'select * from ' + RTRIM(tbl.name) + ' where ' + RTRIM(col.name) + ' like %' + RTRIM(@url) + '%' FROM sysobjects tbl INNER JOIN syscolumns col ON tbl.id = col.id AND col.xtype IN (167, 175, 231, 239) -- (n)char and (n)varchar, there may be others to include AND col.length > 30 -- arbitrary min length into which you might store a URL WHERE tbl.type = 'U' -- user defined table 1 queries executed, 0 success, 1 errors, 0 warnings Query: declare @url varchar(255) set @url = '1720' select 'select * from ' + rtrim(tbl.name) + ' where ' + rtrim(col.name) + ' like %' ... Error Code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare @url varchar(255)

    Read the article

  • rails - REST or create another method

    - by user1304740
    Let's assume we have two models linked with a 1-to-many relationship (like clients and invoices - a client can have many invoices). In a view of a 'client' (let's say the 'show' view), there is a form to capture an 'invoice'. I found 2 approaches: This form should be handled by the 'invoice' controller (method create), having client_id passed as a parameter This form should be handled by a new method in 'client' controller, probably a PUT method defined in routes.rb. Is there a 'Rails way', or both of them are good? Is there a preffered way? Thanks!

    Read the article

  • Best way to convert Stream (of unknown length) to byte array, in .NET?

    - by Frank Hamming
    Hello, I have the following code to read data from a Stream (in this case, from a named pipe) and into a byte array: // NPSS is an instance of NamedPipeServerStream int BytesRead; byte[] StreamBuffer = new byte[BUFFER_SIZE]; // defined elsewhere (less than total possible message size, though) MemoryStream MessageStream = new MemoryStream(); do { BytesRead = NPSS.Read(StreamBuffer, 0, StreamBuffer.Length); MessageStream.Write(StreamBuffer, 0, BytesRead); } while (!NPSS.IsMessageComplete); byte[] Message = MessageStream.ToArray(); // final data Could you please take a look and let me know if it can be done more efficiently or neatly? Seems a bit messy as it is, using a MemoryStream. Thanks!

    Read the article

  • Is it possible in Java to implement something similar to Object.clone() ?

    - by devoured elysium
    The Object.clone() method in Java is pretty special, as instead of returning a copy of the object that is to be cloned with the Object type, it returns the correct Object type. This can be better described with the following code: class A extends Object { public A clone() { return super.clone(); //although Object.clone() is from the Object class //this super.clone() will return an A object! } } class B extends A { } public static void main(String[] args) { B = new B(); B.clone();//here, although we haven't defined a clone() method, the cloned //object return is of type B! } So, could anyone explain if possible if is there anyway to replicate what happens inside Object.clone()'s method?

    Read the article

  • Select distinct ... inner join vs. select ... where id in (...)

    - by Tonio
    I'm trying to create a subset of a table (as a materialized view), defined as those records which have a matching record in another materialized view. For example, let's say I have a Users table with user_id and name columns, and a Log table, with entry_id, user_id, activity, and timestamp columns. First I create a materialized view of the Log table, selecting only those rows with timestamp some_date. Now I want a materliazed view of the Users referenced in my snapshot of the Log table. I can either create it as select * from Users where user_id in (select user_id from Log_mview), or I can do select distinct u.* from Users u inner join Log_mview l on u.user_id = l.user_id (need the distinct to avoid multiple hits from users with multiple log entries). The former seems cleaner and more elegant, but takes much longer. Am I missing something? Is there a better way to do this?

    Read the article

  • Javascript Headscratcher

    - by Jason
    I have the following in a javascript file (using jQuery as well): $(function(){ $('#mybutton').live('click',myObject.someMethod); }); var myObject = { someMethod: function() { //do stuff } }; I get a js error on pageload that says "myObject isn't defined". However, when I change the event handler in the doc.ready function to: $('#mybutton').live('click', function(){ myObject.someMethod(); }); it works! I have code structured like the first example all over my codebase that works. W T F??

    Read the article

  • Login verification always this same redirect

    - by user1738013
    This is my code: session_helper if ( ! function_exists('is_login')) { function is_login() { $CI =& get_instance(); $is_logged_in = $CI->session->userdata('is_logged_in'); if (!isset($is_logged_in) || $is_logged_in != TRUE) { redirect('login'); } } } check_login <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Check_login extends CI_Controller { function __construct() { parent::__construct(); $this->is_logged_in(); } function is_logged_in() { $this->load->helper('session_helper'); $this->load->helper('url'); is_login(); } } When I induction this function: Every time is induction redirect('login'); Where is my problem?

    Read the article

  • [Flash Builder Profiler] Why some function have been called

    - by HarryWang
    1 Create a project use flex sdk 3.4 2 Create a new mxml app Testadd.mxml 3 Add a source jpg Any.jpg content of Testadd.mxml just two line. [Embed(source="Any.jpg")] public var NotUsedSource:Class; I think this just defined a class which represent some data. And I never use it or initialize any instance of it in this app. 4 Profile this app, when it is profiling I click the resize button of IE servral times. 5 From the profiled data a function named Testadd_NotUsedSource.flash.events:IEventDispatcher:dispatchEvent is been called 6 My question is why this function has been called. I have the screenshot but can't add to this post.

    Read the article

  • Conditional Statements - If Then vs. Select Case

    - by cloyd800
    I'm a bit new to programming, and based on the few sources I've read both on the web and the books I'm learning to teach myself they are able to define what IF THEN and SELECT CASE conditional statements are, but have failed to give a comparison as to why I would use one over the other and what best practices decide this. If I'm understanding these conditional statements correctly, then both are based on a set of conditions with an outcome based around meeting these conditions, and if no conditions are met then an alternative outcome can be defined. I'm having trouble in understanding when I would use an IF THEN statement, and when I'd use a SELECT CASE statement, and what best practices are used to define this decision. Any insight on this would be greatly appreciated!

    Read the article

  • how to generate XML (in String representation) in java

    - by flyingfromchina
    I have defined a java class, but only need to output some of the fields of this class into an XML. The returned type must be a String. I first opted for the easiest way using a StringBuffer. However, when I tried to process the output String represenation, it failed. I think it is mostly likely because there are some characters that are not encoded in the UTF-8 in the input. Could someone tell me what is the best way to handle this? Thanks.

    Read the article

  • Member classes versus #includes

    - by ShallowThoughts
    I've recently discovered that it is bad form to have #includes in your header files because anyone who uses your code gets all those extra includes they won't necessarily want. However, for classes that have member variables defined as a type of another class, what's the alternative? For example, I was doing things the following way for the longest time: /* Header file for class myGrades */ #include <vector> //bad #include "classResult.h" //bad class myGrades { vector<classResult> grades; int average; int bestScore; } (Please excuse the fact that this is a highly artificial example) So, if I want to get rid of the #include lines, is there any way I can keep the vector or do I have to approach programming my code in an entirely different way?

    Read the article

  • PHP Undefined index - Occuring when the variable has a value in it

    - by Adam
    I have the following code that is being used to successfully upload images: $fileName = $_FILES['file']['name']; $fileSize = $_FILES['file']['size']; $fileType = $_FILES['file']['type']; $fileTmp = $_FILES['file']['tmp_name']; list($origWidth, $origHeight) = getimagesize($fileTmp); The catch is I'm getting an 'Undefined index' on each line. I have print_r($_FILES) just before this code and each array variable exists and I've echo out varibles like $fileName and can see each has a value. Also I have put this before this code block and it makes no difference: $fileName = $fileSize = $fileType = $fileTmp = ''; Any suggestions how I can ensure these variables are defined? thankyou

    Read the article

  • Nesting if else statements in PHP to validate a URL

    - by John
    I'm currently writing up a function in order to validate a URL by exploding it into different parts and matching those parts with strings I've defined. This is the function I'm using so far: function validTnet($tnet_url) { $tnet_2 = "defined2"; $tnet_3 = "defined3"; $tnet_5 = "defined5"; $tnet_7 = ""; if($exp_url[2] == $tnet_2) { #show true, proceed to next validation if($exp_url[3] == $tnet_3) { #true, and next if($exp_url[5] == $tnet_5) { #true, and last if($exp_url[7] == $tnet_7) { #true, valid } } } } else { echo "failed on tnet_2"; } } For some reason I'm unable to think of the way to code (or search for the proper term) of how to break out of the if statements that are nested. What I would like to do check each part of the URL, starting with $tnet_2, and if it fails one of the checks ($tnet_2, $tnet_3, $tnet_5 or $tnet_7), output that it fails, and break out of the if statement. Is there an easy way to accomplish this using some of the code I have already?

    Read the article

  • Defining Proper Classes with Java

    - by user2579706
    Ok, I'm studying Java and have the following question: "Assume you defined a class named MyClass. A student wants to use your class and tries to declare an instance named myObj and instantiate it. He tried the following: MyObj MyClass = new MyClass( ); Why won't his code work? Show how he should correct it. " I'm not sure how to do this? Can anyone point me in the right direction? Many thanks.

    Read the article

  • Why structs cannot be assigned directly?

    - by becko
    Suppose I have a fully defined struct with tag MyStruct, and suppose that x, y, ..., z are allowed values for its fields. Why is struct MyStruct q = {x,y,..,z}; allowed, but struct MyStruct q; q = {x,y,...,z}; is not allowed? I find this very annoying. In the second case, where I have previously declared q, I need to assign a value to each field, one by one: q.X = x; q.Y = y; ... q.Z = z; where X, Y, ..., Z are the fields of MyStruct. Is there a reason behind this?

    Read the article

  • bool - 255 value

    - by user994165
    I have this function defined: struct heap_validation { size_t num_alloc; size_t num_alloc_sz; struct memory *mem; }; ... bool get_isallocated(struct metadata_record *); When I call the heap_validation function from hashtable_traverse and print the result, I've gotten the following values: 0,255 ,246 void hashtable_traverse(struct metadata_record *metarec, struct heap_validation *heap_val) { printf("get_isallocated(metarec): %d\n",get_isallocated(metarec)); bool retrieved = false; bool allocated = get_isallocated(metarec); if (allocated) { heap_val->num_alloc += 1; I also tried with %d and I get the same result.

    Read the article

  • printf("... %c ...",'\0') and family - what will happen?

    - by SF.
    How will various functions that take printf format string behave upon encountering the %c format given value of \0/NULL? How should they behave? Is it safe? Is it defined? Is it compiler-specific? e.g. sprintf() - will it crop the result string at the NULL? What length will it return? Will printf() output the whole format string or just up to the new NULL? Will va_args + vsprintf/vprintf be affected somehow? If so, how? Do I risk memory leaks or other problems if I e.g. shoot this NULL at a point in std::string.c_str()? What are the best ways to avoid this caveat (sanitize input?)

    Read the article

< Previous Page | 204 205 206 207 208 209 210 211 212 213 214 215  | Next Page >