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:

[LAYOUT]
-- General layout
<L00>Gia Lộc - Trảng Bàng - Tây Ninh
<L00>ĐT: 0663.615.218
<BMP>d:\logo\logo.png
<EB>
<L00>Ngày: {TICKET DATE} {TIME}
{ENTITIES}
<F>-
<J10>SL|TÊN MÓN|THÀNH TIỀN
<F>-
{ORDERS}
<F>=
<J10>Tổng cộng:|[=FF('{TICKET TOTAL}','#,##0')]
{PAYMENTS}
<J10>[Tendered:| {TENDERED TOTAL}]
<J10>[Change:| {CHANGE TOTAL}]
<C10>            CẢM ƠN QUÝ KHÁCH
<DB>
<F>=

[PAYMENTS]
<J10>{PAYMENT NAME}|{PAYMENT AMOUNT}

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

[ORDERS:Combo]
-- Format for combo orders
<J00>{QUANTITY} {NAME}|{TOTAL AMOUNT}
{ORDER TAGS}

[ORDERS:Void]
-- Nothing will print for void lines

[ORDER TAGS]
-- Format for order tags
<J00> * {ORDER TAG NAME} | {ORDER TAG PRICE}

[ENTITIES:Table]
-- Table entity format
<L00>Bàn: {ENTITY NAME}

[ENTITIES:Customer]
-- 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