Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: YYYYMMDD date format

From: g:santilli:tiscalinet:it at: 15-Nov-2000 15:35

Mat Bettinson wrote:
> The only thing that really annoys me in rebol is simple high level > string handling really. The Amigas Arexx had such easy ways to do this > sort of thing - in fact so did BASIC even.
You want LEFT and RIGHT, don't you? It's so simple: left: func [ string [string!] n [integer!] /with char [char!] ] [ head insert/dup tail copy/part string n any [char #" "] subtract n length? string ] or, in a more readable fashion: left: func [ string [string!] n [integer!] /with char [char!] ] [ char: any [char #" "] string: copy/part string n insert/dup tail string char n - length? string string ]
>> left "abc" 0
== ""
>> left "abc" 1
== "a"
>> left "abc" 2
== "ab"
>> left "abc" 10
== "abc "
>> left/with "abc" 10 #"-"
== "abc-------" right: func [ string [string!] n [integer!] /with char [char!] ] [ head insert/dup copy/part tail string negate n any [char #" "] n - length? string ]
>> right "abc" 0
== ""
>> right "abc" 1
== "c"
>> right "abc" 2
== "bc"
>> right "abc" 10
== " abc"
>> right/with "1" 2 #"0"
== "01"
>> zero-pad: func [val [integer!] n] [right/with form val n #"0"] >> zero-pad 5 2
== "05"
>> zero-pad 5 4
== "0005"
> Tell you something else I'd give my left one for, a straight port of > the Arexx parse command. I don't think I'll *ever* understand Rebols > :(
You will; it's simpler than Arexx and is *MUCH* more powerful! HTH, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/