DevOutPict

DevOutPict

Writes a PICTURE formatted value to the current device.

Syntax

      DevOutPict( <expression>, <cPicture> [,<cColor>] ) --> NIL

Arguments

<expression> : Any valid expression to write to the device assigned by SET DEVICE command

<cPicture> : A valid PICTURE format string.

<cColor> : A valid color codes string for value to write. Default is current color setting

Returns

DevOutPict() always returns NIL

Description

DevOutPict() is a console function that outputs the value of an expression to the screen or the printer with defined PICTURE and color. Output device depens on current device.

Example

      DevOutPict( CUST->DEBIT, "99,999.99" )

Seealso

@…SAY, Col(), DevOut(), DevPos(), QOut() | QQOut(), Row(), SET DEVICE, SetPos(), Transform()

StrFormat()

StrFormat()

Format a string

Syntax

      StrFormat(<cMask>[, <cPar1>[, <cParn>[, ...]]) --> cString

Arguments

<cMask> Holds the mask for the resulting string

<cParn> Holds the strings to be inserted in the mask maximum 9 of them can be specified.

Returns

<cString> Return the mask with all the parameters inserted.

Description

String replacment, can be useful when writing international apps. You can separate the constant strings from the variable ones. Each %1 – %9 marks will be replaced with the appropriate parameter from the parameter list.

Marks can be in any order, and can be duplicated.

You can print “%” character with “%%”.

Examples

      StrFormat( "Please insert disk %1 to drive %2", hb_ntos( 2 ), "A:" )
      StrFormat( "This is %1 from %2", "Victor", "Hungary" )
      StrFormat( "%2 %1 %2", "Param1", "Param2" )

Tests

      ? StrFormat( "Please insert disk %1 to drive %2", hb_ntos( 2 ), "A:" )
      ? StrFormat( "This is %1 from %2", "Victor", "Hungary" )
      ? StrFormat( "%2 %1 %2", "Param1", "Param2" )
      ? StrFormat( "Hello" )
      ? StrFormat( "%1 - %2", "one" )
      ? StrFormat( "%1 - %2", "one", "two" )
      ? StrFormat( "%2 - %1", "one", "two" )
      ? StrFormat( "%2 - %", "one", "two" )
      ? StrFormat( "%% - %", "one", "two" )
      ? StrFormat( "%9 - %", "one", "two" )

Compliance

All platforms

Files

Library is libmisc

Seealso

Transform(), Stuff(), StrTran()

Harbour All Functions – T

TabExpand
TabPack

Tan

TanH

TBrowseDB

TBrowseNew

TFileRead

THtml

Time

TimeValid

TNortonGuide 

Token
TokenAt
TokenEnd
TokenExit
TokenInit
TokenLower
TokenNext
TokenNum
TokenSep
TokenUpper

Tone

TOs2

Transform
Trim

TRtf

TTroff

 Type

String Functions

AddASCII

AfterAtNum

AllTrim
Asc

ASCIISum

ASCPos
At

AtAdjust

AtNum
AtRepl
AtToken

BeforAtNum

Chr

CharAdd
CharAnd
CharEven
CharHist
CharList
CharMirr
CharMix
CharNoList
CharNot
CharOdd
CharOne
CharOnly
CharOr
CharPix
CharRela
CharRelRep
CharRem
CharRepl
CharRLL
CharRLR
CharSHL
CharSHR
CharSList
CharSort
CharSub
CharSwap
CharWin
CharXOR

CountLeft
CountRight
Descend
Empty
hb_At
hb_RAt
hb_ValToStr
IsAlpha
IsDigit
IsLower
IsUpper

JustLeft
JustRight

Left
Len
Lower
LTrim

NumAt
NumToken
PadLeft
PadRight

PadC
PadL
PadR

POSALPHA
POSCHAR
POSDEL
POSDIFF
POSEQUAL
POSINS
POSLOWER
POSRANGE
POSREPL
POSUPPER

RangeRem
RangeRepl

RAt

RemAll

RemLeft
RemRight
ReplAll

Replicate

ReplLeft

ReplRight

RestToken

Right
RTrim

SaveToken

SetAtLike
Space
Str

StrDiff

StrFormat

StrSwap

StrTran
StrZero
SubStr

TabExpand
TabPack

Token

TokenAt
TokenEnd
TokenExit
TokenInit
TokenLower
TokenNext
TokenNum
TokenSep
TokenUpper

Transform
Trim
Upper
Val

ValPos
WordOne
WordOnly
WordRem
WordRepl
WordSwap

WordToChar


Val()

Val()

Convert a number from a character type to numeric

Syntax

      Val( <cNumber> ) --> nNumber

Arguments

<cNumber> Any valid character string of numbers.

Returns

<nNumber> The numeric value of <cNumber>

Description

This function converts any number previously defined as an character expression <cNumber> into a numeric expression.

This functions is the oppose of the Str() function.

Examples

      ? Val( "31421" ) // 31421

Compliance

Clipper

Platforms

All

Files

Library is core

Seealso

Str(), Transform()

Str()

Str()

Convert a numeric expression to a character string.

Syntax

      Str( <nNumber>,  [<nLength>],  [<nDecimals>] ) --> cNumber

Arguments

<nNumber> is the numeric expression to be converted to a character string.

<nLength> is the length of the character string to return, including decimal digits, decimal point, and sign.

<nDecimals> is the number of decimal places to return.

Returns

Str() returns <nNumber> formatted as a character string. If the optional length and decimal arguments are not specified, Str() returns the character string according to the following rules:

Results of Str() with No Optional Arguments

      Expression               Return Value Length
      ------------------------ -----------------------------------
      Field Variable           Field length plus decimals
      Expressions/constants    Minimum of 10 digits plus decimals
      Val()                    Minimum of 3 digits
      Month()/Day()            3 digits
      Year()                   5 digits
      RecNo()                  7 digits

Description

Str() is a numeric conversion function that converts numeric values to character strings. It is commonly used to concatenate numeric values to character strings. Str() has applications displaying numbers, creating codes such as part numbers from numeric values, and creating index keys that combine numeric and character data.

Str() is like Transform(), which formats numeric values as character strings using a mask instead of length and decimal specifications.

The inverse of Str() is Val(), which converts character numbers to numerics.

* If <nLength> is less than the number of whole number digits in <nNumber>, Str() returns asterisks instead of the number.

* If <nLength> is less than the number of decimal digits required for the decimal portion of the returned string, Harbour rounds the number to the available number of decimal places.

* If <nLength> is specified but <nDecimals> is omitted (no decimal places), the return value is rounded to an integer.

Examples

      ? Str( 10,  6,  2 ) // " 10.00"
      ? Str( -10,  8,  2 ) // "  -10.00"

Compliance

Clipper

Files

Library is core

Seealso

StrZero(), Transform(), Val()

@…SAY

@…SAY

Displays data at specified coordinates of the current device.

Syntax

      @ <nRow>,<nCol> SAY <xValue> [ PICTURE <cPict> ] [COLOR <cColor>]

Arguments

<nRow> Row coordinate

<nCol> Column coordinate

<xValue> Value to display

<cPict> PICTURE format

<cColor> Color string

Description

This command displays the contents of <xValue> at row column coordinates <nRow>, <nCol>. A PICTURE clause may be specified in <cPict>. If the current device is set to the printer, the output will go to the printer; the default is for all output to go to the screen.

For a complete list of PICTURES templates and functions, see the @…GET command.

Examples

      PROCEDURE Main()
         CLS
         @ 2, 1 SAY "Harbour"
         @ 3, 1 SAY "is" COLOR "b/r+"
         @ 4, 1 SAY "Power" PICTURE "@!"
         RETURN

Tests

      See Examples

Compliance

Clipper

Platforms

All

Seealso

@…GET, SET DEVICE, TRANSFORM()

@…GET

@…GET

Creates a GET object and displays it to the screen

Syntax

      @ <nRow>,<nCol> [SAY <cSay> [PICTURE <cSayPict>] COLOR <cSayColor> ]
      GET <xVar> [PICTURE <cGetPict>] [WHEN <lWhen>] [COLOR <cGetColor>]
      [VALID <lValid> / RANGE <xStart>,<xEnd>]

Arguments

<nRow> The row coordinate.

<nCol> The column coordinate.

<cSay> Message to display.

<cSayPict> Character expression of PICTURE displayed.

<cSayColor> Color to be Used for the SAY expression.

<xVar> An variable/field name.

<cGetPict> Character expression of PICTURE to get.

<lWhen> Logical expression to allow GET.

<lValid> Logical expression to validate GET input.

<xStart> Lower RANGE value.

<xEnd> Upper RANGE value.

<cGetColor> Color string to be used for the GET expression.

Description

This command adds a GET object to the reserved array variable named GETLIST[] and displays it to the screen. The field or variable to be added to the GET object is specified in <xVar> and is displayed at row, column coordinate <nRow>, <nCol>.

If the SAY clause is used <cSay> will be displayed starting at <nRow>, <nCol>, with the field variable <xVar> displayed at ROW(), COL()+ 1. If <cSayPicr>, the picture template for the SAY expression <cSay>, is used, all formatting rules contained will apply See the TRANSFORM I function for further information.

If <cGetPict> is specified, the PICTURE clause of <xVar> will be used for the GET object and all formatting rules will apply. See the table below for GET formatting rules.

If the WHEN clause is specified, when <lWhen> evaluates to a logical true (.T.) condition, the GET object will he activated otherwise the GET object will be skipped and no information will be obtained via the screen. The name of a user-defined function returning a logical true (.T.) or false ( F.) or a code block may be , specified in <lWhen> This clause not activated until a READ command or READMODAL() function call is issued.

If the VALID clause is specified and <lValid> evaluates to it logical true (.T.) condition the current GET will be considered valid and the get operation will continue onto the next active GET object. If not, the cursor will remain on this GET object until aborted or until the condition in <lValid> evaluates to true (.T.). The name of a user-defined function returning a logical true (.T.) or false (.F.) or it code block may be specified in <lValid>. This clause is not activated until a READ command or READMODAL( ) function call is issued.

If the RANGE clause is specified instead of the VALID clause, the two inclusive range values for <xVar> must be specified in <xStart> and <xEnd>. Id <xVar> is a date data type, <xStart> and <xEnd> must also be date data types; if <xVar> is a numeric data type <xStart> and <xEnd> must also be numeric data types. If a value fails the RANGE test , a message of OUT OF RANGE will appear in the SCOREBOARD area (row = 0, col = 60). The RANGE message may be turned off it the SET SCOREBOARD command or SET() function appropriately toggled.

NOTE: GET functions/formatting rules:

      @A          Allows only alphabetic characters.
      @B          Numbers will be left justified
      @C          All positive numbers will be followed by CR.
      @D          All dates will be in the SET DATE format.
      @E          Dates will be in British formal: numbers in European format.
      @K          Allows a suggested value to be seen within the GET
                  area but clears It if any non cursor key is pressed when
                  the cursor is in the first Position in the GET area.
      @R          Non template characters will be inserted.
      @S<nSize>   Allows horizontal scrolling of a field or variable that
                  is <nSize> characters wide.
      @X          All negative numbers will be followed by DB
      @Z          Displays zero values as blanks.
      @!          Forces uppercase lettering
      @(          Displays negative numbers in parentheses with leading spaces.
      @)          Displays negative numbers in parentheses without leading spaces.

GET templates/formatting rules:

      A   Only alphabetic characters allowed.
      N   Only alphabetic and numeric characters allowed
      X   Any character allowed.
      L   Only T or F allowed For logical data.
      Y   Only Y or N allowed for logical data.
      9   Only digits, including signs, will be allowed.
      #   Only digits, signs. and spaces will he allowed.
      !   Alphabetic characters are converted to Uppercase.
      $   Dollar  will be displayed in place of leading
          spaces for numeric data types.
      *   Asterisk,, will Be displayed in place of leading spaces
          for numeric data types.
      .   Position of decimal point.
      ,   Position of comma.

Format PICTURE functions may he grouped together as well as used in Conjunction with a PICTURE templates;however, a blank space must be included in the PICTURE string if there are both functions and templates.

Examples

      PROCEDURE Main()
         LOCAL cVar := Space( 50 )
         LOCAL nId := 0
         CLS
         @ 3,1 SAY "Name" GET cVar PICTURE "@!S 30"
         @ 4,1 SAY "Id"   GET nId  PICTURE "999.999"
         READ
         ? "The name you entered is",cVar
         ? "The id you entered is",nId
         RETURN

Tests

      See Examples

Compliance

Clipper

Platforms

All

Seealso

@…SAY, READ, TRANSFORM()

Harbour Extensions

Harbour Extensions

Harbour Extensions

Description

Language extensions:

* Class generation and management.

CA-Cl*pper only allowed creation of objects from a few standard classes.

In Harbour, you can create your own classes–complete with Methods, Instance Variables, Class Variables and Inheritance. Entire applications can be designed and coded in Object Oriented style.

* @<FunctionName>()

Returns the pointer (address) to a function.

The returned value is not useful to application-level programming, but is used at a low level to implement object oriented coding. (Internally, a class method is a static function and there is no symbol for it, so it is accessed via its address).

* Class HBGetList

Object oriented support for GetLists management.

* ProcName() support for class Method names.

Class Methods can be retrieved from the call stack.

* Memory() has new return values.

See hbmemory.ch

* Transform() –> new function in format string

@0 Make a zero padded string out of the number.

* SToD() –> dDate

New function that converts a yyyymmdd string to a Date value.

* Optional Compile Time STRONG TYPE declaration (and compile time TYPE MISMATCH warnings)

Example: LOCAL/STATIC Var AS …

* The Harbour debugger provides new interesting classes:

– Class TDbWindow could be the foundation for a generic multiplatform

– Class TForm

– Class TDbMenu implement both pulldown and popup menus.

RTL enhanced functionality:

– Directory( <cMask>, <cFlags>, <lEightDotThree> )

The 3rd parameter is a Harbour (optional) parameter and indicates that on those platforms that support long filenames, that you wish to receive what would be considered the dos equivalant 8.3 name. Could affect Adir() and Dir if they were modified to take advantage of it – currently, they will return long names if the os supports it.

– HB_DiskSpace( <nDrive>, <nType> )

The second parameter is a Harbour (optional) parameter and indicates the type of diskinfo being requested. See en/diskspac.txt for info.

DevOutPict()

DEVOUTPICT()

Displays a value to a device using a picture template

Syntax

      DEVOUTPICT( <xExp>, <cPicture>, [<cColorString>] )

Arguments

<xExp> is any valid expression.

<cPicture> is any picture transformation that TRANSFORM() can use.

<cColorString> is an optional string that specifies a screen color to use in place of the default color when the output goes to the screen.

Description

Outputs any expression using a picture transformation instead of using the default transformation for the type of expression.

Examples

      // Output a negative dollar amount using debit notation.
      DEVOUTPICT( -1.25, "@D$ 99,999.99 )

Tests

      @ 3, 1 SAY -1.25 PICTURE "@D$ 99,999.99"
      will display "$(     1.25)" starting on row four, column two of the
      current device (without the double quotation marks, of course).

Compliance

DEVOUTPICT() is mostly CA-Cl*pper compliant. Any differences are due to enhancements in the Harbour TRANSFORM() over CA-Cl*pper.

Files

Library is rtl

Seealso

DEVOUT(), TRANSFORM()