Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 12 of 18

Qlarity-Based Terminal Programmer's Reference Manual: Chapter 4 Qlarity API Function Reference, pages 74 to 82

Pages 74 to 82 of 134, from Qlarity-Based Terminal Programmer's Reference Manual

The original document is the PDF (1.5 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

Filed in the catalog under the QSI Corp QTERM-G70

Page 74

62

QSI Qlarity-based Terminal Programmer’s Reference and "{yoffset}" values obtained from this function call may be used as parameters in the call to DrawSysText(). 4.7.12 GetSysTextFit Syntax: getsystextfit(multiflags[] as reference -> to multiline_flags, xpos[] as reference -> to integer, ypos[] as reference to -> integer, widths[] as reference to -> integer, heights[] as reference to -> integer, xoffsets[] as reference to -> integer, yoffsets[] as reference to -> integer, indices[] as reference to -> integer, lengths[] as reference to -> integer, font as sysfont, facenum as -> integer, ptsize as integer, data[] as -> reference? to sametype!, wordbrks[] as -> reference? to sametype!, linebrks[] as -> reference? to sametype!, flags as -> font_flags)

Parameters: {multiflags} An array of type "multiline_flags" returned by the function giving information on how each line was fitted. {xpos} An array of integers returned by the function that tells the relative horizontal offset for where each line of text should be drawn. {ypos} An array of integers returned by the function that tells the relative vertical offset for where each line of text should be drawn. {widths} An integer array used as both an input and an output. For input, the 0-th element is used to indicate the total width (in pixels) of the box that the text needs to fit into (if FONT_HFIT is specified, this value is only used for alignment purposes). On return, the width for each line of text will be in the individual elements of the array, with the 0-th element always containing the final full width of all the text lines (if FONT_HFIT is specified then this is calculated, otherwise it is the same value as was passed in). {heights} An integer array used as both an input and an output. For input, the 0-th element is used to indicate the total height (in pixels) of the box that the text needs to fit into (if

FONT_VFIT is specified, this value is only used for alignment purposes). On return, the height for each line of text will be in the individual elements of the array, with the 0-th element always containing the final full height of all the text lines (if FONT_VFIT is specified then this is calculated, otherwise it is the same value as was passed in). {xoffsets} An integer array used as both an input and an output. For input, if FONT_HLEFT, FONT_HRIGHT, or FONT_HCENTER is not specified (by default, this is the case), the 0-th element is used to determine how far from the left edge the origin of the first text character should be. On return, the elements indicate how far from the left edge each line's origin should be placed. {yoffsets} An integer array used as both an input and an output. For input, if FONT_VTOP, FONT_VBOTTOM, or FONT_VCENTER is not specified (by default, this is the case), the 0-th element is used to determine how far from the top edge the origin of the first text character should be. On return, the elements indicate how far from the top edge each line's origin should be placed. {indices} An integer array used as both an input and an output. For input, the 0-th element gives the first index into "{data}" indicating where to begin the text fitting. Characters before this index are not fitted. A value of 0 starts at the beginning. On return, the index to the first character for each line of text will be in the individual elements of the array, with the 0-th element containing the index where text fitting began. {lengths} An integer array used as both an input and an output. For input, The number of elements of "{data}" to fit, or -1 to indicate all elements from the starting index to the end of "{data}." On return, the number of elements that should be drawn for each line of text is indicated in the individual elements of the array, with the 0-th element containing the total length of data fitted. {font} The sysfont resource. This may be either a BDF or a TrueType font. {facenum} The number for the desired face. This value is only used with TrueType fonts and is typically zero (0).

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 75

QSI Qlarity-based Terminal Programmer’s Reference

63

{ptsize} The desired point size of the rendered text. This value is ignored unless font specifies a TrueType font.

{maxup} An integer to receive the maximum distance from a character origin to the top edge of any character in the font.

{data} The data to be rendered as text. The type can be a unibyte or byte array (unistring, string or charstr).

{maxdown} An integer to receive the maximum distance from a character origin to the bottom edge of any character in the font.

{wordbrks} An array of the same type as "{data}" that determines which characters to treat as word breaks (spaces, tabs, etc...).

{xnextline} An integer to receive the horizontal offset from the origin of the first character on a line to the origin of the first character on the next line.

{linebrks} An array of the same type as "{data}" that determines which characters to treat as line breaks (newline, form feed, etc...).

{ynextline} An integer to receive the vertical offset from the origin of the first character on a line to the origin of the first character on the next line.

{flags} A value of type "font_flags" that determines how the text will be rendered.

{font} The sysfont resource. This may be either a BDF or a TrueType font.

Description: This function tries to find the best text fit for "{data}." A good understanding of the GetSysTextSize and DrawSysText functions should prelude attempts to use this function.

{facenum} The number for the desired face. This value is only used with TrueType fonts and is typically zero (0).

The parameter "{flags}" is of type font_flags, which is a type that can have any combination of legal values. 4.7.13 GetSysFontMetrics Syntax: getsysfontmetrics(maxleft as reference to -> integer, maxright as reference to integer,-> maxup as reference to integer, maxdown as -> reference to integer, xnextline as -> reference to integer, ynextline as -> reference to integer, font as sysfont, -> facenum as integer, ptsize as integer, -> flags as font_flags)

{ptsize} The point size. This value is ignored unless font specifies a TrueType font. {flags} A value of type "font_flags" (See section 4.7.1, “GetBdfTextSize” for a description) Description: GetSysFontMetrics function returns important metrics for the "{font}" resource which can be used to determine values for parameters in calls to DrawSysText (). 4.7.14 DrawSysText Syntax:

Parameters: {maxleft} An integer to receive the maximum distance in pixels from a character origin to the left edge of any character in the font.

drawsystext(x as integer, y as integer, -> width as integer, height as integer, -> xoffset as integer, yoffset as integer, -> font as sysfont, facenum as integer, -> ptsize as integer, data[] as reference? -> to anytype, flags as font_flags)

{maxright} An integer to receive the maximum distance from a character origin to the right edge of any character in the font.

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 76

64

QSI Qlarity-based Terminal Programmer’s Reference

Parameters: {x} The x-position of the upper left corner of the rendered region (relative to the calling object's parent). {y} The y-position of the upper left corner of the rendered region (relative to the calling object's parent). {width} The width of the region to use for rendering. {height} The height of the region to use for rendering. {xoffset} The horizontal offset from the upper left corner of the rendered region to the origin of the first character. {yoffset} The vertical offset from the upper left corner of the rendered region to the origin of the first character. {font} The sysfont resource. This may be either a BDF or a TrueType font. {facenum} The number for the desired face. This value is only used with TrueType fonts and is typically zero (0). {ptsize} The desired point size of the rendered text. This value is ignored unless font specifies a TrueType font. {data} The data to be rendered as text. The type can be a unibyte or byte array (unistring, string or charstr). {flags} A value of type "font_flags" (See section 4.7.1, “GetBdfTextSize” for a description) Description: DrawSysText renders the text contained in "{data}" and paints the rendered region to the display. The "{width}," "{height}," "{xoffset}," and "{yoffset}" values are often obtained from a call to GetSysTextSize() or inferred from metrics obtained from a call to GetSysFontMetrics(). The rendered text is clipped if the area of the region defined by

"{width}" and "{height}" is not sufficient, or if the values of "{xoffset}" and "{yoffset}" place some or all of the text outside of the rendering region. 4.7.15 DrawSysTextFit Syntax: drawsystextfit(multiflags[] as reference? -> to multiline_flags, xpos[] as reference? -> to integer, ypos[] as reference? to -> integer, widths[] as reference? to -> integer, heights[] as reference? to -> integer, xoffsets[] as reference? to -> integer, yoffsets[] as reference? to -> integer, indices[] as reference? to -> integer, lengths[] as reference? to -> integer, font as sysfont, facenum as -> integer, ptsize as integer, data[] as -> reference? to anytype, flags as font_flags)

Parameters: {multiflags} An array of type "multiline_flags" indicating some information on how well the lines fit within the specified region. {xpos} An array of integers. The 0-th element indicates the x-position of the upper left corner of the rendered region (relative to the calling object's parent). Subsequent elements identify the relative horizontal offset from the initial x-position where each line of text should be drawn. {ypos} An array of integers. The 0-th element indicates the y-position of the upper left corner of the rendered region (relative to the calling object's parent). Subsequent elements identify the relative vertical offset from the initial y-position where each line of text should be drawn. {widths} An array of integers indicating the width for each line of text. {heights} An array of integers indicating the height for each line of text. {xoffsets} An array of integers indicating the horizontal offset from the upper left corner of the rendered region to the origin of the first character for each line.

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 77

QSI Qlarity-based Terminal Programmer’s Reference

{yoffsets} An array of integers indicating the vertical offset from the upper left corner of the rendered region to the origin of the first character for each line. {indices} An array of integers the tells the index into "{data}" where each line of text begins. {lengths} An array of integers indicating the number of elements to draw in each line of "{data}." {font} The sysfont resource. This may be either a BDF or a TrueType font. {facenum} The number for the desired face. This value is only used with TrueType fonts and is typically zero (0).

65

Parameters: {note} The pitch from 0 to 86. {duration} The duration of the note in milliseconds. Description: The PlayNote function plays a note at the specified pitch for the specified duration. The duration is rounded to the nearest multiple of 20 milliseconds. The function returns immediately and the rates are queued. Values for each note number are shown in the table below. Number

Note

Frequency

0 rest note

0 Hz

1

A#/Bb

58.25 Hz

2

B

61.875 Hz

3

C

65.5 Hz

4

C#/Db

69.25 Hz

{data} The data to be rendered as text. The type can be a unibyte or byte array (unistring or string).

5

D

73.5 Hz

6

D#/Eb

77.75 Hz

7

E

82.5 Hz

{flags} A value of type "font_flags" (see below) that determines how the text will be rendered.

8

F

87.25 Hz

9

F#/Gb

92.5 Hz

10

G

98 Hz

11

G#/Ab

103.75 Hz

12

A

110 Hz

13

A#/Bb

116.5 Hz

14

B

123.75 Hz

15

C

131 Hz

16

C#/Db

138.5 Hz

17

D

147 Hz

18

D#/Eb

155.5 Hz

19

E

165 Hz

20

F

174.5 Hz

21

F#/Gb

185 Hz

22

G

196 Hz

{ptsize} The desired point size of the rendered text. This value is ignored unless font specifies a TrueType font.

Description: This function renders the text contained in "{data}." The parameters are typically obtained by a call to GetSysTextFit(). The rendered text is clipped as necessary. A good understanding of the GetSysTextSize and DrawSysText functions should prelude attempts to use this function. The parameter "{flags}" is of type font_flags , which is a type that can have any combination of legal values.

4.8 Controlling the Speaker 4.8.1

PlayNote

Syntax: playnote(note as byte, duration as integer)

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 78

66

QSI Qlarity-based Terminal Programmer’s Reference

Number

Note

Frequency

Number

Note

Frequency

23

G#/Ab

207.5 Hz

56

F

1396 Hz

24

A

220 Hz

57

F#/Gb

1480 Hz

25

A#/Bb

233 Hz

58

G

1568 Hz

26

B

247.5 Hz

59

G#/Ab

1660 Hz

27

C

262 Hz

60

A

1760 Hz

28

C#/Db

277 Hz

61

A#/Bb

1864 Hz

29

D

294 Hz

62

B

1980 Hz

30

D#/Eb

311 Hz

63

C

2096 Hz

31

E

330 Hz

64

C#/Db

2216 Hz

32

F

349 Hz

65

D

2352 Hz

33

F#/Gb

370 Hz

66

D#/Eb

2488 Hz

34

G

392 Hz

67

E

2640 Hz

35

G#/Ab

415 Hz

68

F

2792 Hz

36

A

440 Hz

69

F#/Gb

2960 Hz

37

A#/Bb

466 Hz

70

G

3136 Hz

38

B

495 Hz

71

G#/Ab

3320 Hz

39

Midl C

524 Hz

72

A

3520 Hz

40

C#/Db

554 Hz

73

A#/Bb

3728 Hz

41

D

588 Hz

74

B

3960 Hz

42

D#/Eb

622 Hz

75

C

4192 Hz

43

E

660 Hz

76

C#/Db

4432 Hz

44

F

698 Hz

77

D

4704 Hz

45

F#/Gb

740 Hz

78

D#/Eb

4976 Hz

46

G

784 Hz

79

E

5280 Hz

47

G#/Ab

830 Hz

80

F

5584 Hz

48

A

880 Hz

81

F#/Gb

5920 Hz

49

A#/Bb

932 Hz

82

G

6272 Hz

50

B

990 Hz

83

G#/Ab

6640 Hz

51

C

1048 Hz

84

A

7040 Hz

52

C#/Db

1108 Hz

85

A#/Bb

7456 Hz

53

D

1176 Hz

86

B

7920 Hz

54

D#/Eb

1244 Hz

55

E

1320 Hz

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 79

QSI Qlarity-based Terminal Programmer’s Reference

4.8.2

PlayNoteNotify

67

Parameters: {obj} The object to notify when the sound has finished.

Syntax: playnotenotify (obj as objref, parm as -> integer, note as byte, duratio} as integer)

Parameters: {obj} The object to notify when the sound has finished.

{parm} Optional parameter to send with the message produced when the sound has been played. {sound} The audio resource to play.

{parm} Optional parameter to send with the message produced when the sound has been played.

Description:

{note} The pitch from 0 to 86.

This function plays the audio resource identified by “{sound}.” After the sound has played, the MSG_SOUND_DONE message is sent directly to the specified object, with parm as an optional parameter

{duration} The duration of the note in milliseconds.

4.8.5

Description:

Syntax:

This function plays a note at the specified pitch for the specified duration. The duration is rounded to the nearest multiple of 20 milliseconds. The function returns immediately and the rates are queued. After the note has played, the MSG_SOUND_DONE message is sent directly to the specified object, with parm as an optional parameter.

stopspkr()

4.8.3

4.8.6

PlaySound

StopSpkr

Description: This function immediately silences the speaker, terminating any note that is currently playing, and clears the speaker queue. SetVolume

Syntax:

Syntax:

playsound (sound as _audio)

setvolume(direction as volume_adjust)

Parameters:

Parameters:

{sound} The audio resource to play.

{direction} A value of type "volume_adjust" (see below) that determines how to adjust the volume.

Description: This function plays the audio resource identified by “{sound}.” This function will only play the desired audio resource on units that have the audio decoder option installed. 4.8.4

PlaySoundNotify

Syntax: playsoundnotify (obj as objref, parm as -> integer, sound as _audio)

Description: This function adjusts the volume of the unit at runtime. The adjustment is temporary and is forgotten when power is removed from the terminal. Permanent changes to the volume setting must be made with the Power On Setup utility or the SetSystemSetting() API function. The SetVolume() function takes an argument of type "volume_adjust," which is a defined type with the following legal values:

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 80

68

QSI Qlarity-based Terminal Programmer’s Reference

VOLUME_LOUDER Adjust the volume up.

{len} The number of data elements to extract.

VOLUME_QUIETER Adjust the volume down.

Description: This function returns an array that contains the last “{len}” elements of “{arr}.”

4.9 Array and String Functions 4.9.4 4.9.1

Mid

Len Syntax:

Syntax: len(arr[] as reference? to anytype) -> returns integer mid(arr[] as reference? to sametype!, -> index as integer, len as integer) returns -> sametype!

Parameters:

Parameters:

{arr} An array of any type.

{arr} An array of any type.

Description:

{index} The location of the first data element to extract (0-based).

This function returns the number of elements in the array. 4.9.2

Left

Syntax: left(arr[] as reference? to sametype!, -> len as integer) returns sametype!

Parameters: {arr} An array of any type. {len} The number of data elements to extract. Description: This function returns an array that contains the first “{len}” elements of “{arr}.” 4.9.3

{len} The number of data elements to extract, or -1 to indicate all elements from the element at “{index}” to the end of “{arr}.” Description: This function returns an array containing “{len}” elements from “{arr},” starting with the element located at “{index}” into “{arr}.” 4.9.5

Trim

Syntax: trim(arr[] as reference? to byte) returns -> string

Parameters: {arr} Byte array.

Right

Syntax: right(arr[] as reference? to sametype!, -> len as integer) returns sametype!

Parameters:

Description: This function removes any leading or trailing white space (spaces, tabs, carriage returns, or line feeds) from the byte array, returning the remaining characters.

{arr} An array of any type.

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 81

QSI Qlarity-based Terminal Programmer’s Reference

4.9.6

Find

69

NOTE: It is generally easier to use the plus (+) operator to concatenate arrays.

Syntax: find(match[] as reference? to sametype!, -> start as integer, length as integer, -> pattern[] as reference? to sametype!) -> returns integer

4.9.8

Redim

Syntax:

Parameters:

redim(arr[] as reference to anytype, -> newsize as integer)

{match} An array of any type to examine.

Parameters:

{start} The location in “{match}” to begin the search; elements before the “{start}” element are not searched. 0 starts at the beginning. {length} The number of elements after “{start}” to search in “{match},” or -1 to indicate all elements from “{start}” to the end of “{match}.” {pattern} The pattern of data elements to search for in “{match}.”

{arr} An array of any type. {newsize} The new size of the array “{arr}.” Description: This function resizes an array of any type to the size specified by “{newsize}.” No data is lost unless the array is decreased in size. If the array is increased in size, then the new elements of the array are initialized to the default value for the data type assigned to “{arr}.” 4.9.9

Description:

ArrayOperation

This function searches for “{pattern}” in “{match}.” If “{pattern}” is found, then the index of the first element of “{pattern}” in “{match}” is returned. If “{pattern}” is not found in “{match},” -1 is returned.

Syntax:

4.9.7

Parameters:

Concat

Syntax: concat(strA[] as reference? to sametype!, -> strB[] as reference? to sametype!) -> returns sametype!

Parameters:

arrayoperation (arr1[] as reference to -> anytype, arr2[] as reference? to anytype, -> op as ArrayOp)

{arr1} An array variable that will receive the result of the array operation. Depending on the operation to be performed, this parameter may also be used as an input parameter to the function

{strA} An array of any type to be placed first in the returned array.

{arr2} An array used in the operation. How this parameter will be used is determined by the op parameter.

{strB} An array of the same type as “{strA}” to be placed last in the returned array.

{op} Determines which operation to perform on the input array(s).

Description:

Description:

This function concatenates the arrays “{strA}” and “{strB}” and returns the resulting array.

This function performs one of several array operations, based on the value of the op parameter. The op parameter can take on the following values:

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770

Page 82

70

QSI Qlarity-based Terminal Programmer’s Reference

ARRAY_CONVERT This operation converts arr2[] to the same data type as arr1[] and stores the result of that conversion in arr1[]. Most types of arrays can be converted. This operation is particularly useful when you are developing a workspace that uses both unicode strings and traditional byte strings and you need to convert between the two formats.

Parameters:

ARRAY_PALETTE Both arr2[] and arr1[] must be of type byte or type color. Arr2[] should contain 256 elements. For each element in arr1[], the following assignment is performed: arr1[i] = arr2[arr1[i]]. This performs, in essence a software palette translation on a pixmap. This is used for the translucency and plasma effects you see in some objects.

Description:

ARRAY_REVERSE Reverses the order of elements in arr2[] and stores the result in arr1[]. ARRAY_PFIELD Reserved for future use. Do not use. 4.9.10 FreeArrayHandle Syntax: freearrayhandle(handle as arrayhandle)

Parameters: {handle} An array handle that was previously allocated with a call to AllocateArrayHandle. Description: This function releases an array handle that was allocated by calling AllocateArrayHandle and reclaims the memory used by that handle. After the handle has been freed, it is invalid and should not be used any more.

{data} An array which will receive a copy of the array associated with handle {handle} An array handle that was previously allocated with a call to CreateArrayHandle

This function reads an array associated with an array handle and stores the array in data. You must call this function only with array handles that have been allocated with the AllocateArrayHandle function and which have not been freed by calling FreeArrayHandle. 4.9.12 AllocateArrayHandle Syntax: allocatearrayhandle(data[] as reference? -> to anytype) returns arrayhandle

Parameters: {data} An array to be associated with the returned handle. Description: This function makes a copy of the array that is passed in as the data parameter and returns a handle which can be used to access the new copy via the ReadArrayHandle function. When the array is no longer needed, you MUST call FreeArrayHandle to release the array handle. This function is an advanced API function and if misused may cause the terminal to exhaust its memory resources. 4.9.13 ReverseFind Syntax:

This function is an advanced API function and if misused may cause the terminal to exhaust its memory resources.

reversefind (match[] as reference? to -> sametype!, start as integer, len as -> integer, pattern[] as reference? to -> sametype!) returns integer

4.9.11 ReadArrayHandle

Parameters:

Syntax:

{match} An array of any type to examine.

readarrayhandle (data[] as reference to -> anytype, handle as arrayhandle)

{start} The location in "{match}" to begin the search; characters

QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770