Tivoli Service Desk 6.0 Developer's Toolkit Script Language Reference
Sets the font for subsequent write operations in a standard window.
FUNCTION WinSetFont(VAL whdl: WINDOW, VAL fontName: STRING, VAL pointSize: INTEGER, VAL faceStyle: INTEGER): INTEGER;
Argument Name | Description |
whdl | The handle of the window where the font is to be set. This must be a standard window created by WinCreate. |
fontName | The face name of the font to be set as seen by the operating system. For a list of default system fonts, see the Notes for this statement. |
pointSize | The size of the font in points. Raster fonts point sizes available for the standard fonts are: 8, 10, 12, 14, 18, and 24. Not all fonts are available in all sizes. Outline fonts may be any point size. There are outline fonts available for all of the default fonts except system proportional and system monospaced. These fonts are available only in 10 point size. All of the default fonts, except system proportional, and system monospaced. These fonts are only available in 10 point size. |
faceStyle | A set of flags that may be combined to form a composite face style. Legal values are $FontPlain (default), $FontBold, $FontUnderScore, and $FontStrikeOut. Not all fonts support all face styles. These styles are added to an existing font. Some fonts are created with a face style such as bold or italic. In such cases, the style is always present. |
The following predefined constants provide access to the default system fonts:
KNOWLEDGEBASE WinFont; ROUTINES PROCEDURE FontExample;
PRIVATE CONSTANTS MENU_LIST IS {'File' ,'Exit', '', 'Font','Courier','Helvetica','System Proportional', 'System Monospaced','Times Roman','Symbol Set','' }: LIST OF STRING;
ROUTINES
EVENT MainEvent(REF fontName: STRING) IS ROUTINES PROCEDURE PaintFont(VAL whdl: WINDOW, VAL fontName: STRING) IS
ACTIONS WinSetFont(whdl,'System Proportional',10, $FontPlain); WinClear(whdl); WinSetFont(whdl,fontName,8,$FontPlain); WinWriteAt(whdl,1,1,fontName & ' 8 '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName,10,$FontPlain); WinWrite(whdl,fontName & ' 10 '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName,12,$FontPlain); WinWrite(whdl,fontName & ' 12 '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName,14,$FontPlain); WinWrite(whdl,fontName & ' 14 '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName,18,$FontPlain); WinWrite(whdl,fontName & ' 18 '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName,24,$FontPlain); WinWrite(whdl,fontName & ' 24 '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName,24,$FontBold); WinWrite(whdl,fontName & ' 24 Bold '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName,24,$FontItalic); WinWrite(whdl,fontName & ' 24 Italic '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName,24,$FontUnderscore); WinWrite(whdl,fontName & ' 24 Underscore '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName, 24, $FontStrikeOut); WinWrite(whdl,fontName & ' 24 StrikeOut '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,fontName, 48, $FontPlain); WinWrite(whdl,fontName & ' 48 '); WinWriteLn(whdl, 'abcdefghijllmenopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'); WinSetFont(whdl,'System Proportional',10, $FontPlain); END (* Paint Font *);
PROCEDURE ProcessMenu(VAL whdl: WINDOW, VAL selection: INTEGER) IS ACTIONS WHEN selection IS 101 THEN SendMessage(whdl,$MsgClose); ELSWHEN 201 THEN fontName := $Courier; PaintFont($Handle,fontName); ELSWHEN 202 THEN fontName := $Helvetica; PaintFont($Handle,fontName); ELSWHEN 203 THEN fontName := $SystemProportional; PaintFont($Handle,fontName); ELSWHEN 204 THEN fontName := $SystemMonospaced; PaintFont($Handle,fontName); ELSWHEN 205 THEN fontName := $TimesRoman; PaintFont($Handle,fontName); ELSWHEN 206 THEN fontName := $SymbolSet; PaintFont($Handle,fontName); END; END (* Process Menu *);
ACTIONS WHEN $Event IS $MsgCreate THEN WinSetMenuBar($Handle,MENU_LIST); ELSWHEN $MsgPaint THEN PaintFont($Handle,fontName); ELSWHEN $MsgMenu THEN ProcessMenu($Handle,$MenuSelection); END; END (* Main Event *);
PROCEDURE FontExample IS VARIABLES whdlMain: WINDOW; ACTIONS WinCreate($Desktop,whdlMain,MainEvent{$TimesRoman}, 0,0,60,20,'Font example', BitOr($WinBorder,$WinTitle, $WinResize,$WinMenu, $WinVScroll,$WinMinMax, $WinTaskList, $WinSysMenu,$WinAutoPos)); WinWait(whdlMain); END (* Font Example *);
Sets and displays icons on a toolbar.
FUNCTION WinSetIconBar(VAL buttonList : LIST of $ToolbarNodeRecord): INTEGER;
Argument Name | Description |
whdl | Handle of window with a $WinIconBar style. It may be a standard window or a scroll window. |
iconList | This can either be a list of strings or a list of $ToolbarItem records. For the list of strings, each string is the name of an image file to display on the icon bar. By using the alternate form ($ToolbarNodeRecord), it is possible to specify additional attributes such as the menu ID associated with a given toolbar button, as well as a "tool tip" for the toolbar button. |
A toolbar is a control similar to a menu bar. The toolbar appears below the title bar and the menu bar on a window. It consists of a row of icons that can be selected by clicking with mouse button one.
There is no keyboard interface to the toolbar or to the icons on it. Selecting an icon sends a menu message ($MsgMenu) to the window event handler. The first event parameter (integer) is the icon ID.
Note: The icons are labeled from 1 to 99 with the left-most icon having the ID of 1.
Icons must be in standard icon format. The files must be in the current directory. Otherwise, the full PATH of each file must be specified. Any file that is not found or is not in the correct format is skipped. IDs are actually assigned by the position in the icon list, not by the display position. Passing an unknown list causes the toolbar to be cleared and hidden.
Note: Adding a toolbar to a window that does not have one sends a $MsgSize to the window with the new size of the user area.
Use the list of string form in the following way:
WHEN $Event IS &MsgCreate THEN WinSetIconBar($Handle, {SEARCH,CO','PRINT.ICO'}: LIST OF STRING); END;
Use the list of $ToolbarItem form in the following way:
WHEN $Event IS $MsgCreate THEN theList[1].ImageFile:='SEARCH.BMP'; theList[1].ItemID:=204; theList[1].ToolTip:='Search for Text';
theList[2].ImageFile:='PRINT.BMP'; theList[2].ItemID:=106; theList[2].ToolTipText:='Print File';
theList[3].ImageFile:='SAVE.BMP'; theList[3].ItemID:=103; theList[3].ToolTipText:='Save File';
WinSetIconBar($Handle,theList);
END;
Sets the selections on a window menu bar.
FUNCTION WinSetMenuBar(VAL whdl: WINDOW, VAL menuList: LIST OF STRING): INTEGER;
Argument Name | Description |
whdl | The handle of the window on which to perform the operation. |
menuList | A list of strings specifying a menu to display on the window menu bar. See the Notes for this statement for information on list format. |
WinSetMenuBar can be used to set the menu bar on a window that was created with the $WinMenu style.
The list of strings passed to WinSetMenuBar specifies the entire menu structure. Both the horizontal, main menu items and the vertical, subsidiary items are specified. Menu items are encoded in the list in a top-to-bottom, left-to-right format. Empty strings serve as separators. For example, if the left-most menu item is File and File items include New, Save, Save As, and Exit, the menu list looks like this:
{'File','New','Save','Save ~As','Exit',''}: LIST OF STRING;
The second column of items comes next.
A tilde (~) can be used to make a letter the selector for a menu item. The switches in
the following table can be placed at the beginning of a menu list item to achieve the
results shown for each switch.
Switch | Result |
/C | The menu item is initially checked. |
/D | The menu item is initially disabled. |
/S | The menu item is static and cannot be selected. |
/L | The menu item is not displayed. A line separator appears in its place. |
/H | The menu is held open when the item is selected. |
// | A slash (/) is displayed. No more switches are processed. |
Adding a menu bar to a window that does not have one sends a $MsgSize to the window with the new size of the user area.
KNOWLEDGEBASE WinMenu; TYPES MainWinRec IS RECORD width: INTEGER; height: INTEGER; fontName: STRING; mousePointer: STRING; statusBar: STRING; END;
CONSTANTS MENU_LIST IS {'File' , 'E~xit', '', (* 101 *) 'Menu', '~Enable', (* 201 *) '~Disable', (* 202 *) '/L ', (* Put separator line in menu *) '/C/D~Check', (* 204 start check and disabled *) '', (* Mark end of menu sub menu *) 'Help', 'About', (* 301 *) '' (* Mark end of help submenu *) }: LIST OF STRING;
ROUTINES PROCEDURE MenuExample;
PRIVATE ROUTINES
EVENT MainEvent(REF mainWinData: MainWinRec) IS ACTIONS WHEN $Event IS $MsgCreate THEN WinSetMenuBar($Handle,MENU_LIST); ELSWHEN $MsgPaint THEN WinClear($Handle); ELSWHEN $MsgMenu THEN WHEN $MenuSelection IS 101 THEN SendMessage($Handle,$MsgClose); ELSWHEN 201 THEN WinMenuEnableItem($Handle,204,TRUE); ELSWHEN 202 THEN WinMenuEnableItem($Handle,204,FALSE); ELSWHEN 204 THEN IF WinMenuItemIsChecked($Handle,204) THEN WinMenuCheckItem($Handle,204,FALSE); ELSE WinMenuCheckItem($Handle,204,TRUE); END; ELSWHEN 301 THEN WinMessageBox($Handle,'About',$MBOK,'Menu example'); END; END; END (* Main Event *);
PROCEDURE MenuExample IS VARIABLES whdlMain: WINDOW; ACTIONS WinCreate($Desktop,whdlMain,MainEvent,0,0,60,20, 'Menu example', BitOr($WinBorder,$WinTitle, $WinMenu,$WinMinMax, $WinTaskList,$WinAutoPos, $WinSysMenu)); WinWait(whdlMain); END (* Menu Example *);
Sets the pop-up menu for a window replacing any existing pop-up menu. The pop-up menu automatically appears with the correct mouse action for the platform. Selections from the pop-up menu are reported by $MsgMenu.
FUNCTION WinSetPopupMenu ( VAL whdl: WINDOW, VAL menuList: LIST OF STRING, ) : INTEGER;
Argument Name | Description |
whdl | The handle of the dialog box form or window whose title text is to be changed |
menuList | List of popup menu items for the window |
The list of strings passed to WinSetPopupMenu specifies the entire menu structure. Both the horizontal, main menu items and the vertical, subsidiary items are specified. Menu items are encoded in the list in a top-to-bottom, left-to-right format. Empty strings serve as separators. For example, if the left-most menu item is File and File items include New, Save, Save As, and Exit, the menu list looks like this:
{'File','New','Save','Save ~As','Exit',''}: LIST OF STRING;
The second column of items comes next.
A tilde (~) can be used to make a letter the selector for a menu item. The switches in
the following table can be placed at the beginning of a menu list option to achieve the
results shown for each switch.
Switch | Result |
/C | The menu item is initially checked |
/D | The menu item is initially disabled |
/S | The menu item is static and cannot be selected |
/L | The menu item is not displayed. A line separator appears in its place |
/H | The menu is held open when the item is selected |
// | A slash (/) is displayed. No more switches are processed |
Adding a menu bar to a window that does not have one sends a $MsgSize to the window with the new size of the user area.
When using WinLoadPopupMenu, the menu automatically appears upon the correct mouse action for the platform. When the user selects a menu item, a $MsgMenu is sent to the window. This differs from the old function WinPopup. In WinPopup, the user would have to catch the correct mouse action and call WinPopup to display the pop-up menu. WinPopup would return the id of the menu item selected.
KNOWLEDGEBASE popup;
ROUTINES
PROCEDURE Main;
(* ***** PRIVATE ***** *)
PRIVATE
VARIABLES (*Global Variable to hold the Window handle of the window *) mainWindow : WINDOW;
ROUTINES
PROCEDURE Main IS
VARIABLES MAIN_MENU {'File', '/CNew', '/DExit' } : LIST OF STRING;
ACTIONS WinCreate($Desktop, mainWindow, $NullHandler, 10, 10, 80, 25, 'WinSetPopupMenu Test', $WinDefaultStyle); (* Set the popup menu. The 'New' menu item is initially checked and *) (* the 'Exit' menu item is initially diabled *) WinSetPopupMenu(mainWindow, MAIN_MENU); WinWait(mainWindow);
END;
WinLoadPopupMenu
Sets the position and tab size of a scroll bar.
FUNCTION WinSetScrollBar(VAL whdl: WINDOW, VAL scrollBarID, windowSize, dataSize,windowLoc: INTEGER): INTEGER;
Argument Name | Description |
whdl | The handle of the window on which the operation is to be performed. |
scrollBarID | Label of scroll bar to be set. Must be either $WinVScroll (vertical) or $WinHScroll (horizontal). If the addressed scrollbar does not exist, no action is taken. No error is reported. |
windowSize | Size of window in data units. The units are arbitrary, relating only to the dataSize and windowLoc parameters. These parameters must be expressed in the same units. |
dataSize | Size of data, expressed in the same units used to specify the window size. |
windowLoc | Location of top or left side of window, expressed in the same units as previous parameters. |
KNOWLEDGEBASE FileView; CONSTANTS MENU_OPEN IS 101; MENU_EXIT IS 102; MENU_LIST IS {'~File','~Open','e~xit',''}: LIST OF STRING; TYPES EditorData IS RECORD fileName: STRING; yLen: INTEGER; lineCount: INTEGER; pageTop: INTEGER; statusLine: STRING; lines: LIST OF STRING;
END;
ROUTINES PROCEDURE FileView;
PRIVATE ROUTINES
EVENT EditorEvent(REF data: EditorData) IS VARIABLES loc: INTEGER; ROUTINES PROCEDURE ProcessMainMenu(VALUE selection: INTEGER) IS VARIABLES fileName: STRING; editFile: FILE; result: INTEGER; ACTIONS WHEN selection IS MENU_OPEN THEN WinFileDialog($Handle, fileName, '*.KB', 5, 5, 'Select file to edit', 0); result := FOpen(editFile, fileName, $Read); IF result <= 0 THEN WinMessageBox($Handle, 'Error', $MBOK + $MBIconError, 'Can not open file ' & fileName); Exit; END; data.lineCount := FReadText(editFile, data.lines); FClose(editFile); data.pageTop := 0; data.statusLine := ' File: ' & fileName; PostMessage($Handle, $MsgPaint); PostMessage($Handle, $MsgPaintStatus); ELSWHEN MENU_EXIT THEN SendMessage($Handle, $MsgClose); END;
END (* Process Main Menu *);
PROCEDURE ProcessChar(VALUE character: INTEGER) IS ACTIONS WHEN character IS $KeyDownArrow THEN IF data.pageTop + data.yLen < data.lineCount THEN data.pageTop := data.pageTop + 1; PostMessage($Handle, $MsgPaint); END; ELSWHEN $KeyUPArrow THEN IF data.pageTop > 0 THEN data.pageTop := data.pageTop - 1; PostMessage($Handle, $MsgPaint); END; ELSWHEN $KeyPageDown THEN IF data.pageTop + data.yLen < data.lineCount THEN data.pageTop := data.pageTop + data.yLen; PostMessage($Handle, $MsgPaint); END; ELSWHEN $KeyPageUp THEN IF data.pageTop > 0 THEN data.pageTop := data.pageTop - data.yLen; IF data.pageTop < 0 THEN data.pageTop := 0; END; PostMessage($Handle, $MsgPaint); END; ELSWHEN $KeyControlPageDown THEN IF data.pageTop + data.yLen < data.lineCount THEN data.pageTop := data.lineCount - data.yLen; PostMessage($Handle, $MsgPaint); END; ELSWHEN $KeyControlPageUp THEN IF data.pageTop > 0 THEN data.pageTop := 0; PostMessage($Handle, $MsgPaint); END; END; END (* ProcessChar *);
ACTIONS WHEN $Event IS $MsgCreate THEN WinSetMenuBar($Handle, MENU_LIST); data.lineCount := 0; data.pageTop := 1; data.statusLine := 'File:'; ELSWHEN $MsgSize THEN (* Size Message *) data.yLen := $EventParm(2, INTEGER); WinSetScrollBar($Handle,$WinVScroll,data.lineCount, data.yLen,data.pageTop); ELSWHEN $MsgPaint THEN WinSetScrollBar($Handle,$WinVScroll,data.lineCount, data.yLen,data.pageTop); FOR loc := 1 to data.yLen + 1 DO IF loc + data.pageTop> data.lineCount THEN ExitLoop; END; WinGoToXY($Handle, 1, loc); WinClearEOL($Handle); WinWriteAt($Handle,1,loc,data.lines[ data.pageTop +loc ]); END; WinGoToXY($Handle, 1, loc); WinClearEOW($Handle); ELSWHEN $MsgMenu THEN (* Menu Message *) ProcessMainMenu($MenuSelection); ELSWHEN $MsgChar THEN ProcessChar($EventParm(1, INTEGER)); ELSWHEN $MsgScroll THEN (* Scroll bar *) IF $EventParm(1, INTEGER) =$WinVScroll THEN data.pageTop := $EventParm(2, INTEGER); PostMessage($Handle, $MsgPaint); END; ELSWHEN $MsgPaintStatus THEN (* Status Bar *) WinClear($Handle); WinWrite($Handle,data.statusLine); END; END (* Editor Event *);
PROCEDURE FileView IS VARIABLES whdl: WINDOW; ACTIONS WinCreate($Desktop,whdl,EditorEvent,0,0,0,0, 'KML File viewer', BitOr($WinBorder,$WinTitle, $WinResize,$WinSysMenu, $WinMenu,$WinVSCroll, $WinStatus,$WinAutoPos, $WinAutoSize,$WinTaskList)); WinWait(whdl); END (* File View *);
WinCreate
Sets the text in the title bar of a dialog box form or window.
FUNCTION WinSetTitle(VAL whdl: WINDOW, VAL newTitle: STRING): INTEGER;
Argument Name | Description |
whdl | The handle of the dialog box or window whose title text is to be changed. |
newTitle | The new title for the dialog box form or window. |
This function is also implemented as a message that can be passed to a dialog box form or window ($MsgSetTitle).
KNOWLEDGEBASE title;
ROUTINES PROCEDURE Main;
PRIVATE
ROUTINES
PROCEDURE Main IS VARIABLES Handle : WINDOW; ACTIONS WinCreate($Desktop, Handle, $NullHandler, 1, 1, 80, 25, 'If you see this it did not work', $WinDefaultStyle); WinSetTitle(Handle, 'It works!'); WinWait(Handle); END;
Turns the wait pointer (hourglass) on or off. The wait pointer effects all windows in the application.
WinSetWaitPointer ( VAL state : BOOLEAN ) : INTEGER;
Argument Name | Description |
state | 'True' displays the wait pointer, while 'False' restores the previous pointer. |
WinSetWaitPointer turns the wait pointer on or off depending on the state supplied. It is a used to give the visual clue that the application is busy or still processing.
KNOWLEDGEBASE wait;
ROUTINES
PROCEDURE Main;
(* ***** PRIVATE ***** *)
PRIVATE
VARIABLES (* Global Variable to hold the Window handle of the window *) mainWindow : WINDOW;
ROUTINES
PROCEDURE Main IS
VARIABLES
ACTIONS WinCreateScrollWindow($Desktop, mainWindow, $NullHandler, 10, 10, 80, 25, 'Test Window', $SystemMonoSpaced, 10, $WinDefaultStyle); WinSetWaitPointer(TRUE); (* Set the pointer to be the wait pointer before doing intensive processing *) (* and change it back afterwards *) WinSetWaitPointer(FALSE); WinWait(mainWindow);
END;
Shows or hides a dialog box or a window.
FUNCTION WinShowWindow(VAL whdl: WINDOW, VAL state: BOOLEAN): INTEGER;
Argument Name | Description |
whdl | The handle of the dialog box form or window whose visibility state is to be changed |
state | Set to TRUE if the window is to be "shown", set to FALSE if it is to be "hidden" |
Also used as a message to a dialog box or window ($MsgShow).
KNOWLEDGEBASE title;
ROUTINES PROCEDURE Main;
PRIVATE
ROUTINES
PROCEDURE Main IS VARIABLES Handle : WINDOW; ACTIONS WinCreate($Desktop, Handle, $NullHandler, 1, 1, 80, 25, 'If you see this it did not work', $WinDefaultStyle); WinShowWindow(Handle, FALSE); SysDelay(1000); WinShowWindow(HANDLE, TRUE); WinWait(Handle); END;
Pauses execution while a window exists.
FUNCTION WinWait(VAL whdl: WINDOW): INTEGER;
Do not use WinWait when you process a $MsgDDEInitiate message. $MsgDDEInitiate broadcasts a message to the applications and locks the message queue until a response is returned. Meanwhile, the WinWait statement initiates an event handler that also waits for a reply from the message queue. WinWait prevents the other applications from sending messages to the message queue. This results in a deadlock, and effectively locks the user interface.
Argument Name | Description |
whdl | The handle of the window on which the operation is to be performed |
WinWait is typically used in the application's main procedure to wait until the main window is no longer alive.
VARIABLES whdl: WINDOW; ACTIONS WinCreateScrollWindow($Desktop,whdl,$NullHandler,0,0,0,0, 'Window Title','',0, BitOr($WinBorder,$WinTitle, $WinResize,$WinSysMenu, $WinAutoPos,$WinAutoSize, $WinTaskList)); WinWait(whdl);
Queries the width of a window.
FUNCTION WinWidth(VAL whdl: WINDOW): INTEGER;
Argument Name | Description |
whdl | The handle of the window on which the operation is to be performed |
WinWidth returns the current width of the client area of the indicated window, expressed in character cells.
VARIABLES width: INTEGER; ACTIONS width := WinWidth($Handle);
Writes a string in a window at the current position.
FUNCTION WinWrite(VAL whdl: WINDOW, VAL outputText: LIST OF STRING): INTEGER;
Argument Name | Description |
whdl | The handle of the window to write in. The handle may reference a standard (generic) window or a scroll window. |
outputText | A list of strings to be displayed. A single string is also valid. This command is performed on each item in the list. |
WinWrite can be used to write information into a generic or scroll window. It cannot be used to write information to a dialog box.
Finding the Current Drawing Location
TSD Script maintains a current drawing location for each generic and scroll window. The text written by WinWrite appears at that location and the x-position of the drawing location is advanced after the write operation. The current position can be found by calling the WinX and WinY functions.
Using Format Specifiers
Format specifiers are actually bit masks in which different bits control different parts of the format. WinWrite processes a list of strings which allow you to control the formatting for display in WinWrite and other statements.
In general, any expression can be followed by two format specifiers:
These format specifiers are separated from the expression and from each other by colons. For example:
VARIABLES s: STRING; i: INTEGER; r: REAL; b: BOOLEAN; (* true false *) d: DATE; (* right, empty pad, usa *) t: TIME; (* right, empty pad, 24 hour military *) ACTIONS s := 'First Bank'; i := 951; r := 14567.89; d := {2,15,1956}: DATE; t := {11,45,0}: TIME; WinWrite($Handle,s:20); -- outputs 'First Bank' WinWrite($Handle,i:5); -- outputs '951 ' WinWrite($Handle,r:9:2);-- outputs '14567.89 ';
WinWrite($Handle,d:10:$FmtDateMonthDayYear); -- outputs '2/11/1956' WinWrite($Handle,d:10:BitOr($FmtDateMonthDayYear, $FmtDateTruncateCentury); -- outputs '2/11/56 ' WinWrite($Handle,t:7:$FmtTimeAMPM); -- outputs '11:45 AM';
Note: The various format flags are described in Data Type Format Flags.
Format Specifiers for Real Numbers
The format specifier for real numbers can also encode the number of digits to the right of the decimal point to be displayed. For example,
WinWrite($Handle, r :10 : BitOr(2, $FmtLeftJustify));
left justifies output and displays two digits to the right of the decimal. By default, real numbers display six digits to the right of the decimal point.
Default Formats for Data Types
There are default formats for the various data types. These defaults may vary by country, because data type defaults (including the US ones) are based on the International control panel settings.
The following table shows the United States default formats for data types.
Data Type | US Default Format |
string | $FmtRightJustify |
integer | $FmtRightJustify+$FmtIntUngrouped+$FmtBlankPad+$FmtIntSignNegOnly+$FmtIntDecimal |
real | $FmtRightJustify+$FmtRealUngrouped+$FmtBlankPad+$FmtRealSignNegOnly+
$FmtRealDecimalDot |
Boolean | $FmtRightJustify+$FmtBoolTrueFalse |
date | $FmtRightJustify+$FmtDateMonthDayYear+$FmtBlankPad+$FmtDateSlashSeparators+
$FmtDateNumericMonth+$FmtDateFullYear |
time | $FmtRightJustify+$FmtTimeWithSeconds+$FmtBlankPad+$FmtTimeMilitary |
Default formats can be changed using the StringFormat, IntegerFormat, RealFormat, BooleanFormat, DateFormat, and TimeFormat functions.
KNOWLEDGEBASE Clip;
CONSTANTS MENU_REFRESH IS 101; MENU_EXIT IS 102;
ROUTINES PROCEDURE ClipView;
PRIVATE
CONSTANTS MENU_LIST IS {'~File','~Refresh','E~xit',''}: LIST OF STRING; ROUTINES EVENT ClipboardEvent(REF clipBoard: STRING) IS ACTIONS WHEN $Event IS $MsgCreate THEN WinSetMenuBar($Handle,MENU_LIST); SysGetClipboard(clipBoard); WinWrite($Handle,clipBoard); ELSWHEN $MsgMenu THEN WHEN $MenuSelection IS MENU_REFRESH THEN SysGetClipboard(clipBoard); WinClear($Handle); WinWrite($Handle,clipBoard); ELSWHEN MENU_EXIT THEN SendMessage($Handle,$MsgClose); END; END; END (* Clipboard Event *); PROCEDURE ClipView IS VARIABLES whdl: WINDOW; ACTIONS WinCreateScrollWindow($Desktop,whdl,ClipboardEvent{''}, 0,0,0,0,'KML Clipboard viewer', '',10, BitOr($WinBorder,$WinTitle, $WinResize, $WinSysMenu, $WinMenu,$WinAutoPos, $WinAutoSize,$WinVScroll, $WinHScroll,$WinTaskList)); WinWait(whdl); END (* Clip View *);
For more information, see Data Type Format Flags.
Writes a string in a window at the specified location.
FUNCTION WinWriteAt(VAL whdl: WINDOW, VAL xLoc, yLoc: INTEGER, VAL outputText: LIST OF STRING): INTEGER;
Argument Name | Description |
whdl | The handle of the window in which to write. The handle may reference a standard (generic) window or a scroll window. |
xLoc | The X location of the start of the string. |
yLoc | The Y location of the start of the string. |
outputText | A list of strings to be displayed. A single string is also valid. This command processes each item in the list. |
WinWriteAt is used to write information starting at a specified location within a generic or scroll window. At the end of its processing, WinWriteAt leaves the current drawing location (the location of the cursor) one character position to the right of the last character written.
WHEN $Event IS $MsgPaint THEN WinWriteAt($Handle,1,1,context.fileName); END;
Writes a string in a window and advances the position pointer to the start of the next line.
FUNCTION WinWriteLN(VAL whdl: WINDOW, VAL outputText: LIST OF STRING): INTEGER;
Argument Name | Description |
whdl | The handle of the window to write in. The handle may reference a standard (generic) window or a scroll window. |
outputText | A list of strings to be displayed. A single string is also valid. This command processes each item in the list. |
WinWriteLN uses an implicit FOR loop: It writes the entire list of strings sequentially.
WinWriteLN is identical to WinWrite except that it advances the window cursor to the start of the next line.
KNOWLEDGEBASE Scroll;
CONSTANTS MENU_OPEN IS 101; MENU_EXIT IS 102; MENU_LIST IS {'~File','~Open','E~xit',''}: LIST OF STRING;
TYPES EditorData IS RECORD statusLine: STRING; lines: LIST OF STRING; END;
ROUTINES PROCEDURE FileView; PRIVATE ROUTINES
EVENT EditorEvent(REF editorData: EditorData) IS ROUTINES PROCEDURE ProcessMainMenu(VALUE selection: INTEGER) IS VARIABLES fileName: STRING; editFile: FILE; result: INTEGER; ACTIONS WHEN selection IS MENU_OPEN THEN WinFileDialog($Handle,fileName,'*.KB',5,5, 'Select file to edit',0); IF FOpen(editFile,fileName,$Read) > 0 THEN FReadText(editFile,editorData.lines); FClose(editFile); editorData.statusLine := ' File: ' & fileName; WinClear($Handle); WinWriteLn($Handle,editorData.lines); PostMessage($Handle,$MsgPaintStatus); ELSWHEN MENU_EXIT THEN SendMessage($Handle,$MsgClose); END; END; END (* Process Main Menu *);
ACTIONS WHEN $Event IS $MsgCreate THEN WinSetMenuBar($Handle, menuList); editorData.statusLine := 'File:'; ELSWHEN $MsgMenu THEN ProcessMainMenu($MenuSelection); ELSWHEN $MsgPaintStatus THEN (* Status Bar *) WinClear($Handle); WinWrite($Handle,editorData.statusLine); END; END (* Editor Event *);
PROCEDURE FileView IS VARIABLES whdl: WINDOW; ACTIONS WinCreateScrollWindow($Desktop,whdl,EditorEvent,0,0,0,0, 'KML File viewer',$SystemMonospaced, 10, BitOr($WinBorder,$WinTitle, $WinResize, $WinSysMenu,$WinMenu,$WinStatus, $WinAutoPos,$WinAutoSize, $WinVScroll,$WinHScroll, $WinTaskList)); WinWait(whdl); END (* File View *);
Returns the x-coordinate of the current drawing position.
FUNCTION WinX(VAL whdl: WINDOW): INTEGER;
Argument Name | Description |
whdl | The handle of the window on which the operation is to be performed |
WinX differs from WinGetXPos because it returns a character position within a window while WinGetXPos queries the top left corner of a window or dialog box.
WHEN $Event IS $MsgChar THEN WHEN $EventParm(1,INTEGER) IS $KeyUpArrow THEN WinGoToXY(Handle,$WinX($Handle),$WinY($Handle)-1); ELSWHEN $KeyRightArrow THEN WinGoToXY(Handle,$WinX($Handle)+1,$WinY($Handle)); END; END;
WinY
Returns the y-coordinate of the current drawing position.
FUNCTION WinY(VAL whdl: WINDOW): INTEGER;
Argument Name | Description |
whdl | The handle of the window on which the operation is to be performed |
WinY differs from WinGetYPos because it returns a character position within a window while WinGetYPos queries the top left corner of a window or dialog box.
WHEN $Event IS $MsgChar THEN WHEN $EventParm(1,INTEGER) IS $KeyUpArrow THEN WinGoToXY(Handle,$WinX($Handle),$WinY($Handle)-1); ELSWHEN $KeyRightArrow THEN WinGoToXY(Handle,$WinX($Handle)+1,$WinY($Handle)); END; END;
WinX
Tivoli Service Desk 6.0 Developer's Toolkit Script Language Reference