How to use Substring with [:CommandValue]

How to use Function substr with [:CommandValue]?
I try to make Ask Parameter for Discount. I want to split $ and % from CommandValue.

Tried:
[:CommandValue].substr(1,6)
[=F([:CommandValue]).substr(1,6)]
[=F([:CommandValue]),’#.##’)]
But it is not working. Any idea how it works?

Thanks,
Sukasem

@sukasem try [=’[:CommandValue]’.substr(1,6)]

I thing you are trying to strip mag card control chars. If you tell us more about your implementation I can give more info about how to deal with that.

Hi @emre,
I want to make one button for discount by amount and percent. But how to strip out only 1 first or 1 last letter.
If I use above example substr(1,6) for $5, it will return empty. But if I use substr(1,2), it works.
I also try substr(1) or substr(-1), not working too.

EDIT: Ah, there is function for Length of string (.length). Great! I think I can do it now.

I’m not sure if it will work or not but also try [='[:CommandValue]'.substr(1,-1)] :slight_smile:

I got it working with TN(’[:CommandValue]’.length)-1

2 Likes

BTW, [='[:CommandValue]'.substr(1,-1)] works for stripping first letter. But I can’t figure it how to strip the last letter.

It can be something like

[='[:CommandValue]'.substr('[:CommandValue]'.length-1,1)]

A post was split to a new topic: [5.1.42] Substr function changed?