The text of a manual · part 3 of 10
TT Advantage Programmer's Guide, pages 21 to 30
Pages 21 to 30 of 92
The original document is the PDF (976 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the HHP TT3100 and Welch Allyn TT3100
Page 21
Script Mode 3
Script Mode
The Script mode generates TT3100 Series-resident programs (scripts) that are activated from existing transaction software. Programmers creating new e-transaction systems, where the host controls all the interactive point of sale functions, should use the VB mode, while programmers upgrading legacy systems should use the Script mode.
What are Scripts? Scripts are compiled programs written in the Visual Basic environment using the TT Advantage Assistant. With the customized controls and commands resident in the TT Advantage Assistant add-in, programmers construct semi-conventional Visual Basic programs that are compiled to machine code by a TT Advantage associated DLL. Once compiled, developers use TT Advantage to download scripts into a TT3100 Series terminal attached to the COM port of a host. The TT3100 Series terminal holds the script in non-volatile memory. The speed and ease with which TT Advantage compiles and generates scripts allows developers to rapidly iterate and optimize TT3100 Series terminal applications.
Operating a Script To activate a script, power down then power up the TT3100 Series terminal by disconnecting and reconnecting the power cable. The firmware resident operating system then runs the script. The operating system and the script work semi-autonomously, communicating and receiving commands through the RS-232 and RS 485 ports of the TT3100 Series terminal. If a script contains a Sub Main(), the program starts execution with Sub Main; otherwise the program starts execution with padStart form.
3-1
Page 22
Screen Creation Process in Script Mode Screens on the TT3100 Series terminals are created control-by-control. Although it is not necessary to understand how interactive points of sale screens are created, knowledge about the process helps with troubleshooting. For example, when using the command “Tool.Display.Screen”, the following occurs in the listed order. Steps
Explanation
Clear Screen
Freezes the operation of interactive point of sale screen and deletes any objects on the screen
Process ScreenIniti-
Executes “ScreenInitilization” code in a form.
zation event on forms Draw screen
Places objects on the screen in the following order: 1. Signature areas 2. Magnetic Stripe Readers 3. TextBoxes 4. All other controls in reverse order of creation except for Command Buttons. 5. Command Buttons
Process After-
Executes “AfterScreenDraw” code in a form
ScreenDraw event on form Process timer routine if
Note: Use only one timer per form. The timer code only executes once part of code Wait for user input
Script stops to wait for user or host initiated event.
Note: The TT3100 Series terminals ignore all host commands and events while in steps 1 - 4.
Script Mode Software Components Script mode uses certain components in projects. The TT Advantage Assistant automatically adds those components to projects, so this information is presented for detailed understanding of TT Advantage Script mode. The following components are needed to operate TT Advantage in the Script mode:
Controls Name
Description
Additional Notes
VisualControls.ocx
Provides the SigArea and
DO NOT MODIFY
MSRArea controls
3-2
Page 23
Forms Name
Description
Additional Notes padStart.frm
TT Advantage defaults to
Modifiable component.
padStart on starting in
To add more forms to the project, see TT script mode unless
Advantage Forms on page 2-5.
submain() is present in mainScript. The first screen must always be padStart.
Modules Name
Description
Additional Notes mainScript.bas
Module contains:
In a script, all execution stops at the
TT Advantage internal function end of a routine. To continue execution routines past the end of a routine, add a
User routines A user modifiable command for com port selection and baud rate A user modifiable command for specifying command prefixes
GoToRoutine command at the end of the code. Script mode in TT Advantage does not have subroutines. A routine normally halts execution at the end of code. Communication port is selected with a line in MainScript.bas Command prefixes are also defined in MainScript.bas
References Name mxSptool.dll
Description
Additional Notes
Enables the downloading of
DO NOT MODIFY scripts and graphics to the TT3100 Series terminal. mxScript.dll
Enables the “autolist” in Visual
DO NOT MODIFY
Basic that helps displays the TT Advantage commands.
Downloading the Designed Script to the TT3100 Series Terminal Once the port number is entered, be certain the TT3100 Series terminal is attached to that port then press the “Put Script on Device” button (SeeThe TT Advantage Assistant on page 2-3.) The status area indicates the progress of the download and the TT3100 Series terminal display reads “Downloading.” The Status indicator signifies when the download is completed.
3-3
Page 24
Operational Host Communication with Scripts For the host to communicate with a Script on a TT3100 Series terminal, the mainScript.bas component of TT Advantage needs to be configured to use the port attached to the TT3100 Series terminal. The example shows where to change the port in the mainScript.bas code.
'-----------------------------------------' Start of required code for scripting ' *** THIS MUST BE THE FIRST DIM or DECLARE IN THIS MODULE!!!!! Public Tool As New clsTool '
^
'
You can change this Command Indicator name.
' Const PortNumber = 1 '
^
' where
Change this to the port number
' the POS device is connected
' Const BaudRate = 57600 '
^
' which the
Change this to the baud rate
'
POS device to be communicated
' ' End of required code for scripting '------------------------------------------
Host to Script Communication With the script on the TT3100 Series terminal, power up the terminal. Once it is started, the script functions independently, however, a host terminal is required to send and receive information. Communications between TT3100 Series terminals and hosts takes place using three commands, GoToLabel, SetTextVar, and GetTextVar. GoToLabel LabelName Executes the code starting at the label parameter. LabelName can be a routine name. SetTextVar VarName, StringValue Allows the host to set a string variable. For example, the host might set the variable “Data: to “12/01/1999”, to display a date on an attached TT3100 Series terminal. Note: All variables are case sensitive.
3-4
Page 25
GetTextVar (VarName) as String Allows the host to retrieve a string value from the TT3100 Series terminal for use in a host application. If script variable, “CredCardNum”, holds credit card data from an MSR read event, the operational host can request the variable information from the script by issuing a “GetTextVar” command to the script. Any text (string) variable in a script can be read or be written to by using SetTextVar or GetTextVar commands. These commands are located on the mxsptool.dll and used by the host machines. See the Sample Host application installed in the program directory/Samples directory.
Host-TT3100 Series Terminal Command Traffic GoToLabel SetTextVar Hand Held Products TT3100 Series Terminal
Host GetTextVar
On start-up, the TT3100 Series terminal runs the loaded script. The Script can be designed to operate independent from the host. Communication between the host and the TT3100 Series terminal for a transaction can be as simple as: 1. Start transaction (GoToLabel) 2. Get credit card information (GetTextVar) 3. Set and display the purchase price (SetTextVar) 4. Get Signature (GetTextVar).
Transaction Events Communication between the host and TT3100 Series terminals are simple in script mode. A light communications demand by TT3100 Series terminals of the host relieves the host for other tasks. Host
Get Credit Card
Show Ads
Take Survey
Wait for Signature
View Total and Request Signature
Store Transaction
Next Transaction
Pull Signature
Get Credit Authorization
Pull Credit Card Number
Start Push Greeting
Scan Merchandise
Push Total of Transaction
Initiate Transaction
Thank Customer
Wait for Next Transaction
TT3100 Series terminal
3-5
Page 26
Script Mode Controls TT Advantage scripts run in an environment unique to TT3100 Series terminals. The special demands of the TT3100 Series terminal environment requires a different set of controls than the Windows environment that is native for Visual Basic. Thus, while many of the controls function in TT Advantage as they do in Visual Basic, some do not.
Control Font Sizes Font characters displayed on TT3100 Series terminals come in six sizes. All characters in each font size have the same pixel dimensions. The TT Advantage font families are mapped onto the Courier New font families in the property boxes of TT Advantage controls. The following table shows the correspondence between the TT Advantage font sizes and Courier New font sizes. TT3100 Series Terminal Font Sizes in Pixels
Courier New Font Sizes in Points
6x8
10 to 11 pt
8x8
12 pt
8 x 12
13 to 16 pt
12 x 16
17 to 22 pt
16 x 16
23 to 26 pt
16 x 24
27 to 30 pt
COMMAND BUTTON TT Advantage command buttons operate the same as Visual Basic command buttons. Property
How property is used
Font-Size
Controls the size on the font displayed on the TT3100 Series terminal
Caption
The text displayed inside the button
Style
Property can be set to normal or hidden
USING THE CONTROL Use TT Advantage buttons in the same way as Visual Basic buttons.
3-6
Page 27
TT Advantage Tool Box The eight controls shown in the following diagram work in TT Advantage Script mode. The MSRControl and SigControl are specialized controls added to the toolbox by TT Advantage. Descriptions of the controls follow below:
Text Box
Label
Command Button
List Box
Timer Control
Shape
Line
Image SigControl MSR Control
Image The image sizes on a TT3100 Series terminal depend on the number of pixels they contain. The images display with the same number of pixels as the images on the host monitor. The size of images can be adjusted once placed on a TT Advantage form, but look better if adjusted in the creating application. Keep all the image edges within the boundaries of the screen forms for best results. Property
How property is used
Properties are same
Images can not be larger than 320 x 240 pixels as in Visual Basic
USING THE CONTROL All Script mode images must be 2-color, black-and-white bitmaps. Adjust the image colors with the picture property. Always use the picture property to add or change the picture; do NOT cut and paste pictures.
3-7
Page 28
Label Label controls in Script mode work like Visual Basic label controls, but DO NOT wrap. Multiple lines of text require multiple labels. Property
How property is used
Font-Size
Controls the size of the font on the pad
USING THE CONTROL After putting the code under the _Click event for a label, TT Advantage automatically creates a hidden button in front of the label and assigns the _Click event code to the hidden button.
Textbox Textbox controls in script mode work like a label. Also it works like a variable for script mode. Text property act likes name of the variable. Multiple lines of text require multiple labels. Property
How property is used
BorderStyle
“0 - None” displays no border. “1 - Fixed Single” displays a border. This is the default setting.
Font-Size
Controls the size of the font on the pad
Line The line control displays a line on the TT3100 Series terminal just as it appears on the developer host screen.
ListBox Script mode ListBoxes behave very differently than Visual Basic ListBoxes. Script mode ListBoxes operate as a “serial marquee.” A line of text appears one word at a time in the ListBox window. Create Script mode ListBoxes are one text line in height. Any other height produces unpredictable results. Property
How property is used
List
Place a line of text directly into this property so the box displays one line at a time.
Font-Size
Sets the size of the font on the pad
USING THE CONTROL Enter the lines of text for display in the List property. It is important to manually adjust the height of the ListBox until only one line of text displays.
3-8
Page 29
MSRControl Place the MSRControl anywhere on the form to give the MSR capabilities to TT3100 Series terminals. Though the control is visible on the developer screen, it is invisible on the TT3100 Series terminal. When a form containing a MSR control activates, the MSR also activates. Once activated, the MSR on the TT3100 Series terminal can accept information from credit card swipes. If a good swipe occurs, the code under the GoodSwipe event is called. EVENTS: GoodSwipe - fires after a good swipe. BadSwipe - fires after a bad swipe or after no swipe after timeout. Property
How property is used
There are no configurable control properties
USING THE CONTROL Draw this control on the developer screen. The MSRControl is hidden on the TT3100 Series terminal.
SigControl The SigControl creates a signature capture area on the TT3100 Series terminal. Put code under the “SignTimer” event to handle timeouts. Property
How property is used
BorderStyle
“0 - None” displays no border “1 - Fixed Single” displays a border. This is the default setting.
MaxSize
This property limits the number of points collected per signature. Once a user produces MaxSize pixels, the TT3100 Series terminal stops taking signature data.
Timeout
This property sets the number of seconds, after the user lifts the pen from the TT3100 Series terminal, until the “SignTimer” event fires.
USING THE CONTROL Use this control to draw a signature area. To save the signature into a string variable, use the Tool.Sig.SaveVar command. To clear a signature area, use the Tool.Sig.Clear command.
3-9
Page 30
Shape The shape tool can only be used to draw rectangles on the device, so be sure the control is set to the rectangle shape. After placing a Shape on a form, a dialog box appears asking if the object should be a “Box (Filled)” or a “Frame (Transparent).” Property
How property is used
FillStyle
“0 - Solid” fills the rectangular area with the current fill color. “1 - Transparent” draws a transparent rectangle.
Timer Place the Timer control anywhere on a form to give timer capabilities to a screen. The Timer control is visible on the developer screen but hidden on the TT3100 Series terminal. In Script mode the timer control does not act like a normal Visual Basic timer. It acts like a “countdown” timer. It waits for the number of seconds specified in the “internal” property, then executes the code under the timer event. The countdown occurs only once. Displaying a second screen after 15 seconds is an example of this timer’s usefulness. Property
How property is used
Interval
TT Advantage parameters for timer intervals are expressed in seconds. Parameters for timers in Visual Basic are expressed in milliseconds.
USING THE CONTROL Enter the countdown time in the Interval box of the timer’s properties. Add the control on the form, then enter the interval to be timed. Double-click the control; add script commands to be executed after the interval elapses. Since Script mode timers are countdown timers, enter the amount of time to be counted down in the Interval property. The timer waits for the number of seconds specified with the “Interval” property, then executes the code under the timer event. A great use for the timer is to display a sequence of screens.
Script Commands TT Advantage code lines use either statement or function syntax. An example of statement syntax is: Tool.Sound.Bell Alarm while an example of function syntax is: Tool.Sound.Bell(Alarm). Use function syntax with parentheses for sub commands such as a Script.IfTrue command.
Command Prefixes Every Script mode command begins with a prefix. The default prefix is Tool. The Script command prefix can be changed by substituting a new word in for Tool in the class declaration statement in the mainScript.bas file at the indicated location.
3-10