Tags for text

I think is a good ideea to create a dedicated topic with tags for text.
I say last week some tags for distance in km and miles, but now, i can’t find it anymore. Can somebody help me please?
Thank’s.

This topic had a formula for converting Step counts to Distance I think that is what you are thinking of.

Ron
Samsung Developer Relations

1 Like

Yes, this is what I was looking for. Thank you.
This is a conversion formula from stept to km. But there is any chance to get the distance from GPS ?

If you want to create something in Android Studio that does this.

Ron
Samsung Developer Relations

If you wanted to get the digits from a floating point or integer value into a text field a digit at a time, you could do the following:

From the values I have seen in the tag expressions, it shows some values up to 3 decimal places. Using that as the precision, this would be how I would do it (note: I included a Thousands value and a Thousandths value just so you can see the pattern further).

Let’s say [tag] = 1653.274
Replace tag with your expression

Thousands: (([tag]%10000 - [tag]%1000)/1000)
(1653.274 - 653.274)/1000 = (1000)/1000 = 1

Hundreds: ([tag]%1000 - [tag]%100)/100)
(653.274 - 53.274)/100 = (600)/100 = 6

Tens: (([tag]%100-[tag]%10)/10)
(53.274 - 3.274)/10 = (50)/10 = 5

Ones: ([tag]%10-[tag]%1)
3.274 - 0.274 = 3

Tenths: (([tag]*1000%1000-[tag]*1000%100)/100)
(1653274%1000 - 1653274%100)/100 = (274 - 74)/100 = (200)/100 = 2

Hundredths: (([tag]*1000%100-[tag]*1000%10)/10)
(1653274%100 - 1653274%10)/10 = (74 - 4)/10 = (70)/10 = 7

Thousandths: ([tag]*1000%10)
1653274%10 = 4

Nice! Thank You
My formula for distance in kms is:

((([SC]*0.000762)*1000-([SC]*0.000762)*1000%1000)/1000%10).((([SC]*0.000762)*1000%1000-([SC]*0.000762)*1000%100)/100)((([SC]*0.000762)*1000%100-([SC]*0.000762)*1000%10)/10)

:rofl: :rofl: :rofl:

In Watchmaker is very easy: string.format("%.2f",[SC]/1350)

A very simple question.
How can I add or subtract hours from an hour Tags with leading zeros. I mean, something like “([HOUR_0_11]+1)” but with the Tag [HOUR_0_11_Z]. On hour scale not in natural number scale. I Don’t know if I’m explaining enough…
Help will be apreciatted
Thanks

The leading zero tags are actually handled as a string, not a number. I’d like to introduce a way to make leading zero after a number tag calculation.

( ([HOUR_0_11]+1) < 10 ? “0” : “”)([HOUR_0_11]+1)

would work as you want.

Thank you very very much sinjae. I’ll try as soon as I can. I think I understand the procedure.
Kind reggards
Jorge O

Unfortunately, it doesn’t work. If you have any other suggestions…

Thank you Sinjae

The problem is the quotes. If you copy/pasted the tag expression from the example, they are smart quotes (meaning curved open/close quotes). Just replace the quotes with your own quotes in the text field. On another note, you may want to use the following example instead of always adding +1:

(([HOUR_1_12]) < 10 ? "0" : "")([HOUR_1_12])

Note: the example I provided does not have smart quotes. When you want to display straight quotes here in the forum, you can use the bbCode tag for “code” like the following to display it as code:

codeTag

This will keep the quotes as straight quotes and not smart quotes on this forum.

Great! Thanks for the information :slight_smile:

1 Like

Yesss. The problem was the quotes. Now it works fine. Finally I use the the Tag that VizFX suggested. Why? It works better on negative, in one number. Although in the second negative value shows “0-1”. Something like…"…0-2, 0-1, 00, 01, 02…" instead of “…10, 11, 00, 01, 02…”

My apologies for being so clumsy, and my gratitude for all of you

so, if it is negative and one digit, what you need is “-0” and then multiply your tag by -1 to negate the minus sign.

But, if you want -2 = 10, -1 = 11, then you need to check for < 0 if so 12 + [YOUR_TAG]

Thank you Viz. I tried almost everything with minus sign…but “-0”. I couldn’t think it will works.

I promise not to bother anymore with this.

Thank you again Viz.

@jvc1963 did you get it to work? I wasn’t sure which direction you were going with the negative number so I didn’t want to confuse anything and provide code examples. I think from my 2 suggestions you might have gotten it to work, but if you need another code example, just let me know.

Those day I’m out, so I can’t check it now. When I como home I’ll try and let you know.

For decrement hour with leading zero you may use next expression

((([HOUR_1_24]-1) % 24) < 10?"0":"")(([HOUR_1_24]-1) % 24)

Did you mean to say %12?

No, I meant exactly what I wrote.
For a 24-hour time representation with leading zero, this expression will give the previous hour. In the case when the current hour = 0, not -1 will be returned, but 23.

1 Like