Re: Dynamic generation of "progress bars"

2014-03-02 Thread Alexander Burger
On Sun, Mar 02, 2014 at 05:38:20PM -0500, me wrote:
> Please help point me in the right direction once again?  What I'm
> attempting to achieve is something like:
> 
> ( "progress"
>   ( '("progress-bar progress-bar-success"
>(role . "progressbar")
>(aria-valuenow . "-79")
>(aria-valuemin . "-100")
>(aria-valuemax . "100")
>(style . "width: 79%") )
>  ( "sr-only" "79% Nominal") ) )
> 
> 
> What I have is:
> 
> (de make-progress-bar (bar-type width)
>( "progress"
>   ( '(`(,pack "progress-bar progess-bar-" ,bar-type)
>(role . "progressbar")
>(aria-valuenow . `(,pack ,width))
>(aria-valuemin . "-100")
>(aria-valuemax . "100")
>(style . `(,pack "width: " ,width "%")) )
>  ( "sr-only" `(,pack ,width "% Nominal")) ) ) )
> 
> 
> What is the idiomatic way to manipulate text such that I can dynamically
> generate different types of progress bars?  The idea being that I could use
> different color coded static progress bars as a simple form of charting
> data.

The problem with the solution above is that the backquote has a meaning
in PicoLisp different from that in CL. It is a read macro, not a
pattern-filler at runtime. Same goes for the comma.

Passing a list dynamically at runtimes means that it must be built at
runtime. This should work:

   (de make-progress-bar (Bar-type Width)
  ( "progress"
 (
(list
   (pack "progress-bar progress-bar-" Bar-type)
   '(role . "progressbar")
   (cons 'aria-valuenow Width)
   '(aria-valuemin . "-100")
   '(aria-valuemax . "100")
   (cons 'style (pack "width: " Width "%")) )
( "sr-only" Width "% Nominal") ) ) )

   (make-progress-bar "success" 79)

You might also take a look at 'fill' (which is a bit similar to the CL
backquote function) to build the list, but that's a little more
involved in this case:

   (de make-progress-bar (Bar-type @Width)
  (let
 (@B (pack "progress-bar progress-bar-" Bar-type)
@W (pack "width: " @Width "%") )
 ( "progress"
(
   (fill
  '(@B
 (role . "progressbar")
 (aria-valuenow . @Width)
 (aria-valuemin . "-100")
 (aria-valuemax . "100")
 (style . @W) ) )
   ( "sr-only" @Width "% Nominal") ) ) ) )

   (make-progress-bar "success" 79)

The effect is the same in both cases.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Dynamic generation of "progress bars"

2014-03-02 Thread me
Hello List,
Please help point me in the right direction once again?  What I'm
attempting to achieve is something like:

( "progress"
  ( '("progress-bar progress-bar-success"
   (role . "progressbar")
   (aria-valuenow . "-79")
   (aria-valuemin . "-100")
   (aria-valuemax . "100")
   (style . "width: 79%") )
 ( "sr-only" "79% Nominal") ) )


What I have is:

(de make-progress-bar (bar-type width)
   ( "progress"
  ( '(`(,pack "progress-bar progess-bar-" ,bar-type)
   (role . "progressbar")
   (aria-valuenow . `(,pack ,width))
   (aria-valuemin . "-100")
   (aria-valuemax . "100")
   (style . `(,pack "width: " ,width "%")) )
 ( "sr-only" `(,pack ,width "% Nominal")) ) ) )


What is the idiomatic way to manipulate text such that I can dynamically
generate different types of progress bars?  The idea being that I could use
different color coded static progress bars as a simple form of charting
data.

Thank you.