Wiki

Changes between Version 3 and Version 4 of Strings

Show
Ignore:
Timestamp:
01/14/14 12:18:41 (4 years ago)
Author:
hopscc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Strings

    v3 v4  
    4848 
    4949Cobra allows usual escape sequences for control characters 
    50      \n, \r, \t, \0 
     50    * \a - alarm (bell/beep) 
     51    * \b - backspace 
     52    * \f - formfeed 
     53    * \n - newline. 
     54    * \r - carriage return. 
     55    * \t - tab. 
     56    * \v - vertical tab 
     57    * \\ - single \ 
     58    * \' - single quote ' 
     59    * \" - double quote " 
     60    * \0 - nul char. 
    5161{{{ 
    5262#!cobra 
     
    7282print 'Hi [customer.firstName] [customer.lastName]' 
    7383}}} 
    74 leading [ can be escaped '\[' to escape this substitution. 
    75  
     84leading [ can be escaped '\[' to escape this substitution (individually). 
     85 
     86The expression inside the [] may have an optional format descriptor following the expression and separated from it by a ':'[[BR]] 
     87Any of the (.Net) single, standard or Custom format descriptors can be given.[[BR]] 
     88(see [http://msdn.microsoft.com/en-us/library/system.iformattable%28v=vs.110%29.aspx IFormattable] interface)  
     89{{{ 
     90#!cobra 
     91# std  
     92x = 123.456 
     93print 'val is [x] or [x:F4]' # val is 123.456 or 123.4560 
     94 
     95x1=123 
     96print 'val [x1] is [x1:D4]'   # val [123] is 0123 
     97print 'hex is 0x[x1:x4]' # hex is 0x007b 
     98 
     99# custom 
     100n=67263807 
     101print 'PhoneNum is [n:00-0000-000]' # PhoneNum is 06-7263-807 
     102#std datetime 
     103d = DateTime() 
     104print 'dflt is [d:F]' # dflt is  Monday, 01 January 0001 00:00:00 
     105}}} 
    76106 
    77107Literal strings support the usual escape characters. 
    78     \n - newline. 
    79     \r - carriage return. 
    80     \t - tab. 
    81     \0 - nul char. 
    82  
    83 (arbitrary embedded hex or unicode ??) 
     108    * \a - alarm (bell/beep) 
     109    * \b - backspace 
     110    * \f - formfeed 
     111    * \n - newline. 
     112    * \r - carriage return. 
     113    * \t - tab. 
     114    * \v - vertical tab 
     115    * \\ - single \ 
     116    * \' - single quote ' 
     117    * \" - double quote " 
     118    * \0 - nul char. 
     119 
     120     (arbitrary embedded hex or unicode ??) 
    84121 
    85122==== Raw Strings ==== 
     
    94131 
    95132Interprets escape chars but suppresses expression interpolation/substitution 
    96 (handling of []) 
     133(expansion of expressions in []) 
    97134     
    98135== !DocStrings == 
     
    105142{{{ 
    106143#!cobra 
    107 """ 
    108 Heres the doc string 
    109 """ 
    110 }}} 
     144""" Heres a single line docString.""" 
     145... 
     146""" 
     147Heres a multiline doc string. 
     148Second and subsequent lines follow 
     149... 
     150""" 
     151 
     152""" 
     153Heres another single line docString. 
     154""" 
     155}}} 
     156 
    111157e.g. 
    112158{{{