<RefEntry id="measurement-to-length">
<!-- This file is generated automatically from the DSSSL source. -->
<!-- Do not edit this file! -->
<?html-filename measurement-to-length.html>

<RefMeta>
  <RefEntryTitle>measurement-to-length</RefEntryTitle>
  <RefMiscInfo Role="file">dblib.dsl</RefMiscInfo>
</RefMeta>

<RefNameDiv>
  <RefName>measurement-to-length</RefName>
  <RefPurpose>Convert a measurement to a length</RefPurpose>
</RefNameDiv>

<RefSynopsisDiv><Title>Synopsis</Title>
<Synopsis>
(measurement-to-length measure)
</Synopsis>
</RefSynopsisDiv>

<RefSect1><Title>Description</Title>

<para>
Given a string containing a measurement, return that measurement
as a length.</para>


</RefSect1>

<RefSect1><Title>Example</Title>

<para>
<literal>"2.5cm"</literal> returns 2.5cm as a length.  <literal>"3.4barleycorn"</literal> returns
6.8pi.
</para>


</RefSect1>

<RefSect1><Title>Author</Title>

<para>
Norman Walsh, &lt;ndw@nwalsh.com&gt;
</para>
</RefSect1>
<RefSect1><Title>Source Code</Title>

<ProgramListing>
(define (measurement-to-length measure)
  ;; Convert a measurement to a length
  (let* ((pm (car (parse-measurement measure)))
	 (pu (car (cdr (parse-measurement measure))))
	 (magnitude (if pm pm "1"))
	 (units     (if pu pu (if pm "pt" "default")))
	 (unitconv  (assoc units unit-conversion-alist))
	 (factor    (if unitconv (car (cdr unitconv)) 1pt)))
    (* (string->number magnitude) factor)))
</ProgramListing>
</RefSect1>

</RefEntry>
