Click or drag to resize

Functions.SetDigit Method

Return and optionally change the setting that determines the number of digits that will be shown to the left of the decimal point when a number is displayed.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.16
Request Example View Source

Return Value

Type: DWord
If nNewSetting is not specified, SetDigit() returns the current setting.
If nNewSetting is specified, the previous setting is returned.
SetDigit() and SetDigitFixed() can be used together to control the way digits are displayed: When SetDigitFixed() is TRUE, display of numeric output is fixed according to the SetDigit() value. When SetDigitFixed() is FALSE, numeric output displays according to the default rules for numeric display. To provide finer control of numeric display, you can use the PICTURE clause of @...SAY, @...GET, and the Transform() function. A -1 for nNewSetting implies that only significant whole digits to the left of the decimal are to be displayed (any leading zeros will be suppressed.)
Tip Tip
SetDigit() affects only the display format of numbers, not the actual numeric precision of calculations.
This example shows typical uses of SetDigit():
 1FUNCTION Start()
 2    LOCAL nSaveDigit AS SHORTINT
 3    ? 1234                // 1234
 4                        // Initial setting is 10 digits
 5                        // Number is displayed right justified
 6                        // Save current setting, then reset to 5 digits
 7    nSaveDigit := SetDigit(5)
 8    ? 1234                //  234
 9    ? 1234.567                //  1234.567
10    ? 123456                // *****
11    SetDigit(nSaveDigit)        // Restore the old setting
12    ? 1234                //  1234
See Also