8/13/2018 7:48 PM | |
Posts: 55 Rating: (1) |
I'll try again but I'm sure it didn't like it. I'll keep you updated. I'm struggling on certain things but I'm learning fast, forums have been a godsend |
8/14/2018 12:23 AM | |
Joined: 7/7/2010 Last visit: 4/26/2024 Posts: 14637 Rating: (2349)
|
The real trick is the use of the AT slice option to make your life easier. I have an example that may help.
With this UDT (which has your ESC/P setup inserted):
Which is used in this FB:
|
science guy |
|
This contribution was helpful to2 thankful Users |
8/14/2018 4:40 PM | |
Joined: 7/7/2010 Last visit: 4/26/2024 Posts: 14637 Rating: (2349)
|
Maybe this will help explain the AT slice that makes it all easy to do: https://support.industry.siemens.com/cs/document/57132240 To think about your problem (once you posted the ESC/P setup requirements), it is 3 things you need to do.
So, build up a buffer inside an FB to contain all this mostly static data, enough room for the largest printable text, and 4 more bytes for FF & CR/LF to be appended to the end of the output stream. To ensure the ESC/P setup never gets overwritten, you can put the ESC/P setup in a UDT. The magic is in this:
What that does is sets aside 256 bytes of memory, available as [local tag named] #output. What is also does is tells the compiler, hey, we also want to access that same 256 bytes of memory as follows: give me a local tag named #_output, and within that tag, we will have a data structure where the first 56 bytes are a tag named #_output."ESC/P_Setup" of that special UDT which has all the "default" values already assigned, which means the 1st 56 bytes of #output are also already configured with that setup data which does not change. Then fill up the remaining 200 bytes with #_output.Text[0..199] as Byte (which can accept characters without conversion). All that is left is to fill up #_output.Text from 0 to the length of the INPUT printable string with that string (and append the FF-CR/LF). Using a simple FOR loop works fine [to copy the input string to #_output.Text...] because optimizing is not necessary for controlling just a single printer. By choosing the AT and struct data, it is easy to loop and copy data and everything simply goes to the right place within #output (the actual output array of 256 bytes). Oh, after everything is copied over, add the FF / CR / LF characters and all done.
|
Last edited by: huggy_d1 at: 8/14/2018 4:46:15 PMscience guy |
|
This contribution was helpful to1 thankful Users |
8/14/2018 7:43 PM | |
Posts: 55 Rating: (1) |
Again thanks so much for your input, I've just got home so about to dive into the 'AT keyword' material and try to make some sense of it all. |
Follow us on