Mohammad,

Some of the JS code in this may be helpful?

https://ibnishak.github.io/Tesseract/pluginsandmacros/index.html#Action-JSONtid

This utility by Riz was created to auto-name and number with padded prefix. 
It was specifically aimed to convert JSON collections of Tiddlers without 
title fields to be imported.

Maybe parts of it are useful?

Best
Josiah

On Friday, 15 February 2019 19:17:54 UTC+1, Mohammad wrote:
>
> Thanks Mark, 
>
> I tried to do not touch JS in Tiddler Commander and also keep code simple! 
> (Of course I know very little java script) 
> but seems I have to use JS. For example TW has nothing with string 
> search/replace and the JS code you provided do the job very well.
>
> The macro I proposed above works for me but, modifying the *bulk tiddler 
> creator* makes code complex and difficult to understand.
>
> --Mohammad
>
>
> On Friday, February 15, 2019 at 9:27:41 PM UTC+3:30, Mark S. wrote:
>>
>> Hi Mohammad,
>>
>> Your macros show a deep knowledge of the tools in TW.
>>
>> I'm a bit concerned that each level of indenture requires another chunk 
>> of code, which may be hard to maintain.
>>
>> The thing is, this sort of thing is easy if you have the right text 
>> tools. We need the concat function and a substr function. Unfortunately the 
>> new tools lack the substr. How do you feel about using javascript macros 
>> (and filters) in TW-commander?
>>
>> I just thought of another approach. Maybe. You could use a list filter 
>> and call it recursively. Each time you prefix a "0". When the length (new 
>> math function?) reaches the padded number length, the recursion ends and 
>> the result is sent back. The problem here is that I don't the parameters 
>> for the length function. The length would have to be compared to the target 
>> length and the only comparison tool is the revealwidget.
>>
>> -- Mark
>>
>> On Friday, February 15, 2019 at 8:31:53 AM UTC-8, Mohammad wrote:
>>>
>>> Mark,
>>>  String operation are added to TW - prerelease, see below
>>>
>>> Ref: 
>>>
>>>    - 
>>>    
>>> https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/filters/strings.js
>>>    - 
>>>    
>>> https://github.com/Jermolene/TiddlyWiki5/commit/9b2d52716a24197ba9fd67b708cbe2c56fa1b5d0
>>>
>>>
>>> By the way, please let me know your opinion on the above macros.
>>>
>>> --Mohammad
>>>
>>> On Friday, February 15, 2019 at 7:57:17 PM UTC+3:30, Mark S. wrote:
>>>>
>>>> Like others in the forum, I'm finding that search links do not work. 
>>>> You had a post earlier (which I can't get to) about new string operators 
>>>> being added in the pre-release. But there's no documentation for string 
>>>> operators -- only the new math operators.
>>>>
>>>> I'm wondering if, with the new string operators, it would be possible 
>>>> to make a simpler, more concise padding macro that could provide any level 
>>>> of padding?
>>>>
>>>> Could you share any information or documentation you've uncovered about 
>>>> the string operators?
>>>>
>>>> Thanks!
>>>> -- Mark
>>>>
>>>> On Friday, February 15, 2019 at 8:18:05 AM UTC-8, Mohammad wrote:
>>>>>
>>>>> Asked by Josiah here:
>>>>>
>>>>> https://groups.google.com/d/msg/tiddlywiki/w9Bv-WulKw8/O3RaMUwqBAAJ
>>>>>
>>>>> To produce numbers zero padded like
>>>>>
>>>>> 001
>>>>> 002
>>>>> 003
>>>>> ...
>>>>>
>>>>> 099
>>>>> 100
>>>>>
>>>>> Here is a macro to do that
>>>>>
>>>>> \define zeropad-range(n:10)
>>>>> <$list filter="[range[1,$n$]]" variable=x >
>>>>> <$reveal type="lteq" default=<<x>> text="9" >
>>>>> <$text text= {{{[<x>addprefix[00]]}}} />
>>>>> </$reveal>
>>>>> <$reveal type="gt" default=<<x>> text="9" >
>>>>> <$text text= {{{[<x>addprefix[0]]}}} />
>>>>> </$reveal>
>>>>> </$list>
>>>>> \end
>>>>>
>>>>> Example
>>>>>
>>>>> 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017
>>>>> 018 019 020 021 022 023 024 025
>>>>>
>>>>> The below macro works up to 1000
>>>>>
>>>>> \define zeropad-range4(n:10)
>>>>> <$list filter="[range[1,$n$]]" variable=x >
>>>>> <$reveal type="lteq" default=<<x>> text="9" >
>>>>> <$text text= {{{[<x>addprefix[000]]}}} />
>>>>> </$reveal>
>>>>> <$reveal type="gt" default=<<x>> text="9" >
>>>>> <$reveal type="lt" default=<<x>> text="99" >
>>>>> <$text text= {{{[<x>addprefix[00]]}}} />
>>>>> </$reveal>
>>>>> </$reveal>
>>>>> <$reveal type="gt" default=<<x>> text="99" >
>>>>> <$text text= {{{[<x>addprefix[0]]}}} />
>>>>> </$reveal>
>>>>> </$list>
>>>>> \end
>>>>>
>>>>>
>>>>>
>>>>> --Mohammad
>>>>>
>>>>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f3d70b41-17bc-4dc0-93b1-cd407b22de17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to