How to right pad number

How to right pad space for numbers. Ex: If i want to fix the length of numbers are always 4, i expect as following:

  1. If input 1, it will become 1{3 spaces}
  2. If input 10, it will become 10{2 spaces}
  3. If input 100, it will become 10{1 spaces}
  4. If input 1000, it will become 1000{0 spaces}

If used this function: [=F(’{QUANTITY}’,’{0,-4}’)], but it always adds 4 spaces to any number length

Thanks so much

Can you show a screenshot example of what your talking about?

This is the screen shot:

I want the quantity always fixes with 4 spaces regardless of number length. The expected format is as following:

1   Heinneken Chai
100 Tiger bạc

Can you show your printer template?

Here you are:

-- General layout
<L00>Gia Lộc - Trảng Bàng - Tây Ninh
<L00>ĐT: 0663.615.218
<J10>Tổng cộng:|[=FF('{TICKET TOTAL}','#,##0')]
<J10>[Tendered:| {TENDERED TOTAL}]
<J10>[Change:| {CHANGE TOTAL}]
<C10>            CẢM ƠN QUÝ KHÁCH


-- Default format for orders
<span style="text-align:left">
<J10>[=F('{QUANTITY}','{0,-4}')]|{NAME}|[=FF('{TOTAL PRICE}','#,##0')]

-- Format for combo orders

-- Nothing will print for void lines

-- Format for order tags

-- Table entity format

-- Customer entity format
<J00>Customer: {ENTITY NAME} | {ENTITY DATA:Phone}

May use this

<J>  [=('{QUANTITY}'+"   ").substr(0,3)]{NAME}|{TOTAL PRICE}

It doesnot work. The quantity is gone.

Sorry, i still can’t format text at this reply.

1 Like

It’s ok. If we can do pad number like PHP or Javascript is great…:frowning:
Anyway, thanks so much for your support

What he posted works just fine.

So try this:

<J10>[=('{QUANTITY}'+"    ").substr(0,4)] {NAME}|{TOTAL PRICE}
1 Like

Yeah… I tried this one and it works fine:

Thanks guys for your great support! Wish you all the best <3

1 Like

@RickH I thought you were looking to do something similar several months ago?

Yep i did qmckay helped me out with it, sorry ive not been around today oherwise id have posted my template

Glad youre sorted now though :slight_smile:

1 Like