22.5.3.5 Strset (User Defined Function)

Completed Script

// Append strings "Product Name:" and "Price".
_strset(databuf0, "") // Initialize data buffer 0.
_strset(databuf0, "Product Name:") // Store text to data buffer 0.
_bin2decasc(databuf1, [w:[#MEMLINK]0500]) // Convert value to text and store in data buffer 1.
_strcat(databuf0, databuf1) // Append data buffer 1 to end of data buffer 0.
_strset(databuf1, "") // Initilalize data buffer 1.
_strset(databuf1, "Price") // Store text to data buffer 1.
_strcat(databuf0, databuf1) // Append data buffer 1 to end of data buffer 0.
// Initilialize temporary address.
[t:0001]=0
[t:0002]=0
// Text strings stored in internal device in consecutive word units. Store again in byte units (30 characters).
loop()
{
  [w:[#MEMLINK]2000]#[t:0002]=[w:[#MEMLINK]1000]#[t:0001]>>8 // Move top byte to bottom byte and store.
[w:[#MEMLINK]2001]#[t:0002]=[w:[#MEMLINK]1000]#[t:0001]&0xFF // Delete top byte and store in next address.
[t:0001]=[t:0001]+1 // Address offset + 1.
[t:0002]=[t:0002]+2 // Address offset +2.
  if([t:0001]==15) // Store 2 bytes in 2 words. Repeat 15 times.
{
break
}
  endif
}
endloop
_ldcopy(databuf2, [w:[#MEMLINK]2000], 30) // Store internal device 2000 to 2029 to data buffer as text string.
// Add text "Product Name:"
_strset(databuf1, "") // Initialize data buffer 1.
_strset(databuf1, "Product Name:") // Store text in data buffer 1.
_strcat(databuf1, databuf2) // Append data buffer 2 to end of data buffer 1.
// Add price to product name.
_strcat(databuf1, databuf0) // Append value in data buffer 0 to data buffer 1.

Function Summary

  1. Append the text "Price:" and "Yen" to the price data in internal device 0500.

  2. Change the data format in order to send print data to the printer. Divide into byte units the string data (Product Name) stored sequentially from internal memory address 1000, and store as string data into the bottom bytes of internal device addresses 2000 to 2030.
    Use the function _ldcopy to copy the bottom byte of consecutive word addresses to databuf2.

    • The _ldcopy function takes data stored as Words, and stores only the bottom bytes in the buffer, while the data in the top bytes is ignored.

  3. Add the strings "Product Name:" and "Price" to databuf2.