User Tools

Site Tools


literals

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
literals [2018/02/10 14:51] wolfgangriedmannliterals [2018/08/20 04:05] (current) wolfgangriedmann
Line 4: Line 4:
  
 A string literal is delimited with the double quotation mark ''"'' A string literal is delimited with the double quotation mark ''"''
-<code>"This is a string"</code>+<code visualfoxpro>"This is a string"</code>
 Please note that in the VO dialect a string can also be delimited with the quotation mark '' ' ''. Please note that in the VO dialect a string can also be delimited with the quotation mark '' ' ''.
-<code>'This is a string' // valid only in the VO dialect, not in Core or Vulcan</code>+<code visualfoxpro>'This is a string' // valid only in the VO dialect, not in Core or Vulcan</code>
 If you need to specify special characters or single quotation marks in a string, you need an ''escaped'' string, prefixed with ''e'': If you need to specify special characters or single quotation marks in a string, you need an ''escaped'' string, prefixed with ''e'':
-<code>e"This is an escaped string with a new line \nand a double \" quotation mark"</code>+<code visualfoxpro>e"This is an escaped string with a new line \nand a double \" quotation mark"</code>
 There are also interpolated strings that can contain variables: There are also interpolated strings that can contain variables:
-<code>local cValue := "guys" as string+<code visualfoxpro>local cValue := "guys" as string
 Console.WriteLine( i"Hi {cValue}" ) // Hi guys</code> Console.WriteLine( i"Hi {cValue}" ) // Hi guys</code>
 +
 +Since in the VO dialect a string can also be defined with single quotation marks, there is no possibility for the compiler to see a difference between a single character string and a char. Therefore you should prefix a char literal with a ''c'' like this:
 +<code visualfoxpro>cChar := c'\r'</code>
  
 For more details please see [[strings|Strings and their prefixes]] and [[string_char_byte|String, Char and Byte]] For more details please see [[strings|Strings and their prefixes]] and [[string_char_byte|String, Char and Byte]]
Line 20: Line 23:
 If you need to specify what type a numeric literal should take, use suffixes: If you need to specify what type a numeric literal should take, use suffixes:
   * ''d'' for **D**ouble   * ''d'' for **D**ouble
-  * ''s'' for **S**single+  * ''s'' for **S**ingle
   * ''m'' for Deci**m**al   * ''m'' for Deci**m**al
   * ''b'' for **B**inary   * ''b'' for **B**inary
 You can also use a prefix of ''0x'' to specify a hexadecimal value. You can also use a prefix of ''0x'' to specify a hexadecimal value.
 Sample code: Sample code:
-<code>Console.WriteLine( "123.45  is a " + (123.45 ):GetType():Name ) // Double +<code visualfoxpro>Console.WriteLine( "123.45  is a " + (123.45 ):GetType():Name )      // Double 
-Console.WriteLine( "123     is a " + ( 123 ):GetType():Name ) // Int32 +Console.WriteLine( "123     is a " + ( 123 ):GetType():Name )              // Int32 
-Console.WriteLine( "10000000000 is a " + ( 10000000000 ):GetType():Name ) // Int64 +Console.WriteLine( "10000000000 is a " + ( 10000000000 ):GetType():Name )  // Int64 
-Console.WriteLine( "123s    is a " + ( 123s ):GetType():Name ) // Single +Console.WriteLine( "123s    is a " + ( 123s ):GetType():Name )             // Single 
-Console.WriteLine( "123d    is a " + ( 123d ):GetType():Name ) // Double +Console.WriteLine( "123d    is a " + ( 123d ):GetType():Name )             // Double 
-Console.WriteLine( "123dm   is a " + ( 123m ):GetType():Name ) // Decimal +Console.WriteLine( "123dm   is a " + ( 123m ):GetType():Name )             // Decimal 
-Console.WriteLine( "0x111   has a decimal value of " + 0x111:ToString() ) // decimal 273 +Console.WriteLine( "0x111   has a decimal value of " + 0x111:ToString() )  // decimal 273 
-Console.WriteLine( "0b111   has a decimal value of " + 0b111:ToString() ) // decimal 7</code>+Console.WriteLine( "0b111   has a decimal value of " + 0b111:ToString() )  // decimal 7</code>
  
 For explanations why these suffixes differ from these on C#, please see this X# forum post: [[https://www.xsharp.info/forum/public-product/555-correct-syntax-for-floats|Correct syntax for floats]] (look at the 3rd message from Chris Pyrgas) For explanations why these suffixes differ from these on C#, please see this X# forum post: [[https://www.xsharp.info/forum/public-product/555-correct-syntax-for-floats|Correct syntax for floats]] (look at the 3rd message from Chris Pyrgas)
  
  
literals.1518274301.txt.gz · Last modified: 2018/02/10 14:51 by wolfgangriedmann