Click or drag to resize

LoByte Function

X#
Return the low-order (rightmost) byte in a number.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax
 FUNCTION LoByte(
	wValue AS WORD
) AS BYTE
Request Example View Source

Parameters

wValue
Type: Word
The number whose low-order byte you want to get.

Return Value

Type: Byte
Remarks
Related data can be stored in the high-order and low-order words of a variable.
Therefore, instead of creating and returning a 2-element array, it may be more efficient to return a word whose 2 bytes contain separate information.
Examples
The Windows API function GetVersion() returns the DOS version in the high-order WORD and the Windows version in the low-order WORD. Moreover, the DOS major number is in the high-order byte of its WORD, the DOS minor number is in the low-order bytes of its WORD, the Windows major number is in the low-order byte of its WORD, and the Windows minor number is in the high-order byte of its WORD:
X#
 1LOCAL dwVersion AS DWORD
 2LOCAL wDOS, wWindows AS DWORD
 3LOCAL bDOSMinor, bDOSMajor AS BYTE
 4LOCAL bWindowsMajor, bWindowsMinor AS BYTE
 5dwVersions := GetVersion()
 6wDOS :=  HiWord(dwVersions)
 7bDOSMajor := HiByte(wDOS)
 8bDOSMinor := LoByte(wDOS)
 9wWindows := LoWord(dwVersions)
10bWindowsMinor := HiByte(wWindows)
11bWindowsMajor := LoByte(wWindows)
12? "The DOS major and minor numbers are",;
13     bDOSMajor, bDOSMinor
14// The DOS major and minor numbers are 5          0
15? "The Windows major and minor numbers are",;
16     bWindowsMajor, bWindowsMinor
17// The Windows major and minor numbers are 3      10
See Also