string format
Marielle Lange
rp011s7075 at blueyonder.co.uk
Sun Aug 28 03:41:01 EDT 2005
Alex,
> The format function is indeed very useful - but I don't think it
> can be used to solve the particular problem of adding spaces after
> a string to fill it out to a specified length.
>
> Or at least - when I was looking at the problem the other day, one
> of the alternatives I considered was "format", but I couldn't see a
> way to use it to solve this problem :-)
I had forgotten the spaces were to be put after the string, rather
than before. I reckon the example you provided was really making
excellent used of xTalk (nice lesson, thanks).
What you can do with sprintf (sorry, format in xtalk) combined with
regular expressions is quite powerful though:
put format("%14s","A") into aDataCell
get matchtext(aDataCell, "( *)(.*)", tspaces, tstr)
put "_" & tstr & tspaces & "_"
("_" only added to make the trailing spaces visible)
Marielle
------------------------------------------------------------------------
---------------------------------
Marielle Lange (PhD), Psycholinguistics, Lecturer in Psychology and
Informatics
University of Edinburgh, UK
Homepage: http://homepages.inf.ed.ac.uk/mlange/
Lexicall project: http://lexicall.org
Revolution-education project: http://revolution.lexicall.org
More information about the use-livecode
mailing list