Search Results

Search found 639 results on 26 pages for 'literal'.

Page 3/26 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Passing unknown amounts of variables using through a string string and eval and multiple functions a

    - by user300797
    I'm not sure how best to describe this problem... In short, I want to use object literal to allow me to pass a random amount of variables in any order to a function. Whilst this is not big deal in theory, in my code, this object literal is passed to a second function call on_change. on_change works comparing an element inner HTML to a string. if it is the same, it sets a time out of to call the function again (this is sort of/almost recursive, but the function dose actually get to end before it is called again). if the elements inner HTML is different from the string, then the third parameter is executed. this will either be a function or a string. either way it will execute. I have tested this function plenty and used it for a while now. how ever, it cannot seem to get the object literal to flow through the function calls... var params = { xpos:'false'}; on_change('window_3_cont_buffer','',' if(Window_manager.windows[3].window_cont_buffer.getElementsByTagName(\'content\')[0].getElementsByTagName(\'p\')[0].innerHTML == \'ERROR\'){ alert(Window_manager.windows[3].window_cont_buffer.getElementsByTagName(\'content\')[0].getElementsByTagName(\'p\')[1].innerHTML); return false; } else { Window_manager.windows[3].load_xml(\'location/view.php?location_ID=3\', \'\', ' + params + ' ); } '); I call this as part of the form submission. after this line, I then call a function to load some content via ajax, which works fine and will trigger the code from the on_change function. I have tested load_xml function it is able to call alert(param.xpos) and get the correct response. I can even added in a check for being undefined so that rest of the times I cam load_xml I don't get swamped with alerts. The load_xml function first set up the on_change function, then calls the function to load the content to a hidden div. Once the AJAX request has updated that DIV, the on_change function should now call the parse_xml function. This pulls out the information from the xml file. How ever... The idea of this object literal param is that it can tell this parse_xml function to ignore certain things. on_change("window_" + this.id + "_cont_buffer", "", "Window_manager.windows[" + this.id + "].parse_xml('" + param + "')"); this is part of load_xml. it works perfectly fine, even with the param bit in there. except, parse_xml dose not seem to be able to use that parameter. I have been able to get it to a point where parse_xml can alert(param) and give [object object] which I would of thought meant that the object litteral had been passed through, but when I try and call alert(param.xpos) I get undefined. I know this is a pig of a problem, and I could get around it by just having the function take a zillion boolean parameters, but its just not practical or elegant. I'm sure you will need to ask me plenty more questions before I can solve this. I will post more complete code, I just cut it down to what is actually going on. Thanks

    Read the article

  • xslt (table) by matching the attribute value.

    - by Magesh
    i need to generate an xsl table for the xml below , for atrributes fname and lname.. i have done something worng in xpath i guess.could someone help me out writing an xsl table for the xml below.. <sparql> - <head> <variable name="s"/> <variable name="fname"/> <variable name="lname"/> </head> - <results> - <result> - <binding name="s"> <uri>http://tn.gov.in/Person/41</uri> </binding> - <binding name="fname"> <literal>Gayathri</literal> </binding> - <binding name="lname"> <literal>Vasudevan</literal> </binding> </result> - <result> - <binding name="s"> <uri>http://tn.gov.in/Person/43</uri> </binding> - <binding name="fname"> <literal>Vivek</literal> </binding> - <binding name="lname"> <literal>Vasudevan</literal> </binding> </result> - <result> - <binding name="s"> <uri>http://tn.gov.in/Person/37</uri> </binding> - <binding name="fname"> <literal>Magesh</literal> </binding> - <binding name="lname"> <literal>Vasudevan</literal> </binding> </result> - <result> - <binding name="s"> <uri>http://tn.gov.in/Person/39</uri> </binding> - <binding name="fname"> <literal>Vasudevan </literal> </binding> - <binding name="lname"> <literal>Srinivasan</literal> </binding> </result> </results>

    Read the article

  • XML parsing error: 'A string literal was expected' when inserting values into table

    - by Christian
    In Microsoft Sequel Server 2008 I am attempting to insert values into an sql table with the columns type_id of datatype int and xml_info of datatype XML. I am using the following query: INSERT INTO tbl_applied_devices ([type_id],[xml_info]) VALUES (1,'<Profile ID=99><Server><ID>BC4A18CA-AFB5-4268-BDA9-C990DAFE7783</ID> <Name>localhost</Name><Services></Services></Server></Profile>') But I keep getting this error: Msg 9413, Level 16, State 1, Line 4 XML parsing: line 1, character 13, A string literal was expected What am I doing incorrectly? Thank you for the help. EDIT: I found that the source of the error is the xml element's ID attribute, where seems to be what is causing the error. How can I correctly insert xml with an attribute ? Do I need to somehow escape one of the characters?

    Read the article

  • C++ Preprocessor string literal concatenation

    - by ezpz
    I found this regarding how the C preprocessor should handle string literal concatenation (phase 6). However, I can not find anything regarding how this is handled in C++ (does C++ use the C preprocessor?). The reason I ask is that I have the following: const char * Foo::encoding = "\0" "1234567890\0abcdefg"; where encoding is a static member of class Foo. Without the availability of concatenation I wouldnt be able to write that sequence of characters like that. const char * Foo::encoding = "\01234567890\0abcdefg"; Is something entirely different due to the way \012 is interpreted. I dont have access to multiple platforms and I'm curious how confident I should be that the above is always handled correctly - i.e. I will always get { 0, '1', '2', '3', ... }

    Read the article

  • Iphone build error - literal-pointer symbol(s) not found

    - by Nick
    Sorry I imagine I'm missing something basic here. Before I write up a bunch of details on the specifics of the class I'd appreciate a nudge or smack on the head about the meaning of this build error. I have a subclass of NSObject SiteAnnotation that should be conforming to the MKAnnotation protocol. It is #imported in the ViewController in question When I try to alloc/init: SiteAnnotation *thisAnnotation = [[SiteAnnotation alloc] init]; This is the build error which occurs: Link /build/Debug-iphonesimulator/testbed.app/testbed ".objc_class_name_SiteAnnotation", referenced from: literal-pointer@__OBJC@__cls_refs@SiteAnnotation in MapViewController.o Symbol(s) not found collect2: ld returned 1 exit status Any tips appreciated.

    Read the article

  • simpledateformat parsing date with 'Z' literal

    - by DanInDC
    I am trying to parse a date that looks like this: 2010-04-05T17:16:00Z This is a valid date per http://www.ietf.org/rfc/rfc3339.txt. The 'Z' literal "imply that UTC is the preferred reference point for the specified time." If I try to parse it using SimpleDateFormat and this pattern: yyyy-MM-dd'T'HH:mm:ss It will be parsed as a Mon Apr 05 17:16:00 EDT 2010 SimpleDateFormat is unable to parse the string with these patterns: yyyy-MM-dd'T'HH:mm:ssz yyyy-MM-dd'T'HH:mm:ssZ I can explicitly set the TimeZone to use on the SimpleDateFormat to get the expected output, but I don't think that should be necessary. Is there something I am missing? Is there an alternative date parser?

    Read the article

  • unterminated string literal on json eval

    - by sonam
    I am trying to eval() a json having speacial characters - 
 and getting "unterminated string literal" error in Firefox 3.5.9 Although the same works fine on IE. 7. I have set the character encoding to UTF-8 in both the browsers. Any idea why its an error in FF? Also right before converting the String to JSON, I ran this code in java String jsonString = //some json string having 
 for(byte b : jsonString.getBytes()){ System.out.print(Integer.toHexString(b) + " "); } net.sf.json.JSON jsonObject = net.sf.json.JSONSerializer.toJSON(jsonString); And the o/p for above characters is ffffffe2 ffffff80 ffffffa8 respectively. How do I know if these are valid UTF-8 characters?

    Read the article

  • Where to split a string literal

    - by quinmars
    Every time I have to split a long string literal into two (or more) pieces, because it does not fit into a single line, I have to decide if I split the text before or after a space. For example: const char * long_text1 = "This is a long text, which does not fit " "in one line"; /* or */ const char * long_text2 = "This is a long text, which does not fit" " in one line"; I tend to use the first way, but I do not have a real reason for it. So I wonder is there any advantage to favor one of them? I know this questions tend to be coding style question, but that's not my intend. I only want to know if there is a convincing reason why one of those two ways might be preferable.

    Read the article

  • How to return a string literal from a function

    - by skydoor
    Hi I am always confused about return a string literal or a string from a function. I was told that there might be memory leak because you don't know when the memory will be deleted? For example, in the code below, how to implement foo() so that make the output of the code is "Hello World"? void foo ( ) // you can add parameters here. { } int main () { char *c; foo ( ); printf ("%s",c); return 0; } Also if the return type of foo() is not void, but you can return char*, what should it be.

    Read the article

  • Problem with literal arguments in the PATTERN string for a python 2to3 fixer

    - by Zxaos
    Hi folks. I'm writing a fixer for the 2to3 tool in python. In my pattern string, I have a section where I'd like to match an empty string as an argument, or an empty unicode string. The relevant chunk of my pattern looks like: (args='""' | args='u""') My issue is the second option never matches. Even if it's alone, it won't match. However, if I simply say args=any and then output args, I can catch cases where args is exactly equal to the second option. Is there some weird unicode handling thing going on? Why won't the second literal option ever match?

    Read the article

  • Create a modifiable string literal in C++

    - by Anne
    Is it possible to create a modifiable string literal in C++? For example: char* foo[] = { "foo", "foo" }; char* afoo = foo[0]; afoo[2] = 'g'; // access violation This produces an access violation because the "foo"s are allocated in read only memory (.rdata section I believe). Is there any way to force the "foo"s into writable memory (.data section)? Even via a pragma would be acceptable! (Visual Studio compiler) I know I can do strdup and a number of other things to get around the problem, but I want to know specifically if I can do as I have asked. :)

    Read the article

  • Literal ampersands in System.Uri query string

    - by Nathan Baulch
    I'm working on a client app that uses a restful service to look up companies by name. It's important that I'm able to include literal ampersands in my queries since this character is quite common in company names. However whenever I pass %26 (the URI escaped ampersand character) to System.Uri, it converts it back to a regular ampersand character! On closer inspection, the only two characters that aren't converted back are hash (%23) and percent (%25). Lets say I want to search for a company named "Pierce & Pierce": var endPoint = "http://localhost/companies?where=Name eq '{0}'"; var name = "Pierce & Pierce"; Console.WriteLine(new Uri(string.Format(endPoint, name))); Console.WriteLine(new Uri(string.Format(endPoint, Uri.EscapeUriString(name)))); Console.WriteLine(new Uri(string.Format(endPoint, Uri.EscapeDataString(name)))); All three of the above combinations return: http://localhost/companies?where=Name eq 'Pierce & Pierce' This causes errors on the server side since the ampersand is (correctly) interpreted as a query arg delimiter. What I really need it to return is the original string: http://localhost/companies?where=Name eq 'Pierce %26 Pierce' How can I work around this behavior without discarding System.Uri entirely? I can't replace all ampersands with %26 at the last moment because there will usually be multiple query args involved and I don't want to destroy their delimiters. Note: A similar problem was discussed in this question but I'm specifically referring to System.Uri.

    Read the article

  • User defined literal arguments are not constexpr?

    - by Pubby
    I'm testing out user defined literals. I want to make _fac return the factorial of the number. Having it call a constexpr function works, however it doesn't let me do it with templates as the compiler complains that the arguments are not and cannot be constexpr. I'm confused by this - aren't literals constant expressions? The 5 in 5_fac is always a literal that can be evaluated during compile time, so why can't I use it as such? First method: constexpr int factorial_function(int x) { return (x > 0) ? x * factorial_function(x - 1) : 1; } constexpr int operator "" _fac(unsigned long long x) { return factorial_function(x); // this works } Second method: template <int N> struct factorial { static const unsigned int value = N * factorial<N - 1>::value; }; template <> struct factorial<0> { static const unsigned int value = 1; }; constexpr int operator "" _fac(unsigned long long x) { return factorial_template<x>::value; // doesn't work - x is not a constexpr }

    Read the article

  • Using Generics to return a literal string or from Dictionary<string, object>

    - by Mike
    I think I outsmarted myself this time. Feel free to edit the title also I could not think of a good one. I am reading from a file and then in that file will be a string because its like an xml file. But in the file will be a literal value or a "command" to get the value from the workContainer so <Email>[email protected]</Email> or <Email>[? MyEmail ?]</Email> What I wanted to do instead of writing ifs all over the place to put it in a generic function so logic is If Container command grab from container else grab string and convert to desired type Its up to the user to ensure the file is ok and the type is correct so another example is so <Answer>3</Answer> or <Answer>[? NumberOfSales ?]</Answer> This is the procedure I started to work on public class WorkContainer:Dictionary<string, object> { public T GetKeyValue<T>(string Parameter) { if (Parameter.StartsWith("[? ")) { string key = Parameter.Replace("[? ", "").Replace(" ?]", ""); if (this.ContainsKey(key)) { return (T)this[key]; } else { // may throw error for value types return default(T); } } else { // Does not Compile if (typeof(T) is string) { return Parameter } // OR return (T)Parameter } } } The Call would be mail.To = container.GetKeyValue<string>("[email protected]"); or mail.To = container.GetKeyValue<string>("[? MyEmail ?]"); int answer = container.GetKeyValue<int>("3"); or answer = container.GetKeyValue<int>("[? NumberOfSales ?]"); But it does not compile?

    Read the article

  • Which languages support *recursive* function literals / anonymous functions?

    - by Hugh Allen
    It seems quite a few mainstream languages support function literals these days. They are also called anonymous functions, but I don't care if they have a name. The important thing is that a function literal is an expression which yields a function which hasn't already been defined elsewhere, so for example in C, &printf doesn't count. EDIT to add: if you have a genuine function literal expression <exp>, you should be able to pass it to a function f(<exp>) or immediately apply it to an argument, ie. <exp>(5). I'm curious which languages let you write function literals which are recursive. Wikipedia's "anonymous recursion" article doesn't give any programming examples. Let's use the recursive factorial function as the example. Here are the ones I know: JavaScript / ECMAScript can do it with callee: function(n){if (n<2) {return 1;} else {return n * arguments.callee(n-1);}} it's easy in languages with letrec, eg Haskell (which calls it let): let fac x = if x<2 then 1 else fac (x-1) * x in fac and there are equivalents in Lisp and Scheme. Note that the binding of fac is local to the expression, so the whole expression is in fact an anonymous function. Are there any others?

    Read the article

  • Can't get rid of this warning?

    - by NextRev
    I'm getting this warning "Format not a string literal and no format arguments? Any ideas? -(BOOL)isFirstPointReached{ NSString *firstPoint = [NSString stringWithFormat:[pointsToFillArray objectAtIndex:0]]; NSString *lastPoint = [NSString stringWithFormat:[pointsToFillArray lastObject]]; if([firstPoint isEqualToString:lastPoint]){ return YES; } else{ return NO; } }

    Read the article

  • Replacing string literal values in Visual Studio project templates

    - by Daniel A. White
    I notice when I create a project template from an existing project in my solution, it does a semi-string replace to update references. However, it does not replace string literals. It does update my web.config file, but not code files. The project template: namespace MyTemplateProject { class MyClass { public string GetStringValue() { return "MyProjectTemplate"; } } } The generated code when used as a template: namespace MyActualNewProject { class MyClass { public string GetStringValue() { return "MyProjectTemplate"; } } } How can I instruct the template maker to replace "MyProjectTemplate" wih "MyActualNewProject"?

    Read the article

  • Regular expression literal

    - by Marcus
    As I'm RegEx dyslexic.. what RegEx can you use to find each of the following strings - with the exception of "LoginException"? NullPointerException LoginException BooException Abc123Exception

    Read the article

  • constructor function's object literal returns toString() method but no other method

    - by JohnMerlino
    I'm very confused with javascript methods defined in objects and the "this" keyword. In the below example, the toString() method is invoked when Mammal object instantiated: function Mammal(name){ this.name=name; this.toString = function(){ return '[Mammal "'+this.name+'"]'; } } var someAnimal = new Mammal('Mr. Biggles'); alert('someAnimal is '+someAnimal); Despite the fact that the toString() method is not invoked on the object someAnimal like this: alert('someAnimal is '+someAnimal.toString()); It still returns 'someAnimal is [Mammal "Mr. Biggles"]' . That doesn't make sense to me because the toString() function is not being called anywhere. Then to add even more confusion, if I change the toString() method to a method I make up such as random(): function Mammal(name){ this.name=name; this.random = function(){ return Math.floor(Math.random() * 15); } } var someAnimal = new Mammal('Mr. Biggles'); alert(someAnimal); It completely ignores the random method (despite the fact that it is defined the same way was the toString() method was) and returns: [object object] Another issue I'm having trouble understanding with inheritance is the value of "this". For example, in the below example function person(w,h){ width.width = w; width.height = h; } function man(w,h,s) { person.call(this, w, h); this.sex = s; } "this" keyword is being send to the person object clearly. However, does "this" refer to the subclass (man) or the super class (person) when the person object receives it? Thanks for clearing up any of the confusion I have with inheritance and object literals in javascript.

    Read the article

  • Single quotes in JavaScript object literal

    - by stone
    I'm looking at the Google Maps API tutorial, and I see this: <script type="text/javascript" src="http://www.google.com/jsapi?autoload={'modules':[{name:'maps', version:3, other_params:'sensor=false'}]}"></script> Why is modules wrapped in single quotes?

    Read the article

  • JavaScript Object literal notation confusion

    - by Ding
    In Firefox console, this code will generate error: {"d" : ["bankaccountnumber", "$1234.56"] } SyntaxError: invalid label { message="invalid label", more...} this code works just fine {d : ["bankaccountnumber", "$1234.56"] } ["bankaccountnumber", "$1234.56"] this code works fine as well var act = {'d' : ["bankaccountnumber", "$1234.56"] } a.d Can someone help to explain why is the diference? thanks!

    Read the article

  • JavaScript regular expression literal persists between function calls

    - by Charles Anderson
    I have this piece of code: function func1(text) { var pattern = /([\s\S]*?)(\<\?(?:attrib |if |else-if |else|end-if|search |for |end-for)[\s\S]*?\?\>)/g; var result; while (result = pattern.exec(text)) { if (some condition) { throw new Error('failed'); } ... } } This works, unless the throw statement is executed. In that case, the next time I call the function, the exec() call starts where it left off, even though I am supplying it with a new value of 'text'. I can fix it by writing var pattern = new RegExp('.....'); instead, but I don't understand why the first version is failing. How is the regular expression persisting between function calls? (This is happening in the latest versions of Firefox and Chrome.) Edit Complete test case: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <title>Test Page</title> <style type='text/css'> body { font-family: sans-serif; } #log p { margin: 0; padding: 0; } </style> <script type='text/javascript'> function func1(text, count) { var pattern = /(one|two|three|four|five|six|seven|eight)/g; log("func1"); var result; while (result = pattern.exec(text)) { log("result[0] = " + result[0] + ", pattern.index = " + pattern.index); if (--count <= 0) { throw "Error"; } } } function go() { try { func1("one two three four five six seven eight", 3); } catch (e) { } try { func1("one two three four five six seven eight", 2); } catch (e) { } try { func1("one two three four five six seven eight", 99); } catch (e) { } try { func1("one two three four five six seven eight", 2); } catch (e) { } } function log(msg) { var log = document.getElementById('log'); var p = document.createElement('p'); p.innerHTML = msg; log.appendChild(p); } </script> </head> <body><div> <input type='button' id='btnGo' value='Go' onclick='go();'> <hr> <div id='log'></div> </div></body> </html> The regular expression continues with 'four' as of the second call on FF and Chrome, not on IE7 or Opera.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >