Re: [tw5] Test for existence of macro

2019-03-03 Thread Jeremy Ruston
Hi David I wasn't suggesting that git was a universal solution, more that it's one of many techniques that users with different prior experience can use to manage multiple revisions of their files. Dropbox doesn't require any prior technical experience. TiddlyWiki's single file format means

Re: [tw5] Test for existence of macro

2019-03-02 Thread David Nebauer
What you say is correct, Jeremy, and I'm already version controlling my wiki and keeping my personal customisations in plugins, and yet... your comments trigger a couple of thoughts. The first is that TW is "marketed" as a personal notebook as much as a personal wiki. The second sentence at

Re: [tw5] Test for existence of macro

2019-03-02 Thread Jeremy Ruston
Hi David I think the problem you’re describing is the possibility that ones delicate arrangements of customisations might break, perhaps through an upgrade or human error. That’s certainly something I can relate to, and I’m interested in how we can address the brittleness of complex wikis.

Re: [tw5] Test for existence of macro

2019-03-02 Thread David Nebauer
S. S., no problem. I touched on it in a post earlier in the topic. My use case is that I've been using TW for a couple of months now and am starting to include some macros in my tiddlers that are either defined in standalone macro tiddlers or in non-core plugins. One example is Mohammad's <>

Re: [tw5] Test for existence of macro

2019-02-28 Thread S. S.
David, it was an interesting question. Could you share what happened for you to want that feature, and how you are using it? On a similar track - the code in the <> macro can show the values of all variables and macros that exist at that position in the widget tree. I wonder if it would it be

Re: [tw5] Test for existence of macro

2019-02-28 Thread David Nebauer
Okay, in summary, here are two ways of using the [is[variable]] operator to display an error message if a specific variable or macro is undefined. * As a macro: \define check-var-or-macro(var) <$list filter="[[$var$]] +[is[variable]]" emptyMessage="Undefined variable or macro '$var$'"> <> \end

Re: [tw5] Test for existence of macro

2019-02-28 Thread PMario
On Thursday, February 28, 2019 at 4:57:31 AM UTC+1, Mal wrote: > > but the "!" does not seem to be working. If you try a similar > arrangement to test for non-existence of a tiddler, using "!is[tiddler]", > it does work as expected. > > I think I will raise this as a GitHub issue. > This

Re: [tw5] Test for existence of macro

2019-02-28 Thread David Nebauer
Thanks, Mal. Your proposed solution would certainly be a more concise and elegant way to achieve the same outcome. If you don't mind, perhaps you could keep this topic updated with developments and/or include a pointer to the github issue you raise. Regards, David. On Thursday, 28 February

Re: [tw5] Test for existence of macro

2019-02-28 Thread David Nebauer
Thanks S. S. That does juts what I wanted. I'll call that success. Regards, David. On Thursday, 28 February 2019 11:02:47 UTC+9:30, S. S. wrote: > > This seems to work for me. > > \define variable-test(var) > <$list filter="[[$var$]] +[is[variable]]" emptyMessage="''$var$'' - > Undefined

Re: [tw5] Test for existence of macro

2019-02-27 Thread Mal
David, On Wednesday, 27 February 2019 23:46:51 UTC+10, David Nebauer wrote: > > Hmm, I may have declared success prematurely. Is there a way to > reformulate the test so that if the macro *is* defined, the <$list> > displays nothing. I really only want output if the error condition -- a >

Re: [tw5] Test for existence of macro

2019-02-27 Thread S. S.
This seems to work for me. \define variable-test(var) <$list filter="[[$var$]] +[is[variable]]" emptyMessage="''$var$'' - Undefined variable or macro"> \end 1. <> 2. <> It uses a single line return with nothing else in the *results area* before the closing tag to give an empty looking

Re: [tw5] Test for existence of macro

2019-02-27 Thread TonyM
Rather than use the else ~ for the error message use emptyMessage on the list widget. Tony -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [tw5] Test for existence of macro

2019-02-27 Thread David Nebauer
Hmm, I may have declared success prematurely. Is there a way to reformulate the test so that if the macro *is* defined, the <$list> displays nothing. I really only want output if the error condition -- a missing macro -- occurs. Otherwise I want it to do nothing while the rest of the

Re: [tw5] Test for existence of macro

2019-02-26 Thread Mohammad
Thanks David! Added to TW-Scripts. --Mohammad On Wednesday, February 27, 2019 at 5:07:17 AM UTC+3:30, David Nebauer wrote: > > Thanks very much, Mohammad and Jeremy. For future reference, here is what > I was seeking: > > <$list filter="[[VAR_OR_MACRO_NAME]] +[is[variable]addsuffix[ is a >

Re: [tw5] Test for existence of macro

2019-02-26 Thread David Nebauer
Thanks very much, Mohammad and Jeremy. For future reference, here is what I was seeking: <$list filter="[[VAR_OR_MACRO_NAME]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined variable or macro 'VAR_OR_MACRO_NAME']]"> <> If anyone else sees the option for marking this topic complete, please

Re: [tw5] Test for existence of macro

2019-02-26 Thread Mohammad
Hello David, Yes, the new subfilter operator can check if a macro/variable is defined (exist) or not! It works in TW5.1.20pr. Example \define VAR_NAME() This is a test macro <$list filter="[[VAR_NAME]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined variable or macro 'VAR_NAME']]"> <>

Re: [tw5] Test for existence of macro

2019-02-26 Thread David Nebauer
I'm glad my question has led to something useful for others. Unfortunately, my original question has not been answered. Is there any way to use Jeremy's new subfilter to display an error message if a specified macro is undefined? (Thanks, Mal, for your efforts.) Alternately, if it is still not

Re: [tw5] Test for existence of macro

2019-02-26 Thread Mohammad
Thanks for clarification! --Mohammad On Tuesday, February 26, 2019 at 3:38:07 PM UTC+3:30, Jeremy Ruston wrote: > > Hi Mohammad > > The reason that we don’t use the “[]” formulation here is because > we don’t want to retrieve the value of the macro, we want to get its name > as a string. > >

Re: [tw5] Test for existence of macro

2019-02-26 Thread Mohammad
Thanks Jeremy, I use the below method and it works, but it is NOT semantic! \define macro2(param) I'm a macro. Param is <$list filter="[<__param__>minlength[1]]">not provided \end <> <> --Mohammad -- You received this message because you are subscribed to the Google Groups "TiddlyWiki"

Re: [tw5] Test for existence of macro

2019-02-26 Thread Jeremy Ruston
Hi Mohammad, > Is it possible to use this operator for checking if the parameter has been > passed to a macro or not! Sadly not. One might hope this would work: \define macro(param) I'm a macro. Param is <$list filter="[[__param__]!is[variable]]">not provided \end <> <> But in fact, the

Re: [tw5] Test for existence of macro

2019-02-26 Thread Jeremy Ruston
Hi Mohammad The reason that we don’t use the “[]” formulation here is because we don’t want to retrieve the value of the macro, we want to get its name as a string. Best wishes Jeremy > On 26 Feb 2019, at 11:57, Mohammad wrote: > > Hello again Jeremy, > > Look at below code > > \define

Re: [tw5] Test for existence of macro

2019-02-26 Thread Mohammad
Hello again Jeremy, Look at below code \define macro(VAR_NAME) test \end <$list filter="[[macro]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined variable or macro 'VAR_NAME']]"> <> Why the syntax needs variable like Tiddler title, I expect to have macro or variable as below <$list

Re: [tw5] Test for existence of macro

2019-02-26 Thread Mohammad
Jeremy! Is it possible to use this operator for checking if the parameter has been passed to a macro or not! --Mohammad On Tuesday, February 26, 2019 at 12:25:58 AM UTC+3:30, Jeremy Ruston wrote: > > Hi David > > Try: > > [[VAR_NAME]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined >

Re: [tw5] Test for existence of macro

2019-02-25 Thread Mal
Jeremy, I was going to suggest this: {{{ [[myMacro]] +[!is[variable]addsuffix[ is not defined]] }}} But the "!" does not seem to be working as expected. Am I missing something here? Regards, Mal -- You received this message because you are subscribed to the Google Groups "TiddlyWiki"

Re: [tw5] Test for existence of macro

2019-02-25 Thread David Nebauer
Thanks, Jeremy, but I'm still not clear on how to use this. For newbs, i.e., me, what complete line (or lines) would you add to the top of a tiddler to display an error message if a particular macro is undefined, and do nothing if it does exist? My use case is to add this to a tiddler where I

Re: [tw5] Test for existence of macro

2019-02-25 Thread Jeremy Ruston
Hi David Try: [[VAR_NAME]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined variable or macro 'VAR_NAME']] [[currentTiddler]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined variable or macro ‘currentTiddler']] You can try out these examples in the “filter” tab of advanced search

Re: [tw5] Test for existence of macro

2019-02-25 Thread David Nebauer
Thanks, Jeremy. For future reference, would you mind showing how that subfilter could be used to test for the existence of a particular variable or macro, say 'VAR_NAME', and display the text "Undefined variable or macro 'VAR_NAME'" if it is not found. -David On Monday, 25 February 2019

Re: [tw5] Test for existence of macro

2019-02-25 Thread Jeremy Ruston
Hi David I think you’re right: there is no way to test for the existence of a variable whose value is blank. I’ve added an [is[variable]] subfilter operator for v5.1.20 to address this: https://github.com/Jermolene/TiddlyWiki5/commit/36e76429b1a1d4638374d513430393db5693b932 Best wishes

[tw5] Test for existence of macro

2019-02-25 Thread David Nebauer
As I understand it, if you attempt to call an undefined macro the call fails silently, with nothing displaying in the tiddler to alert users. This occurs regardless of the calling method, i.e., <> or <$macrocall $name="not-a-real-macro"/> *Is there a technique for checking whether a macro is