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/12 07:07] 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 25: Line 28:
 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
literals.txt · Last modified: 2018/08/20 04:05 by wolfgangriedmann