How do I do a LTRIM on a variable in ZPL2?

I need to trim leading spaces from a variable I'm sending to a label with ZPL2.

This is what the row of code looks like:

^FO260,39^ACR,73,25^FD$1HWWRPQT^FS

$1HWWRPQT is a variable.

I tried this:

^FO260,3^ACR,73,25^FDLTRIM$($1HWWRPQT)^FS

But it returns:

LTRIM$($1HWWRPQT)

How do I trim the variable?  Do I need something between the ^FD and the LTRIM$()?

Dmitry Prokhorov
Hello Curtis,As you can see

Hello Curtis,

As you can see in ZPL Programming Guide: https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf  the LTRIM$ command is ZBI language command, not ZPL command. You can call ZBI from ZPL with "^JI" or "~JI" ZPL command. Although, it will require you to write some program on ZBI language, not just to call LTRIM$ function.

You can find ZBI examples here: Zebra Basic Interpreter (ZBI) Support & Downloads | Zebra

Hope it helps.

Dmitry Prokhorov

Software Engineer, Kutir Mobility

Posted on behalf of Zebra Technologies

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Curtis Richey
Yes, this won't work well for

Yes, this won't work well for me in my situation.  Thanks for the reply.

Are you aware of any ZPL commands that would trim leading spaces from a variable?  Or a substring command perhaps?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Dmitry Prokhorov
Hello Curtis,Unsure there is

Hello Curtis,

Unsure there is any ZPL command that is able to trim leading spaces from arbitrary value of variable. However there is ^SN ZPL command that handle leading zeros and spaces and allows the printer to index data fields by a selected increment or decrement value, making the data fields increase or decrease by a specified value each time a label is printed.

Dmitry Prokhorov

Software Engineer, Kutir Mobility

Posted on behalf of Zebra Technologies

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Curtis Richey
Unfortunately, the number of

Unfortunately, the number of spaces varies depending on the length of the data.

Thank you for the reply.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments