Search Results

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

Page 18/26 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Limit scope of #define

    - by Ujjwal Singh
    What is the correct strategy to limit the scope of #define and avoid unwarrented token collisions. In the following configuration: Main.c # include "Utility_1.h" # include "Utility_2.h" VOID Utility() // Was written without knowing of: Utility_1 & Utility_2 { const UINT ZERO = 0; } VOID Main() { ... } // Collision; for Line:5 Compiler does not indicate what replaced Utility_1.h # define ZERO "Zero" # define ONE "One" BOOL Utility_1(); Utility_2.h # define ZERO '0' # define ONE '1' BOOL Utility_2(); Utility_2.c # include "Utility_2.h" BOOL Utility_2() { // Using: ZERO & ONE } //Collision: Character Literal replaced with String {Edit} Note: This is supposed to be a generic quesition so do not limit yourself to enum or other defined types. i.e. What to do when: I MUST USE #define Please comment on my proposed solution below.. _

    Read the article

  • How to make flyspell bypass some words by context?

    - by manu
    Hi, I use Emacs for writing most of my writings. I write using reStructuredText, and then transform them to LaTeX after some preprocessing since I write my citations á-la LaTeX. This is an excerpt of one of my texts (in Spanish): En \cite[pp.~XXVIII--XXIX]{Crnkovic2002} se brindan algunos riesgos que se pueden asumir con el desarrollo basado en componentes, los This text is processed by some custom scripts that deals with the \cite part so rst2latex can do its job. When I activate flyspell-mode it signals most of the citation keys as spelling errors. How can I tell flyspell not to spellcheck things within \cite commands. Furthermore, how can I combine rst-mode and flyspell, so that rst-mode would keep flyspell from spellchecking the following? reST comments reST code literal reST directive parameters and arguments reST raw directive contents Any ideas?

    Read the article

  • What is wrong in this json string?

    - by bala3569
    My json string looks like this, {"id" : "38","heading" : "Can you also figure out how to get me back the 10 hours I sp.....","description" : "Im having a very similar problem with the Login control - again it always generates a default style containing border -collapse -only in this case .....","img_url" : "~/EventImages/ EventImages1274014884460.jpg","catogory" : "News","doe" : "15-05-2010 "} But get the error, unterminated string literal.... EDIT: I used this but it didn't work, var newjson = cfreturn( """" & ToString( HfJsonValue ).ReplaceAll( "(['""\\\/\n\r\t]{1})", "\\$1" ) & """" ) ; var jsonObj = eval('(' + newjson + ')'); Error: missing ) after argument list Source Code: var newjson = cfreturn( """" & ToString( HfJsonValue ).ReplaceAll( "(['""\\\/\n\r\t]{1})", "\\$1" ) & """" ) ;

    Read the article

  • built in Soap extension php5 passing in params as associative array

    - by Ageis
    I have this xml I'm wanting to pass to this web service function <UserName>myuser</UserName> <Password>password</Password> <User> <AddCoverCode /> <title>sdadasdsa</title> </User> </CreateNewUser>','',array(),'document', 'literal'); I'm using the soap extension buit in php5. Is this what I'm supposed to be passing in the soapcall function as parameters? array('CreateNewUser' => array( 'UserName' => 'sc', 'Password' => 'i82372', 'Registration' => array('username' =>'new','password' =>'ss'));

    Read the article

  • C++ Translation Phase Confusion

    - by blakecl
    Can someone explain why the following doesn't work? int main() // Tried on several recent C++ '03 compilers. { #define FOO L const wchar_t* const foo = FOO"bar"; // Will error out with something like: "identifier 'L' is undefined." #undef FOO } I thought that preprocessing was done in an earlier translation phase than string literal operations and general token translation. Wouldn't the compiler be more or less seeing this: int main() { const wchar_t* const foo = L"bar"; } It would be great if someone could cite an explanation from the standard.

    Read the article

  • How to replace all the blanks within square brackets with an underscore using sed?

    - by Ringerrr
    I figured out that in order to turn [some name] into [some_name] I need to use the following expression: s/\(\[[^ ]*\) /\1_/ i.e. create a backreference capture for anything that starts with a literal '[' that contains any number of non space characters, followed by a space, to be replaced with the non space characters followed by an underscore. What I don't know yet though is how to alter this expression so it works for ALL underscores within the braces e.g. [a few words] into [a_few_words]. I sense that I'm close, but am just missing a chunk of knowledge that will unlock the key to making this thing work an infinite number of times within the constraints of the first set of []s contained in a line (of SQL Server DDL in this case). Any suggestions gratefully received....

    Read the article

  • addslashes and addcslahes

    - by theband
    I was seeing today the addslashes and addcslashes in php.net, but did not get the point on what is the difference between them and what are the characters escaped in these two. <?php $originaltext = 'This text does NOT contain \\n a new-line!'; $encoded = addcslashes($originaltext, '\\'); $decoded = stripcslashes($encoded); //$decoded now contains a copy of $originaltext with perfect integrity echo $decoded; //Display the sentence with it's literal \n intact ?> If i comment the $decoded variable and echo $encoded, i get the same value which is in the original string. Can anyone clearly explain me the difference and use of these two.

    Read the article

  • How to enter decimal/binary numbers when creating byte objects in python?

    - by Eric
    I'm using python 3.1.1. I know that I can create byte objects using the byte literal in the form of b'...'. In these byte objects, each byte can be represented as a character(in ascii code if I'm not wrong) or as a hexadecimal/octal number. Hexadecimal and octal numbers can be entered using an escape of \x for hexadecimal numbers and just a \ for octal numbers. However, there's no escape sequences for decimal or binary numbers. Is there any way to enter them into byte objects?

    Read the article

  • Are the atomic builtins provided by gcc actually translated into the example code, or is that just f

    - by Jared P
    So I was reading http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html, and came across this: type __sync_and_and_fetch (type *ptr, type value, ...) type __sync_xor_and_fetch (type *ptr, type value, ...) type __sync_nand_and_fetch (type *ptr, type value, ...) These builtins perform the operation suggested by the name, and return the new value. That is, { *ptr op= value; return *ptr; } { *ptr = ~*ptr & value; return *ptr; } // nand Is this code literal? or is it just to explain what gcc is doing atomically using c-like syntax? And if this is the direct translation, can someone explain how it is atomic?

    Read the article

  • C++ Scoping and ambiguity in constructor overloads

    - by loarabia
    I've tried the following code snippet in 3 different compilers (G++, clang++, CL.exe) and they all report to me that they cannot disambiguate the overloaded constructors. Now, I know how I could modify the call to the constructor to make it pick one or the other (either make explicit that the second argument is a unsigned literal value or explicitly cast it). However, I'm curious why the compiler would be attempting to choose between constructors in the first place given that one of the constructors is private and the call to the constructor is happening in the main function which should be outside the class's scope. Can anyone enlighten me? class Test { private: Test(unsigned int a, unsigned int *b) { } public: Test(unsigned int a, unsigned int b) { } }; int main() { Test t1 = Test(1,0); // compiler is confused }

    Read the article

  • How to understand the output of the PHP regex matching below?

    - by smarty
    $file = '{include file="{$COMMON_TPL_PATH}common/header_admin.tpl"} {include file="{$mainPage}"} {include file="{$COMMON_TPL_PATH}common/footer_admin.tpl"}'; preg_match('/^(\{\})|^(\{\*([\S\s]*?)\*\})|^(<\?(?:php\w+|=|[a-zA-Z]+)?)|^([ ]*[ ]+[ ]*)|^(\{strip\})|^(\{\/strip\})|^(\{literal\})|^(\{\s{1,}\/)|^(\{\s{1,})|^(\{\/)|^(\{)|^(([\S\s]*?)(?=([ ]*[ ]+[ ]*|\{|<\?)))|^([\S\s]+)/', $file, $matches); var_dump($matches); Why the output is: array(13) { [0]=> string(1) "{" [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(0) "" [8]=> string(0) "" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" [12]=> string(1) "{" } It seems to me that ^([\S\s]+) can match the whole string..

    Read the article

  • Initializing a value through a Session variable

    - by William Calleja
    I need to Initialize a value in a Javascript by using a c# literal that makes reference to a Session Variable. I am using the following code <script type="text/javascript" language="javascript" > var myIndex = <%= !((Session["myIndex"]).Equals(null)||(Session["myIndex"]).Equals("")) ? Session["backgroundIndex"] : "1" %>; However the code above is giving me a classic Object reference not set to an instance of an object. error. Why? Shouldn't (Session["myIndex"]).Equals(null) capture this particular error?

    Read the article

  • Database Documentation with `SQL Doc 2`

    - by mehdi lotfi
    I use SQL Doc 2 for documentation my database. But this tools not support following expect : Add diagrams in documentation. Add Additional description for each object such as tables, columns and etc. Customize output format. Add custom link for each object. Add Analyze business description of created tables, columns and etc Some time need to explain records of each table such as records of literal tables. How Can support above request in SQL Doc 2? Do exists a tools for documentation database with above request?

    Read the article

  • ' \r ' vs ' \n ' in C

    - by MCP
    I'm writing a function that basically waits for the user to hit "enter" and then does something. What I've found that works when testing is the below: #include <stdio.h> int main() { int x = getc(stdin); if (x == '\n') { printf("carriage return"); printf("\n"); } else { printf("missed it"); printf("\n"); } } The question I have, and what I tried at first was to do: "if (x == '\r')" but in testing, the program didn't catch me hitting enter. The '\n' seems to correspond to me hitting enter from the console. Can someone explain the difference? Also, to verify, writing it as "if... == "\n"" would mean the character string literal? Ie the user would literally have to enter "\n" from the console, correct? Thanks!

    Read the article

  • What is the difference between these two ways of creating NSStrings?

    - by adame
    NSString *myString = @"Hello"; NSString *myString = [NSString stringWithString:@"Hello"]; I understand that using method (1) creates a pointer to a string literal that is defined as static memory (and cannot be deallocated) and that using (2) creates an NSString object that will be autoreleased. Is using method (1) bad? What are the major differences? Is there any instances where you would want to use (1)? Is there a performance difference? P.S. I have searched extensively on Stack Overflow and while there are questions on the same topic, none of them have answers to the questions I have posted above.

    Read the article

  • jquery Troubles with binding to an element by id

    - by Alonzo
    Hi What im trying to do is that when the esc key is pressed on the text input field (id = txtSearch), some code will run. this is my code: $(document).ready(function() { $('#txtSearch').bind('keyup', function(e) { var characterCode; // literal character code will be stored in this variable if (e && e.which) { //if which property of event object is supported (NN4) e = e; characterCode = e.which; } else { characterCode = e.keyCode; } if (characterCode == 27) //if esc key { //do stuff } }); } It doesnt work for me. however, if i would change that line: $('#txtSearch').bind('keyup', function(e) { with: $(document).bind('keyup', function(e) { everything works. but i dont want to bind the keyup with esc to the whole document... any suggestions on how i can bind the the keyup only with the specific text search element? (or its containing div or something) Thanks!

    Read the article

  • Access dynamically generated control from code behind

    - by user648922
    I load a piece of html which contains something like: <em> < input type="text" value="Untitled" name="ViewTitle" id="ViewTitle" runat="server"> </em> into my control. The html is user defined, do please do not ask me to add them statically on the aspx page. On my page, I have a placeholder and I can use LiteralControl target = new LiteralControl (); // html string contains user-defined controls target.text = htmlstring to render it property. My problem is, since its a html piece, even if i know the input box's id, i cannot access it using FindControl("ViewTitle") (it will just return null) because its rendered as a text into a Literal control and all the input controls were not added to the container's control collections. I definitely can use Request.Form["ViewTitle"] to access its value, but how can I set its value?

    Read the article

  • Isses using function with variadic arguments

    - by Sausages
    I'm trying to write a logging function and have tried several different attempts at dealing with the variadic arguments, but am having problems with all of them. Here's the latest: - (void) log:(NSString *)format, ... { if (self.loggingEnabled) { va_list vl; va_start(vl, format); NSString* str = [[NSString alloc] initWithFormat:format arguments:vl]; va_end(vl); NSLog(format); } } If I call this like this: [self log:@"I like: %@", @"sausages"]; Then I get an EXC_BAD_ACCESS at the NSLog line (there's also a compiler warning that the format string is not a string literal). However if in XCode's console I do "po str" it displays "I like: sausages" so str seems ok.

    Read the article

  • Conditional Branching Issues

    - by Zack
    Here is the code: def main_menu print_main_menu user_selected = gets.chomp if user_selected.downcase == "no" main_menu elsif user_selected == "1" || "2" || "3" || "4" || "5" || "6" || "7" user_selected = user_selected.to_i call_option(user_selected) else main_menu end end This code uses calls to allow a user to make a selection from a main menu. Depending on the input, be it a certain number, a certain word, or something else, the respective method is called (in the case of a valid input) or the main menu is printed again (in the case of an invalid input or "no"). My questions are twofold. 1) Is there an efficient way to get rid of the literal string error that appears as a result of this redundant or statement on the elsif line? (the code itself works fine, but this error appears and is frustrating). 2) When an alternate/unspecified input is made by the user, the else branch doesn't execute and main_method doesn't start over. I have no idea why this is happening. Is there something I'm missing here? Thanks

    Read the article

  • Numeric literals in sql server 2008

    - by costa
    What is the type that sql server assigns to the numeric literal: 2. , i.e. 2 followed by a dot? I was curious because: select convert(varchar(50), 2.) union all select convert(varchar(50), 2.0) returns: 2 2.0 which made me ask what's the difference between 2. and 2.0 type wise? Sql server seems to assign types to numeric literals depending on the number itself by finding the minimal storage type that can hold the number. A value of 1222333 is stored as int while 1152921504606846975 is stored as big int. thanks

    Read the article

  • Extra line breaks inserted in MrEd text%

    - by Jesse Millikan
    In a DrScheme project, I'm using a MrEd editor-canvas% with text% and inserting a string from a literal in a Scheme file. This results in an extra blank line in the editor for each line of text I'm trying to insert. Is this a Windows vs. Unix linebreak problem? I can't find anything about text% treats line breaks in the documentation. ; Inside a class definition: (define/public (edit-pattern p j b d h) (send input-beat set-value (number->string b)) (send input-dwell set-value (number->string d)) (send hold-beats set-value (number->string h)) (send juggler-t erase) ; Why do these add extra newlines (send juggler-t insert j) (send pattern-t erase) (send pattern-t insert p)) (define juggler-ec (new editor-canvas% [parent this] [line-count 12])) (define juggler-t (new text%)) (send juggler-ec set-editor juggler-t) (define pattern-ec (new editor-canvas% [parent this] [line-count 20])) (define pattern-t (new text%)) (send pattern-ec set-editor pattern-t) ; Lots of other stuff...

    Read the article

  • New regular expression features in PCRE 8.34 and 8.35

    - by Jan Goyvaerts
    PCRE 8.34 adds some new regex features and changes the behavior of a few to make it better compatible with the latest versions of Perl. There are no changes to the regex syntax in PCRE 8.35. \o{377} is now an octal escape just like \377. This syntax was first introduced in Perl 5.12. It avoids any confusion between octal escapes and backreferences. It also allows octal numbers beyond 377 to be used. E.g. \o{400} is the same as \x{100}. If you have any reason to use octal escapes instead of hexadecimal escapes then you should definitely use the new syntax. Because of this change, \o is now an error when it doesn’t form a valid octal escape. Previously \o was a literal o and \o{377} was a sequence of 337 o‘s. In free-spacing mode, whitespace between a quantifier and the ? that makes it lazy or the + that makes it possessive is now ignored. In Perl this has always been the case. In PCRE 8.33 and prior, whitespace ended a quantifier and any following ? or + was seen as a second quantifier and thus an error. The shorthand \s now matches the vertical tab character in addition to the other whitespace characters it previously matched. Perl 5.18 made the same change. Many other regex flavors have always included the vertical tab in \s, just like POSIX has always included it in [[:space:]]. Names of capturing groups are no longer allowed to start with a digit. This has always been the case in Perl since named groups were added to Perl 5.10. PCRE 8.33 and prior even allowed group names to consist entirely of digits. [[:<:]] and [[::]] are now treated as POSIX-style word boundaries. They match at the start and the end of a word. Though they use similar syntax, these have nothing to do with POSIX character classes and cannot be used inside character classes. Perl does not support POSIX word boundaries. The same changes affect PHP 5.5.10 (and later) and R 3.0.3 (and later) as they have been updated to use PCRE 8.34. RegexBuddy and RegexMagic have been updated to support the latest versions of PCRE, PHP, and R. Older versions that were previously supported are still supported, so you can compare or convert your regular expressions between the latest versions of PCRE, PHP, and R and whichever version you were using previously.

    Read the article

  • const vs. readonly for a singleton

    - by GlenH7
    First off, I understand there are folk who oppose the use of singletons. I think it's an appropriate use in this case as it's constant state information, but I'm open to differing opinions / solutions. (See The singleton pattern and When should the singleton pattern not be used?) Second, for a broader audience: C++/CLI has a similar keyword to readonly with initonly, so this isn't strictly a C# type question. (Literal field versus constant variable in C++/CLI) Sidenote: A discussion of some of the nuances on using const or readonly. My Question: I have a singleton that anchors together some different data structures. Part of what I expose through that singleton are some lists and other objects, which represent the necessary keys or columns in order to connect the linked data structures. I doubt that anyone would try to change these objects through a different module, but I want to explicitly protect them from that risk. So I'm currently using a "readonly" modifier on those objects*. I'm using readonly instead of const with the lists as I read that using const will embed those items in the referencing assemblies and will therefore trigger a rebuild of those referencing assemblies if / when the list(s) is/are modified. This seems like a tighter coupling than I would want between the modules, but I wonder if I'm obsessing over a moot point. (This is question #2 below) The alternative I see to using "readonly" is to make the variables private and then wrap them with a public get. I'm struggling to see the advantage of this approach as it seems like wrapper code that doesn't provide much additional benefit. (This is question #1 below) It's highly unlikely that we'll change the contents or format of the lists - they're a compilation of things to avoid using magic strings all over the place. Unfortunately, not all the code has converted over to using this singleton's presentation of those strings. Likewise, I don't know that we'd change the containers / classes for the lists. So while I normally argue for the encapsulations advantages a get wrapper provides, I'm just not feeling it in this case. A representative sample of my singleton public sealed class mySingl { private static volatile mySingl sngl; private static object lockObject = new Object(); public readonly Dictionary<string, string> myDict = new Dictionary<string, string>() { {"I", "index"}, {"D", "display"}, }; public enum parms { ABC = 10, DEF = 20, FGH = 30 }; public readonly List<parms> specParms = new List<parms>() { parms.ABC, parms.FGH }; public static mySingl Instance { get { if(sngl == null) { lock(lockObject) { if(sngl == null) sngl = new mySingl(); } } return sngl; } } private mySingl() { doSomething(); } } Questions: Am I taking the most reasonable approach in this case? Should I be worrying about const vs. readonly? is there a better way of providing this information?

    Read the article

  • Date Time Format in RUBY

    - by Madhan ayyasamy
    The following snippets is very useful when we render views dates in various format in ruby on rails."Format meaning:  %a - The abbreviated weekday name (``Sun'')  %A - The  full  weekday  name (``Sunday'')  %b - The abbreviated month name (``Jan'')  %B - The  full  month  name (``January'')  %c - The preferred local date and time representation  %d - Day of the month (01..31)  %H - Hour of the day, 24-hour clock (00..23)  %I - Hour of the day, 12-hour clock (01..12)  %j - Day of the year (001..366)  %m - Month of the year (01..12)  %M - Minute of the hour (00..59)  %p - Meridian indicator (``AM''  or  ``PM'')  %S - Second of the minute (00..60)  %U - Week  number  of the current year,          starting with the first Sunday as the first          day of the first week (00..53)  %W - Week  number  of the current year,          starting with the first Monday as the first          day of the first week (00..53)  %w - Day of the week (Sunday is 0, 0..6)  %x - Preferred representation for the date alone, no time  %X - Preferred representation for the time alone, no date  %y - Year without a century (00..99)  %Y - Year with century  %Z - Time zone name  %% - Literal ``%'' character   t = Time.now   t.strftime("Printed on %m/%d/%Y")   #=> "Printed on 04/09/2003"   t.strftime("at %I:%M%p")            #=> "at 08:56AM""Have a great day!

    Read the article

  • Function Folding in #PowerQuery

    - by Darren Gosbell
    Originally posted on: http://geekswithblogs.net/darrengosbell/archive/2014/05/16/function-folding-in-powerquery.aspxLooking at a typical Power Query query you will noticed that it's made up of a number of small steps. As an example take a look at the query I did in my previous post about joining a fact table to a slowly changing dimension. It was roughly built up of the following steps: Get all records from the fact table Get all records from the dimension table do an outer join between these two tables on the business key (resulting in an increase in the row count as there are multiple records in the dimension table for each business key) Filter out the excess rows introduced in step 3 remove extra columns that are not required in the final result set. If Power Query was to execute a query like this literally, following the same steps in the same order it would not be overly efficient. Particularly if your two source tables were quite large. However Power Query has a feature called function folding where it can take a number of these small steps and push them down to the data source. The degree of function folding that can be performed depends on the data source, As you might expect, relational data sources like SQL Server, Oracle and Teradata support folding, but so do some of the other sources like OData, Exchange and Active Directory. To explore how this works I took the data from my previous post and loaded it into a SQL database. Then I converted my Power Query expression to source it's data from that database. Below is the resulting Power Query which I edited by hand so that the whole thing can be shown in a single expression: let     SqlSource = Sql.Database("localhost", "PowerQueryTest"),     BU = SqlSource{[Schema="dbo",Item="BU"]}[Data],     Fact = SqlSource{[Schema="dbo",Item="fact"]}[Data],     Source = Table.NestedJoin(Fact,{"BU_Code"},BU,{"BU_Code"},"NewColumn"),     LeftJoin = Table.ExpandTableColumn(Source, "NewColumn"                                   , {"BU_Key", "StartDate", "EndDate"}                                   , {"BU_Key", "StartDate", "EndDate"}),     BetweenFilter = Table.SelectRows(LeftJoin, each (([Date] >= [StartDate]) and ([Date] <= [EndDate])) ),     RemovedColumns = Table.RemoveColumns(BetweenFilter,{"StartDate", "EndDate"}) in     RemovedColumns If the above query was run step by step in a literal fashion you would expect it to run two queries against the SQL database doing "SELECT * …" from both tables. However a profiler trace shows just the following single SQL query: select [_].[BU_Code],     [_].[Date],     [_].[Amount],     [_].[BU_Key] from (     select [$Outer].[BU_Code],         [$Outer].[Date],         [$Outer].[Amount],         [$Inner].[BU_Key],         [$Inner].[StartDate],         [$Inner].[EndDate]     from [dbo].[fact] as [$Outer]     left outer join     (         select [_].[BU_Key] as [BU_Key],             [_].[BU_Code] as [BU_Code2],             [_].[BU_Name] as [BU_Name],             [_].[StartDate] as [StartDate],             [_].[EndDate] as [EndDate]         from [dbo].[BU] as [_]     ) as [$Inner] on ([$Outer].[BU_Code] = [$Inner].[BU_Code2] or [$Outer].[BU_Code] is null and [$Inner].[BU_Code2] is null) ) as [_] where [_].[Date] >= [_].[StartDate] and [_].[Date] <= [_].[EndDate] The resulting query is a little strange, you can probably tell that it was generated programmatically. But if you look closely you'll notice that every single part of the Power Query formula has been pushed down to SQL Server. Power Query itself ends up just constructing the query and passing the results back to Excel, it does not do any of the data transformation steps itself. So now you can feel a bit more comfortable showing Power Query to your less technical Colleagues knowing that the tool will do it's best fold all the  small steps in Power Query down the most efficient query that it can against the source systems.

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >