In previous post the first $list seems *incorrect*! So, for now ignore it 
and use the revised substr code as below:

\define substr(string, start, length)
<$vars Length={{{ [[$length$]!is[blank]then[$length$]]~[[$string$]length[]] 
}}}  >
<$text text={{{ [<__string__>split[]butfirst<__start__>first<Length>join[]] 
}}} />
</$vars>
\end


I am thinking not check the input at all or find a better solution!

--Mohammad



On Saturday, March 28, 2020 at 11:24:00 PM UTC+4:30, Mohammad wrote:
>
> This is a modified version of substr proposed by Jed and it works amazing!
>
> \define substr(string, start, length)
> <$list filter="[<__string__>!is[blank]]+[<__start__>!is[blank]]" 
> variable=ignore>
> <$vars Length={{{ 
> [[$length$]!is[blank]then[$length$]]~[[$string$]length[]] }}}  >
> <$text text={{{ 
> [<__string__>split[]butfirst<__start__>first<Length>join[]] }}} />
> </$vars>
> </$list> 
> \end
>
> <<substr "This_is_a_Test" 1 3>>
>
> <<substr "This_is_a_Test" 5>>
>
> <<substr "This_is_a_Test" -5>>
>
> <<substr "This_is_a_Test" -10 6>>
>
> The two inputs *string *and *start* are required and the last input, *length 
> *is optional.
> Macro checks if the first two parameters are missing!
>
> It gives amazing but correct results! Give a try in tiddlywiki.com.
> Note to the minus value for start and It takes characters from the 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f585c8b6-f09e-4d1c-8410-7694a1dfe840%40googlegroups.com.

Reply via email to