Click here to Skip to main content
15,038,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am somewhat beginner in coding. My question seem easy, but...
I wrote an application to send some special text to a printer (a Zebra printer, the text is a ZPL code).

What I have tried:

I definded a string in the app combined with some variables.
My question is: there is the string with a variable:

"^XA~JSB^MMC^MNN^MTT^PW365^LL690^POI^PMN^LH0,0^PR2,2^JUS^LRN^CI0^XZ"
"^XA"
"^FB330,1,,C^FO0,493^A0n,31,31^F8^FD" + LATK + "^FS"
"^XZ"
"^XA"
"^IDE:*.*"
"^IDR:*.*"
"^XZ"


I would like to put this string in a separate text file.
In the app I would like to read the text file, assign a value to the LATK variable from the text file, and then send it to the printer. The question is, how could I evaluate the string with the variables to get this

^XA~JSB^MMC^MNN^MTT^PW365^LL690^POI^PMN^LH0,0^PR2,2^JUS^LRN^CI0^XZ
^XA
^FB330,1,,C^FO0,493^A0n,31,31^F8^FD1158037-AB^FS
^XZ
^XA
^IDE:*.*
^IDR:*.*
^XZ


thanks.
Appreciate any aswers.
Posted
Updated 13-Oct-20 10:32am

1 solution

The way I'd do it is to add format markers:
C#
string putThisToFile = "fixed text:{0}:more fixed text";
string LATK = "variable text";
string result = string.Format(putThisToFile, LATK);

The result you get is:
fixed text:variable text:more fixed text


Make sense?
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900