Okay, I have a working version but I think I should be able to do it more
elegantly. I have the complete choTask function below (pretty printed
ofcourse :) ) I have the repeating pattern as XXX which I replace using
patch -
(patch choTask 'XXX '(filter '((X) X) (mapcar '((X) (uppc (pack X)))
*Tags)))
Which works but seems to me like I am not using "macros" correctly.
(de choTask (Dst)
(diaform
'(Dst)
(<grid>
"--"
"Name"
(gui
'ttl
'(+DbHint +Var +TextField)
'(ttl +Task)
'*Name
20 )
"Tags"
(gui
'tags
'(+Var +ListTextField)
'*Tags
'("," " ")
20 )
(searchButton '(init> (: home query))) )
(gui
'query
'(+QueryChart)
*ROWS
'(goal
'(@Names
XXX
@Gen
(mapcan
'((Nm) (list 'nm '+TagNm Nm))
'XXX )
(select
(@@)
((@Gen (nm +Tag) tsk))
(^
@
(fully
'((Nm)
(find
'((This) (member Nm (: nm nm)))
(; (-> @@) tgs) ) )
(-> @Names) ) ) ) ) )
1
'((This) (list This)) )
(<table>
NIL
(choTtl "Entries" '+Task)
'(("em20 align" "Name"))
(do *ROWS
(<row>
NIL
(gui 1 '(+ObjView +TextField) '(: ttl)) ) ) )
(<spread> (scroll *ROWS) (newButton T Dst '(+Task))) ) )
On Wed, Dec 4, 2019 at 5:43 AM C K Kashyap <[email protected]> wrote:
> Thanks Alex,
> Sure, I'll do a pp in future - also start following that conventions.
>
> About @Gen using @Names - the second argument of mapcan in the definition
> of @Gen is essentially @Names. I am looking for a way to avoid having to
> repeat the expression (filter ...
>
>
> (gui
>
> 'query
>
> '(+QueryChart)
>
> *ROWS
>
> '(goal
>
> '(@Names
>
> (filter
>
> '((X) X)
>
> (mapcar
>
> '((X) (uppc (pack X)))
>
> (split (chop *Tags) " ") ) )
>
> @Gen
>
> (mapcan
>
> '((Nm) (list 'nm '+TagNm Nm))
>
> '(filter
>
> '((X) X)
>
> (mapcar
>
> '((X) (uppc (pack X)))
>
> (split (chop *Tags) " ") ) ) )
>
> (select
>
> (@@)
>
> ((@Gen (nm +Tag) tsk))
>
> (^
>
> @
>
> (fully
>
> '((Nm)
>
> (find
>
> '((This) (member Nm (: nm nm)))
>
> (; (-> @@) tgs) ) )
>
> (-> @Names) ) ) ) ) )
>
> 1
>
> '((This) (list This)) )
>
>
>
>
> Regards,
> Kashyap
>
> On Wed, Dec 4, 2019 at 3:07 AM Alexander Burger <[email protected]>
> wrote:
>
>> Hi Kashyap,
>>
>> On Tue, Dec 03, 2019 at 07:48:58PM -0800, C K Kashyap wrote:
>> > I'll need a little bit more help with Pilog in QueryChart - In the code
>> > below,
>>
>> Could you in the future provide code which is formatted in a more
>> readable way?
>> It is very hard to decipher. Better no spaces between lines, and
>> indentations
>> and parentheses more to the standard (see the output of 'pretty' and
>> 'pp').
>>
>> If I try to fix it manually, I get (hope I did not destroy anything):
>>
>> (diaform '(Dst)
>> (<grid> "--"
>> "Name" (gui 'ttl '(+DbHint +Var +TextField) '(ttl > Task) '*Name
>> 20)
>> "Tags" (gui 'tags '(+Var +TextField) '*Tags 20)
>> (searchButton '(init> (: home query))) )
>> (gui 'query '(+QueryChart) *ROWS
>> '(goal
>> (quote
>> @Names
>> (filter
>> '((X) X)
>> (mapcar
>> '((X) (uppc (pack X)) )
>> (split (chop *Tags) " ") ) )
>> @Gen
>> (mapcan
>> '((Nm) (list 'nm '+TagNm Nm))
>> '(filter # Commented?
>> '((X) X) #??
>> (mapcar
>> '((X) (uppc (pack X)))
>> (split (chop *Tags) " ") ) ) )
>> (select (@@)
>> ((@Gen (nm +Tag) tsk))
>> (^ @
>> (fully
>> '((Nm)
>> (find
>> '((This) (or T (member Nm (: nm nm)))) # T?
>> (; (-> @@) tgs) ) )
>> (-> @Names) ) ) ) ) )
>> 1
>> '((This) (list This)) )
>>
>> (I assume the quotes, T etc. are temporary tests)
>>
>>
>> > I get the tags as a list of space separated words in the *Tags
>> > variable.
>>
>> That's all right, but better may be to use +ListTextField, it directly
>> returns a
>> list of strings:
>>
>> "Tags" (gui 'tags '(+ListTextField) '("," " ") 20)
>>
>>
>> > I create the @Names and @Gen pilog variables using *Tags. As you
>> > can see @Gen uses @Names inside it but I am not sure how to reuse the
>> > definition of @Names inside the definition of @Gen. I tried wrapping the
>> > whole "gui" call inside a let binding but that does not seem to work
>> > either. What's the way out?
>>
>> Sorry, I don't understand this. In which way does @Gen "use" @Names?
>>
>> ☺/ A!ex
>>
>> --
>> UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe
>>
>