Mark, Good start. I was thinking how to get 16^0 16^1 16^2 and 16^3 and you have hard coded it. If moving to a recursive process we may be able to handle variable length hex.
But it is a little mind bending. Tones On Thursday, 3 December 2020 at 08:41:11 UTC+11 Mark S. wrote: > Here's my first attempt. It uses the 5.1.23 search-replace filter > operator. It requires the input to be padded to 4 bytes. > > Now that I've done it, I realize it could probably be written with a > recursive loop and be open ended (not needing to be padded). > > \define hex2dec2(hex) > <$vars myhex=<<__hex__>> > myfilter="[split[]nth<place>search-replace:g[A],[10]search-replace:g[B],[11]search-replace:g[C],[12]search-replace:g[D],[13]search-replace:g[E],[14]search-replace:g[F],[15]]"> > <$list filter="1 2 3 4" variable="place"><<place>> > <$list filter="[<myhex>subfilter<myfilter>] > [<place>compare:number:eq[1]then[4096]else[1]] [<myhex>subfilter<myfilter>] > [<place>compare:number:eq[2]then[256]else[1]] [<myhex>subfilter<myfilter>] > [<place>compare:number:eq[3]then[16]else[1]]+[product[]]"/> > </$list> > </$vars> > \end > \define hex2dec(hex) > <$wikify text="<<hex2dec2 $hex$>>" name=dec> > <$list filter="[enlist<dec>sum[]]"/> > </$wikify> > \end > <<hex2dec EA0E>> > > On Wednesday, December 2, 2020 at 3:34:02 AM UTC-8 TW Tones wrote: > >> Mark, >> >> On this occasion I need to convert a 4 digit Hex to a decimal, so that I >> can use it in the range widget, because we cant generate a range of hex >> numbers. >> >>> >>>> -- 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/717db388-89c1-4e69-a0be-dfae63b73933n%40googlegroups.com.

