ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Passing Variables to RAW PRINTING!

Hello everyone,
I am working with custom scripts with TSC Printer, I have read its language and i can print 2000+ tags without any issue, the problem which I am facing is I am unable to pass variables in the raw printer strings to a printer

This code works perfectly
indent preformatted text by 4 spaces
{% for row in doc.items %}
{% set serial_ids_list = row.serial_no.split("\n") %}
{% for obj in serial_ids_list %}
SIZE 103.9 mm, 25.4 mm
DIRECTION 0,0
REFERENCE 0,0
OFFSET 0 mm
SET PEEL OFF
SET CUTTER OFF
SET PARTIAL_CUTTER OFF
SET TEAR ON
CLS
BARCODE 808,122,“39”,77,0,180,1,3,“123456”
CODEPAGE 1252
TEXT 763,40,“0”,180,8,8,“123456”
TEXT 639,156,“0”,180,6,6,“2500/-PKR”
TEXT 794,182,“0”,180,6,6,“Lipton Yellow Label”
PRINT 1,1

{% endfor %}
{% endfor %}

but this one doesn’t, it prints empty tags which means that values are not being passed
indent preformatted text by 4 spaces
{% for row in doc.items %}
{% set serial_ids_list = row.serial_no.split("\n") %}
{% for obj in serial_ids_list %}
SIZE 103.9 mm, 25.4 mm
DIRECTION 0,0
REFERENCE 0,0
OFFSET 0 mm
SET PEEL OFF
SET CUTTER OFF
SET PARTIAL_CUTTER OFF
SET TEAR ON
CLS
BARCODE 808,122,“39”,77,0,180,1,3,{{obj}}
CODEPAGE 1252
TEXT 763,40,“0”,180,8,8,{{obj}}
TEXT 639,156,“0”,180,6,6,{{ frappe.db.get_value(“Item Price”, {“item_code”: row.item_code, “price_list”: “Standard Selling”}, “price_list_rate” ) }}
TEXT 794,182,“0”,180,6,6,{{row.item_name}}
PRINT 1,1

{% endfor %}
{% endfor %}

any help will be greatly appreciated

Jinja has some strange scoping rules try :
remove {% set serial_ids_list = row.serial_no.split("\n") %}
instead try
{% for obj in row.serial_no.split("\n") %}

but {% set serial_ids_list = row.serial_no.split("\n") %} is working the issue is coming with the lower part

This doesnt works
TEXT 763,40,“0”,180,8,8,{{obj}}
TEXT 639,156,“0”,180,6,6,{{ frappe.db.get_value(“Item Price”, {“item_code”: row.item_code, “price_list”: “Standard Selling”}, “price_list_rate” ) }}
TEXT 794,182,“0”,180,6,6,{{row.item_name}}

but this works

BARCODE 808,122,“39”,77,0,180,1,3,“123456”
CODEPAGE 1252
TEXT 763,40,“0”,180,8,8,“123456”
TEXT 639,156,“0”,180,6,6,“2500/-PKR”
TEXT 794,182,“0”,180,6,6,“Lipton Yellow Label”

the issue is raw strings are not getting variable

the loop is not in issue ,

The main issue is I am unable to print the values of variables being passed

@Muzzammil_Hussain I think your issue, is because you are forgetting the "

instead of

TEXT 763,40,“0”,180,8,8,{{obj}}
TEXT 639,156,“0”,180,6,6,{{ frappe.db.get_value(“Item Price”, {“item_code”: row.item_code, “price_list”: “Standard Selling”}, “price_list_rate” ) }}
TEXT 794,182,“0”,180,6,6,{{row.item_name}}

Try

TEXT 763,40,“0”,180,8,8,"{{obj}}"
TEXT 639,156,“0”,180,6,6,"{{ frappe.db.get_value(“Item Price”, {“item_code”: row.item_code, “price_list”: “Standard Selling”}, “price_list_rate” ) }}"
TEXT 794,182,“0”,180,6,6,"{{row.item_name}}"

let me give it a try

thanks alot its done

Hello @max_morais_dmm,
Where did you get this raw print commands from, I need one for 80mm thermal printer and auto cuts at height less than 8.00mm
Regards.

@iteerstech from the printer manual!

Thanks… I will check it out.