YesNoPopup.kl

Here’s an example of a program that shows a popup “Yes or No” in the teach pendant.

CODE    tag icon

PROGRAM YesNoPopup
%NOPAUSE=ERROR+COMMAND+TPENABLE
%NOBUSYLAMP
%NOLOCKGROUP
%ENVIRONMENT uif
%INCLUDE klevkmsk

CONST
— Text to display in popup
messageStr = ‘Yes or no?’ — Message
btn1Str = ‘No’ — First button
btn2Str = ‘Yes’ — Second button

— Type of data to set
DataType = ’35’ — 35 is Flag
DataIndex = ‘1’ — Flag number

— Name of HTM page
popupFileName = ‘MD:POPUP.HTM’

VAR
popupFile: FILE
term_char: INTEGER
status: INTEGER

BEGIN

— Create a HTM file with Text Zone and 2 buttons
OPEN FILE popupFile (‘RW’, popupFileName)
WRITE popupFile(‘<DIALOG posx=”150″ posy=”150″ width=”360″ height=”180″ bgcolor=”#3A3B3B” >’)
WRITE popupFile(‘<DLGTILE posx=”10″ posy=”10″ width=”340″ height=”75″>’)
WRITE popupFile(‘<object classid=”clsid:7106065C-0E45-11D3-81B6-0000E206D650″ id=”LABEL1″>’)
WRITE popupFile(‘ <param name=”Caption” value=”‘+messageStr+'”>’)
WRITE popupFile(‘<param name=”DataType” value=”100″>’)
WRITE popupFile(‘<param name=”FontSize” value=”28″>’)
WRITE popupFile(‘ <param name=”ForeColor” value=”16777215″>’)
WRITE popupFile(‘ <param name=”Border” value=”1″>’)
WRITE popupFile(‘</object>’)
WRITE popupFile(‘</DLGTILE>’)
WRITE popupFile(‘<DLGTILE posx=”20″ posy=”100″ width=”150″ height=”50″ type=”1″>’)
WRITE popupFile(‘<object classid=”clsid:7106066C-0E45-11D3-81B6-0000E206D650″ id=”TGBTN1″>’)
WRITE popupFile(‘<param name=”Caption” value=”‘+btn1Str+'”>’)
WRITE popupFile(‘ <param name=”DataType” value=”‘+DataType+'”>’)
WRITE popupFile(‘ <param name=”DataIndex” value=”‘+DataIndex+'”>’)
WRITE popupFile(‘ <param name=”SetValue” value=”-1″>’)
WRITE popupFile(‘ <param name=”FontSize” value=”28″>’)
WRITE popupFile(‘ <param name=”TrueColor” value=”1179878″>’)
WRITE popupFile(‘ <param name=”FalseColor” value=”1179878″>’)
WRITE popupFile(‘ <param name=”BackColor” value=”1179878″>’)
WRITE popupFile(‘ <param name=”Border” value=”2″>’)
WRITE popupFile(‘</object>’)
WRITE popupFile(‘</DLGTILE>’)
WRITE popupFile(‘<DLGTILE posx=”190″ posy=”100″ width=”150″ height=”50″ type=”1″>’)
WRITE popupFile(‘<object classid=”clsid:7106066C-0E45-11D3-81B6-0000E206D650″ id=”TGBTN1″>’)
WRITE popupFile(‘<param name=”Caption” value=”‘+btn2Str+'”>’)
WRITE popupFile(‘ <param name=”DataType” value=”‘+DataType+'”>’)
WRITE popupFile(‘ <param name=”DataIndex” value=”‘+DataIndex+'”>’)
WRITE popupFile(‘ <param name=”SetValue” value=”0″>’)
WRITE popupFile(‘ <param name=”FontSize” value=”28″>’)
WRITE popupFile(‘ <param name=”TrueColor” value=”170503″>’)
WRITE popupFile(‘ <param name=”FalseColor” value=”170503″>’)
WRITE popupFile(‘ <param name=”BackColor” value=”170503″>’)
WRITE popupFile(‘ <param name=”Border” value=”2″>’)
WRITE popupFile(‘</object>’)
WRITE popupFile(‘</DLGTILE>’)
WRITE popupFile(‘</DIALOG>’)
CLOSE FILE popupFile

— Display popup
DISCTRL_DIAG(popupFileName, kc_prev_key, term_char, status)

END YesNoPopup