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

[REBOL] Re: Constant size string variable?

From: ingo:2b1 at: 2-Dec-2001 12:01

Hi Bob, Once upon a time Bob Paddock spoketh thus: <..>
> I need a string variable that is always ten characters long.
<..>
> Examples: > > ++++++++++ [10 of them] > +++++++++1 > ++++++4321 > +987654321
Here're some ideas to get you going ...
>> ; Version 1 >> fillers: "++++++++++"
== "++++++++++"
>> str: "677"
== "677"
>> pos: (length? f) - (length? str) + 1
== 8
>> f: copy fillers
== "++++++++++"
>> change at f pos str
== ""
>> f
== "+++++++677"
>> ; Version 2 >> len: (length? f) - (length? str)
== 7
>> rejoin [ copy/part fillers len str ]
== "+++++++677"
>> ; Version 3 >> copy skip tail join fillers str -10
== "+++++++677" I hope that helps, Ingo