Search Results

Search found 11178 results on 448 pages for 'syntax checking'.

Page 63/448 | < Previous Page | 59 60 61 62 63 64 65 66 67 68 69 70  | Next Page >

  • why does .replace method use forward slash characters to enclose the first argument?

    - by Phillip Dodd
    I am working through a book about Javascript and have encountered the following example of code designed to replace the value of the class attribute of a table header HTML element: th.className = th.className.replace(/asc/,"dsc"); th.className = th.className.replace(/dsc/,"asc"); Why is the first parameter of .replace, the current value of th.className, enclosed in forward slashes instead of quotation marks? Why not use quotation marks to enclose both parameters, not just the second one? Thank you in advance for any help given. First time posting, apologies if I duplicated a question despite searching the site before posting.

    Read the article

  • How do you override operator == when using interfaces instead of actual types?

    - by RickL
    I have some code like this: How should I implement the operator == so that it will be called when the variables are of interface IMyClass? public class MyClass : IMyClass { public static bool operator ==(MyClass a, MyClass b) { if (ReferenceEquals(a, b)) return true; if ((Object)a == null || (Object)b == null) return false; return false; } public static bool operator !=(MyClass a, MyClass b) { return !(a == b); } } class Program { static void Main(string[] args) { IMyClass m1 = new MyClass(); IMyClass m2 = new MyClass(); MyClass m3 = new MyClass(); MyClass m4 = new MyClass(); Console.WriteLine(m1 == m2); // does not go into custom == function. why not? Console.WriteLine(m3 == m4); // DOES go into custom == function } }

    Read the article

  • RegEx replace query to pick out wiki syntax

    - by Jeremy Thake
    I've got a string of HTML that I need to grab the "[Title|http://www.test.com]" pattern out of e.g. "dafasdfasdf, adfasd. [Test|http://www.test.com/] adf ddasfasdf [SDAF|http://www.madee.com/] assg ad" I need to replace "[Title|http://www.test.com]" this with "Title". What is the best away to approach this? I was getting close with: string test = "dafasdfasdf adfasd [Test|http://www.test.com/] adf ddasfasdf [SDAF|http://www.madee.com/] assg ad "; string p18 = @"(\[.*?|.*?\])"; MatchCollection mc18 = Regex.Matches(test, p18, RegexOptions.Singleline | RegexOptions.IgnoreCase); foreach (Match m in mc18) { string value = m.Groups[1].Value; string fulltag = value.Substring(value.IndexOf("["), value.Length - value.IndexOf("[")); Console.WriteLine("text=" + fulltag); } There must be a cleaner way of getting the two values out e.g. the "Title" bit and the url itself. Any suggestions?

    Read the article

  • java oracle syntax error?

    - by murali
    hi, i am using the following code for the uploading keywords & count to the excel file. i am having the keyword_id as primary key for that one i had written sentence...i am having the twocolumns in the excel file..1.keyword 2.count my code is: while (rs.next()) { System.out.println("inside "); String keyword = rs.getString(1); int count = rs.getInt(2); System.out.println("insert into SEARCHABLE_KEYWORDS values ('"+ keyword+"','"+count+"')"); stmtdb.execute("insert into SEARCHABLE_KEYWORDS (keyword_id,keyword,count) values ('"+ "select Searchable_Keywords_sequence.nextval from dual"+ "','"+keyword+"','"+count+"')"); System.out.println(keyword + " " + keyword+" count "+count); } but I am getting the following error: java.sql.SQLException: [Microsoft][ODBC Excel Driver] Too few parameters. Expected 1. at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6998) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7155) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3151) at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:378) at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:284) at keywordsreader.main(keywordsreader.java:42) please help to slove this problem...

    Read the article

  • Uncaught SyntaxError: Unexpected token var

    - by Bob R
    I have an error Uncaught SyntaxError: Unexpected token var displayed between (1) and (2) its a very odd error and it doesn't make sense at all. if ($hiddenimage.length==0){ //if this is the first time moving over or clicking on the anchor link var $hiddenimage=$('<img src="'+this.href+'" />').appendTo($hiddenimagediv) //populate hidden div with enlarged image $hiddenimage.bind('loadevt', function(e){ //when enlarged image has fully loaded loadarea.empty().append($.thumbnailviewer2.buildimage($, $anchor, s, options) (1) - var $targetimage=$.thumbnailviewer2.buildimage($, $anchor, s, options) //create reference actual enlarged image (2) - $loadarea.empty().append($targetimage) //show enlarged image $.thumbnailviewer2.showimage($targetimage, s) })

    Read the article

  • Syntax error, need help with this 'string'

    - by Camran
    I have this piece of code here below: $fq.=" + (fritidsboende_uth_from:[$fritids_uth_from TO *] AND fritidsboende_uth_to:[* TO $fritids_uth_to]) OR (fritidsboende_uth_from:'1972-01-01T01:01:00Z' AND fritidsboende_uth_to:'2019-01-01T01:01:00Z')"; I have noticed my app doesn't get anything behind the colon, in this part of the code: OR (fritidsboende_uth_from:'1972-01-01T01:01:00Z' // Notice the colon in the date string I get this error msg: Unrecognized date string: '1972-01-01T01'. Nothing from behind the colon is there though. How should I 'escape' it so that the colon is properly recognized? Its PHP... Thanks

    Read the article

  • Ruby: rules for implicit hashes

    - by flyer
    Why second output shows me only one element of Array? Is it still Array or Hash already? def printArray(arr) arr.each { | j | k, v = j.first printf("%s %s %s \n", k, v, j) } end print "Array 1\n" printArray( [ {kk: { 'k1' => 'v1' }}, {kk: { 'k2' => 'v2' }}, {kk: { 'k3' => 'v3' }}, ]) print "Array 2\n" printArray( [ kk: { 'k1' => 'v1' }, kk: { 'k2' => 'v2' }, kk: { 'k3' => 'v3' }, ]) exit # Output: # # Array 1 # kk {"k1"=>"v1"} {:kk=>{"k1"=>"v1"}} # kk {"k2"=>"v2"} {:kk=>{"k2"=>"v2"}} # kk {"k3"=>"v3"} {:kk=>{"k3"=>"v3"}} # Array 2 # kk {"k3"=>"v3"} {:kk=>{"k3"=>"v3"}}

    Read the article

  • Please explain syntax rules and scope for "typedef"

    - by unknown google user
    What are the rules? OTOH the simple case seems to imply the new type is the last thing on a line. Like here Uchar is the new type. typedef unsigned char Uchar; But a function pointer is completely different. Here the new type is pFunc: typedef int (*pFunc) (int); I can't think of any other examples offhand but I have come across some very confusing usages. So are there rules or are people just suppose to know from experience that this is how it is done because they have seen it done this way before? ALSO: What is the scope of a typedef. Thanks to everyone.

    Read the article

  • subplot matplotlib wrong syntax

    - by madptr
    I am using matplotlib to subplot in a loop. For instance, i would like to subplot 49 data sets, and from the doc, i implemented it this way; import numpy as np import matplotlib.pyplot as plt X1=list(range(0,10000,1)) X1 = [ x/float(10) for x in X1 ] nb_mix = 2 parameters = [] for i in range(49): param = [] Y = [0] * len(X1) for j in range(nb_mix): mean = 5* (1 + (np.random.rand() * 2 - 1 ) * 0.5 ) var = 10* (1 + np.random.rand() * 2 - 1 ) scale = 5* ( 1 + (np.random.rand() * 2 - 1) * 0.5 ) Y = [ Y[k] + scale * np.exp(-((X1[k] - mean)/float(var))**2) for k in range(len(X1)) ] param = param + [[mean, var, scale]] ax = plt.subplot(7, 7, i + 1) ax.plot(X1, Y) parameters = parameters + [param] ax.show() However, i have an index out of range error from i=0 onwards. Where can i do better to have it works ? Thanks

    Read the article

  • Isn't objective-c function parameter syntax weird? [closed]

    - by Haoest
    Consider the following method: +(void) myMethod:(int)arg1 **argument2**(int)arg2 **argument3**(int) arg3; See how the first argument, unlike the 2nd and 3rd, doesn't have a description, giving it an impression of bad symmetry. Also you would expect the extra typing will provide named argument as you pass it in, but you still have to pass them in the correct order. Can anyone help me make sense of this?

    Read the article

  • Authoritative Excel range syntax reference

    - by olefevre
    Sorry if this has been asked before but I can't find it. I am looking for an authoritative description of all valid strings that can be used as a reference, e.g., "A1:C5", "$A:$A", $A2" etc etc. That seems a pretty basic thing yet I've wasted hours trying to locate it. All I can find is a swamp of "helpful" examples but no reference.

    Read the article

  • Basic FreeMat/MATLAB syntax - dimension error

    - by 0x90
    I am using FreeMat, and I have an RGB picture which is a 3D matrix contains the columns and rows of the pictures and the RGB values for each pixel. Since there is not an intrinsic function to convert RGB picture to YIQ, I have implement one. I came up with this code: Assume I have a 3D array, image_rgb: matrix = [0.299 0.587 0.114; 0.596 -0.274 -0.322; 0.211 -0.523 0.312]; row = 1:length(image_rgb(:,1,1)); col = 1:length(image_rgb(1,:,1)); p = image_rgb(row,col,:); %Here I have the problem mage_yiq(row,col,:) = matrix*image_rgb(row,col,:); max_y = max (max(image_yiq(:,:,1))); max_i = max (max(image_yiq(:,:,2))); max_q = max (max(image_yiq(:,:,3))); %Renormalize the image again after the multipication % to [0,1]. image_yiq(:,:,1) = image_yiq(:,:,1)/max_y; image_yiq(:,:,2) = image_yiq(:,:,2)/max_i; image_yiq(:,:,3) = image_yiq(:,:,3)/max_q; I can't understand why the matrix multiplication fails. I want the code to be nice and not just to, multiply the matrix by hand...

    Read the article

  • Alternates to C++ Reference/Pointer Syntax

    - by Jon Purdy
    What languages other than C and C++ have explicit reference and pointer type qualifiers? People seem to be easily confused by the right-to-left reading order of types, where char*& is "a reference to a pointer to a character", or a "character-pointer reference"; do any languages with explicit references make use of a left-to-right reading order, such as &*char/ref ptr char? I'm working on a little language project, and legibility is one of my key concerns. It seems to me that this is one of those questions to which it's easy for a person but hard for a search engine to provide an answer. Thanks in advance!

    Read the article

  • Alternatives to C++ Reference/Pointer Syntax

    - by Jon Purdy
    What languages other than C and C++ have explicit reference and pointer type qualifiers? People seem to be easily confused by the right-to-left reading order of types, where char*& is "a reference to a pointer to a character", or a "character-pointer reference"; do any languages with explicit references make use of a left-to-right reading order, such as &*char/ref ptr char? I'm working on a little language project, and legibility is one of my key concerns. It seems to me that this is one of those questions to which it's easy for a person but hard for a search engine to provide an answer. Thanks in advance!

    Read the article

  • rails db migration, undefined method `to_sym', cant figure out syntax

    - by oelbrenner
    the original migration looks like this: class CreateUsers true do |t| t.string :login, :limit = 40 t.string :name, :limit = 100, :default = '', :null = true t.string :email, :limit = 100 t.string :crypted_password, :limit = 40 t.string :salt, :limit = 40 t.string :remember_token, :limit = 40 t.datetime :remember_token_expires_at t.string :activation_code, :limit = 40 t.datetime :activated_at, :datetime t.string :state, :null = :no, :default = 'passive' t.datetime :deleted_at t.integer :occupation_id, :null = :yes t.datetime :paid_up_to_date, :date t.timestamps end and I am trying to change the default of "state" to be "active" instead of passive so my attempt at a migration looks like this: ( still learning.. be gentle ) class ChangeUserStateDefault < ActiveRecord::Migration def self.up change_column :users, :state, :null = :no, :default = 'active' end def self.down end end

    Read the article

  • Backbone: rendering syntax

    - by ksol
    We're using Backbone.js in one of my team's projects, and this is the first time I use it. I've seen many times this kind of code (it's coffeescript, but clear enough I think. @ means this.) clients_view = new Homespa.Views.Orders.Clients.SectionView(collection: @options.clients) @$("#clients-section").html(clients_view.render().el) clients_search_view = new Homespa.Views.Orders.Clients.SearchView @$("#clients_search_modal").html(clients_search_view.render().el) Isn't there a better way to do this? I would expect to just call render on my view, and then everything's good, I shouldn't have to get the html and append/replace it by hand. Thanks for you time !

    Read the article

  • Lambda recursive PHP functions.

    - by Kendall Hopkins
    Is it possible to have a PHP function that is both recursive and anonymous (lambda). This is my attempt to get it to work, but it doesn't pass in the function name. $factorial = function( $n ) use ( $factorial ) { if( $n == 1 ) return 1; return $factorial( $n - 1 ) * $n; }; print $factorial( 5 ); I'm also aware that this is a bad way to implement factorial, it's just an example.

    Read the article

  • Basic help needed with pointers (double indirection)

    - by sbsp
    Hi, i asked some time ago on an account i cant remember how to manipulate basic pointers and someone gave me a really good demo for example char *ptr = "hello" (hello = a char array) so now *ptr is pointing at h ptr++ = moves the ptr to point at the next element, to get its value i do *ptr and that gives me e ok so far i hope :D but now i need to manipulate a char **ptr and was wondering how I do this in a way that mimmicks the effects of a 2d array? some basic tips would be much appreciated as I need to do an assignment that has a **ptr to imitate a 2d array and without knowing how it does this first means I cant even solve it on paper (for example, how do you dereference a **ptr, how do you get [x][y] values etc) thanks

    Read the article

  • C#: Union of two ICollections? (equivlaent of Java's addAll())

    - by Rosarch
    I have two ICollections of which I would like to take the union. Currently, I'm doing this with a foreach loop, but that feels verbose and hideous. What is the C# equivalent of Java's addAll()? Example of this problem: ICollection<IDictionary<string, string>> result = new HashSet<IDictionary<string, string>>(); // ... ICollection<IDictionary<string, string>> fromSubTree = GetAllTypeWithin(elementName, element); foreach (IDictionary<string, string> dict in fromSubTree) // hacky { result.Add(dict); } // result is now the union of the two sets

    Read the article

  • is this correct syntax to create onclick event on dynamic html document

    - by user321382
    var val1=document.createElement("input"); val1.setAttribute('type',"image"); val1.setAttribute('src',"../images/delete.gif"); val1.setAttribute('id',chkid); val1.setAttribute('name',"val2"); val1.setAttribute('class',"mylist2"); val1.onclick=function(){var block=document.getElementById("repeat_ul"); var obj=document.getElementById('country_chk'); document.block.removeChild(obj);};

    Read the article

< Previous Page | 59 60 61 62 63 64 65 66 67 68 69 70  | Next Page >