Wednesday, November 9, 2011

String Formatting

There are several places in the QwikTouchPro Editor where you can provide an optional string format.

We use string formatting when we are retuning a value from a Datasource or another control and we want to change the way it is displayed.

String formatting is how we convert 7.2 to $7.20, or “11/8/2011” to “November 8, 2011” for e.g.

As of this writing, you can apply a String Format in the following places –
  • Data Binding (Data Tab, Data Binding Group)
  • Source Control Builder (Anywhere you see this icon -)
  • DataGrid Columns (Data Controls Tab, Datagrid Group, Configure)

One of the more common uses for string formatting will probably be to format prices from Keystrokes as dollar amounts.  When you create a Customer Display or a collection of inventory items they are displayed the way they come out of the Keystroke Data port or Export.txt files.
This often means 0, 1, 1.5, or 17.32, when what we really want to see is $0.00, $1.00, $1.50, or $17.32.

To accomplish this we can apply a String Format to the price to convert it from a number to a dollar amount (currency).

The string format for currency is –
                {0:c}

Here is an example of a currency string format being applied to the Amount Due field from the Keystroke Dataport –


Here is a great link to some string formats –
(Scroll down to where the string format examples begin)

And here is a link of some common examples –



You can also use string formatting to specify the image for a Keystroke Inventory Item.
We know that the Images in Keystrokes are named I[StockNumber].jpg.

If we know the Stock Number of an item we can build the path to its image with string formatting.

{0} is a token that represents the string we are formatting (the Stock number of the selected item for example).

To get the full path of the image we would format the string as –
C:\Keystrok\Tutor\PHOTOS\I{0}.jpg
At runtime, QwikTouchPro will replace the {0} with the stock number of the selected item.

No comments:

Post a Comment