On Wed, Dec 18, 2019 at 12:50:55PM -0800, C K Kashyap wrote:
>   (if *CfgNurNetto
>                (gui 7 '(+Upd +Chg +FixField)       # B-Preis
>                   '(let? Pos (curr) ...
> 
> Looks like the (gui 7...) is either a FixField or a Checkbox depending on
> *CfgNurNetto

Correct. But *CfgNurNetto is a global, set in 'main', before this page is
called.

> I think I think I have something that illustrates the idea I am trying to
> do. Here, set the width of the TextField to 50 if the text contained is
> "ABC".
> ...
>  (for R (range 1 5)
> ...
>     (if
>        (let L (: chart 1 data)
>           (and
>              (car (nth L R))
>              (= "ABC" (get @ 'cmt)) ) )
>        (gui 2 '(+TextField) 50 3)
>        (gui 2 '(+TextField) 150 3) )

This may work, but I don't think it is useful, as the width is fixed after the
page is drawn, and will not change later when the data change.

First, it should be cleaned up. 'for' with 'range' is not a good idea, as it
buils a list (garbage) for no reason. Better is (for R 5 ...).

Then, (car (nth L R)) is just (get L R), but the whole 'let' is overkill
(binding is expensive), as 'L' is used only once.
Same with 'and'. I think it can be reduced to

   (= "ABC" (get (: chart 1 data) R 'cmt))

so the above could just be

   (gui 2 '(+TextField)
      (if (= "ABC" (get (: chart 1 data) R 'cmt))
         50
         150 )
      3 ) )


> Calling (nth) repeatedly does not seem nice - also I am not sure if
> (: chart 1 data) can be used reliably here.

As we are here in the static GET transaction, you may use *ID or (: obj)
directly

      (if (= "ABC" (get *ID 'cmts R 'cmt))

For short lists, 'get' or 'nth' is no problem at all, the traversal is shorter
than the function call overhead anyway.

But more lispy is to map the data directly:

   (for Obj (; *ID cmts)
      ...
      (gui 2 '(+TextField)
         (if (= "ABC" (; Obj cmt)) 50 150)
         3 ) )

☺/ A!ex

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

Reply via email to