? | ??

?|??

Display one or more values to the console

Syntax

       ? | ?? [<exp list>]

Arguments

<exp list> is a list of values to display and can be any combination of data types, including memo.

If you specify no argument and use the ? command, a carriage return/linefeed is sent to the console. If you use the ?? command without arguments, nothing happens.

Description

? and ?? are console commands that display the results of one or more expressions, separated by a space, to the console. These commands are also command synonyms for the QOUT() and QQOUT() functions, respectively.

Although functionally similar, ? and ?? differ slightly. ? sends a carriage return/linefeed to the console before displaying the results of the expression list. ?? displays output at the current screen cursor or printhead position. This lets you use successive ?? commands to display output to the same line.

A ? or ?? command locates the cursor or printhead one position to the right of the last character displayed. If SET PRINTER is OFF, ROW() and COL() are updated to reflect the new cursor position. If SET PRINTER is ON, PROW() and PCOL() are updated with the new printhead position.

If output from a ? or ?? command reaches the edge of the screen as reported by MAXCOL(), it wraps to the next line. If the output reaches the bottom of the screen as reported by MAXROW(), the screen scrolls up one line.

You can echo output from the ? or ?? commands to the printer by specifying a SET PRINTER ON command before beginning output. You can echo output from both of these commands to a text file using SET ALTERNATE TO <xcFile> to create the file, and SET ALTERNATE ON to begin echoing to the file. Like other console commands, SET CONSOLE OFF suppresses the display to the screen without affecting output to the printer or text file.

To format any expression specified, use TRANSFORM() or a user-defined function. If you need to pad a variable length value for column alignment, use any of the PAD() functions to left-justify, right- justify, or center the value. See the examples below.

Examples

       .  This example prints a record from a database file using ? and
          ?? commands with PADR() to ensure column alignment:
       LOCAL nPage := 0, nLine := 99
       USE Salesman INDEX Salesman NEW
       SET PRINTER ON
       SET CONSOLE OFF
       DO WHILE !EOF()
          IF nLine > 55
             IF nPage != 0
                EJECT
             ENDIF
             ? PADR("Page", LTRIM(STR(nPage++)), 72)
             ?? DTOC(DATE())
             ?
             ?
             ? PADC("Sales Listing", 79)
             ?
             nLine := 5
          ENDIF
          ? Name, Address, PADR(RTRIM(City) + "," ;
                + State, 20), ZipCode
          nLine++
          SKIP
       ENDDO
       SET CONSOLE ON
       SET PRINTER OFF
       CLOSE Salesman

Seealso

@…SAY, PAD(), QOUT(), SET ALTERNATE, SET CONSOLE, SET PRINTER

SP_ADDSPACE

ADDSPACE()

  Short:
  ------
  ADDSPACE() Pads right of string with spaces

  Returns:
  --------
  <cPaddedString> => String padded with spaces.

  Syntax:
  -------
  ADDSPACE(cInString,nPadSpaces)

  Description:
  ------------
  Pads right side of <cInString> with <nPadSpaces> spaces.

  Truncates string if <nPadSpaces> is shorter than
  original string length.

  Examples:
  ---------
   ADDSPACE("GARRY",10)     // => "GARRY           "

  Notes:
  -------
  For compatibility. In Clipper 5.x , the function
  PADR() does the same thing.

  Source:
  -------
  S_ADDSP.PRG

 

C5_PAD

 PAD()
 Pad character, date, and numeric values with a fill character
------------------------------------------------------------------------------
 Syntax

     PADL(<exp>, <nLength>, [<cFillChar>])
        --> cPaddedString
     PADC(<exp>, <nLength>, [<cFillChar>])
        --> cPaddedString
     PADR(<exp>, <nLength>, [<cFillChar>])
        --> cPaddedString

 Arguments

     <exp> is a character, numeric, or date value to be padded with a
     fill character.

     <nLength> is the length of the character string to be returned.

     <cFillChar> is the character with which to pad <exp>.  If not
     specified, the default is a space character.

 Returns

     PADC(), PADL(), and PADR() return the result of <exp> as a character
     string padded with <cFillChar> to a total length of <nLength>.

 Description

     PADC(), PADL(), and PADR() are character functions that pad character,
     date, and numeric values with a fill character to create a new character
     string of a specified length.  PADC() centers <exp> within <nLength>
     adding fill characters to the left and right sides; PADL() adds fill
     characters on the left side; and PADR() adds fill characters on the
     right side.  If the length of <exp> exceeds <nLength>, all of the PAD()
     functions truncate cPaddedString to <nLength>.

     PADC(), PADL(), and PADR() display variable length strings within a
     fixed length area.  They can be used, for instance, to ensure alignment
     with consecutive ?? commands.  Another use is to display text to a fixed-
     width screen area assuring that previous text is completely overwritten.

     PADC(), PADL(), and PADR() are the inverse of the ALLTRIM(), RTRIM(),
     and LTRIM() functions which trim leading and trailing space from
     character strings.

 Examples

     .  This example uses PADR() to format a record number display on
        a status line filling the allocated space:

        IF EOF()
           @ 23, 45 PADR("EOF/" + LTRIM(STR(LASTREC())), 20)
        ELSEIF BOF()
           @ 23, 45 PADR("BOF/" + LTRIM(STR(LASTREC())), 20)
        ELSE
           @ 23, 45 SAY PADR("Record " + LTRIM(STR(RECNO()) ;
                 + "/" + LTRIM(STR(LASTREC())), 20)
        ENDIF

 Files   Library is EXTEND.LIB.

See Also: RTRIM()

 

CT_FIELDSIZE

FIELDSIZE()
 Determines the size of a field
------------------------------------------------------------------------------
 Syntax

     FIELDSIZE(<nField>) --> nLength

 Argument

     <nField>  Designates the number of the field to evaluate.

 Returns

     FIELDSIZE() returns a numeric value that corresponds to the field length
     of a valid field number.

 Description

     Use FIELDSIZE() to determine the length (or size) of data field of
     desired data types.  This determines the window width needed for output
     to appear without a line break, or the length needed for an input to
     automatically fit in the database.

 Note

     .  If there is an invalid data field number, the function returns
        a value of 0.

 Example

     Determine the total length of fields 3 to 5:

     nLength  :=  0
     FOR I = 3 TO 5
        nLength := nLength + FIELDSIZE()
     NEXT

See Also:  FCOUNT, FIELDNUM, FIELDNAME, FIELDTYPE, FIELDDECI, PAD, STR, DBF Structure

CT_FIELDNUM

FIELDNUM()
 Determines the field number for a specific field in a database file
------------------------------------------------------------------------------
 Syntax

     FIELDNUM(<cFieldName>) --> nFieldNumber

 Argument

     <cFieldName>  Designates to the field name.

 Returns

     FIELDNUM() returns the number of the data field.

 Description

     FIELDNUM() is the exact opposite of the CA-Clipper FIELD() function.
     Use this function when you need a data field number instead of the data
     field name.  FIELDNUM() determines if a symbol name pertains to a data
     field or a memory variable (see Examples).

 Note

     .  If a data field with the name <cFieldName> is not available,
        the function returns a value of 0.

 Example

     Is it a field or a variable?

     IF FIELDNUM("cName") > 0.
        REPLACE cName WITH UPPER(cName).
     ELSE.
        cName  :=  UPPER(cName).
     ENDIF

See Also:  FCOUNT,  FIELDNAME, FIELDTYPE, FIELDSIZE, FIELDDECI, PAD, STR, DBF Structure

 

DBF Structure

How I can obtain structure info of a DBF ?

 

PROC MAIN()
 
   SETMODE( 25, 80 )
   CLS
 
   USE ..\datas\TEST1
? "No Field Name T Size Dec"
   ? "-- ------------ - ----- ---"
 
   FOR nFld := 1 TO FCOUNT()
       * or : FIELDNUM( FIELDNAME( nFld ) 
       ? STR( nFld, 2, 0 ),; // CT Database Function
         PAD( FIELDNAME( nFld ), 12 ),; // Standard dBASE function
         FIELDTYPE( nFld ),; // CT Database Function
         STR( FIELDSIZE( nFld ), 5, 0 ),; // CT Database Function
         STR( FIELDDECI( nFld ), 3, 0 ) // CT Database Function
    NEXT nFld
 
    ? 
    WAIT "EOF DBF_Struct.prg"
 
RETURN // MAIN.DBF_Struct.prg"

Uniform Arrays

 

If a multi-dimension array

–          have a fixed number elements in each dimension and

–          each column contains the same type of information for each row in array

called “uniform”.

This structure is similar to a table structure.

Built-in functions DBSTRUCT() and DIRECTORY() produces uniform arrays.

Array produced by DBSTRUCT() will have field count  in size and the structure of an array is:

Field Name  C
Field Type  C
Field Width N
Field Dec   N

And DIRECTORY() function produces an array with elements as file count and with this structure:

File Name        C
File Size        N
File Date        D
File Time        C
File Attributes  C

Building, maintaining and using those arrays is simple as possible.

Let’s look at a sample .prg:

-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
#include "directry.ch"
#include "dbstruct.ch"
PROCEDURE Main()
  SET DATE GERM
  SET CENT ON
 
  ?
  ? "Uniform arrays :" 
  ?
 
  ?
  ? " Directory file list :"
  ?
 
  FileList()
 
  ?
  ? " Table structure list :"
  ?
  IF MakUseTable()
     DispStru() 
  ELSE
     ? "Couldn't USE or Make th table." 
  ENDIF
 
  ?
  @ MAXROW(), 0
  WAIT "EOF UF_Arrays.prg"
 
RETURN // UF_Arrays.Main
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._

PROCEDURE FileList()
  LOCAL aFList := DIRECTORY( "C:\Harbour\*.*" )
  LOCAL a1File
 
  FOR EACH a1File IN aFList 
     ? SPACE( 4 ),;
       PAD( a1File[ F_NAME ], 13 ),; /* File name */ 
       TRAN( a1File[ F_SIZE ], "999,999,999" ),; /* File size */
       a1File[ F_DATE ],; /* File date */
       a1File[ F_TIME ],; /* File time */
       a1File[ F_ATTR ] /* File attribute */
 NEXT
 
RETURN // FileList()
 
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
FUNCTION MakUseTable() 
 
  LOCAL cTablName := "CUSTOMER.DBF"
  LOCAL lRetval, aStru 
 
  IF FILE( cTablName ) 
     USE (cTablName)
  ELSE
     aStru := { { "CUST_ID",    "C",  5, 0 },;
                { "CUST_NAME",  "C", 10, 0 },;
                { "CUST_SNAM",  "C", 10, 0 },;
                { "CUST_FDAT",  "D",  8, 0 },;
                { "CUST_ACTV",  "L",  1, 0 },;
                { "CUST_BLNCE", "N", 11, 2 } }
    * 
    * 5-th parameter of DBCREATE() is alias - 
    * if not given then WA is open without alias 
    *                              ^^^^^^^^^^^^^ 
    DBCREATE( cTablName, aStru, , .F., "CUSTOMER" ) 
 ENDIF 
 
 lRetval := ( ALIAS() == "CUSTOMER" )
 
RETURN lRetval // MakUseTable()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
PROCEDURE DispStru()
   LOCAL nTotal := 1
 
   IF SELECT() > 0
      aStructur := DBSTRUCT()
      ? SPACE( 4 ), "No: Field Name Type Width Dec"
      ? SPACE( 4 ), "--- ---------- ---- ----- ---"
      AEVAL( aStructur, { | aF1, nFNo | ;
             QOUT( SPACE( 4 ),; // Left Marj 
                   PADL( nFNo, 3 ),; // Field No
                   PADR( aF1[ DBS_NAME ], 11 ),; // Field Name
                   PADC( aF1[ DBS_TYPE ], 4 ),; // Field Type
                   PADL( aF1[ DBS_LEN ], 4 ),; // Field Len
                   PADL( aF1[ DBS_DEC ], 3 )),; // Field Dec 
             nTotal += aF1[ 3 ] } )
 
      ? SPACE( 4 ), "--- ---------- ---- ----- ---"
      ? SPACE( 4 ), "** Total ** ", TRAN( nTotal, "9,999" )
   ELSE
      ? "Current work area is empty"
   ENDIF 
 
RETURN // DispStru()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
 
UF_Arrays

C5 Data Manipulation Functions

Array :

AADD() :

Add a new element to the end of an array

AADD( <aTarget>, <expValue> ) --> Value

ACLONE() :

Duplicate a nested or multidimensional array

ACLONE( <aSource> ) --> aDuplicate

ACOPY() :

Copy elements from one array to another

ACOPY( <aSource>, <aTarget>, [ <nStart> ], [ <nCount> ], 
    [ <nTargetPos> ] ) --> aTarget

ADEL() :

Delete an array element

ADEL( <aTarget>, <nPosition> ) --> aTarget

ADIR()* :

Fill a series of arrays with directory information

ADIR([ <cFilespec> ],
    [ <aFilenames> ],
    [ <aSizes> ],
    [ <aDates> ],
    [ <aTimes> ],
    [ <aAttributes> ] ) --> nFiles

AEVAL() :

Execute a code block for each element in an array

AEVAL( <aArray>, <bBlock>, [ <nStart> ], [ <nCount> ] ) --> aArray

AFILL() :

Fill an array with a specified value

AFILL( <aTarget>, <expValue>, [ <nStart> ], [ <nCount> ] )
       --> aTarget

AINS() :

Insert a NIL element into an array

AINS( <aTarget>, <nPosition> ) --> aTarget

ARRAY() :

Create an uninitialized array of specified length

ARRAY( <nElements> [, <nElements>...] ) --> aArray

ASCAN() :

Scan an array for a value or until a block returns (.T.)

ASCAN( <aTarget>, <expSearch>, [ <nStart> ], [ <nCount> ] )
      --> nStoppedAt

ASIZE() :

Grow or shrink an array

ASIZE( <aTarget>, <nLength> ) --> aTarget

ASORT() :

Sort an array

ASORT( <aTarget>, [ <nStart> ], [ <nCount> ], [ <bOrder> ] )
       --> aTarget

ATAIL() :

Return value of the highest numbered (last) element of an array

ATAIL( <aArray> ) --> Element

Common :

EMPTY() :

Determine if the result of an expression is empty

EMPTY( <exp> ) --> lEmpty

LEN() :

Return the length of a character string or array size

LEN( <cString> | <aArray> ) --> nCount

MAX() :

Return the larger of two numeric or date values

MAX( <nExp1>, <nExp2> ) --> nLarger
MAX( <dExp1>, <dExp2> ) --> dLarger

MIN() :

Return the smaller of two numeric or date values

MIN( <nExp1>, <nExp2> ) --> nSmaller
MIN( <dExp1>, <dExp2> ) --> dSmaller

PAD() :

Pad character, date or numeric values with a fill character

PADL( <exp>, <nLength>, [ <cFillChar> ] ) --> cPaddedString
PADC( <exp>, <nLength>, [ <cFillChar> ] ) --> cPaddedString
PADR( <exp>, <nLength>, [ <cFillChar> ] ) --> cPaddedString

TRANSFORM() :

Convert any value into a formatted character string

TRANSFORM( <exp>, <cSayPicture> ) --> cFormatString

TYPE() :

Determine the type of an expression

TYPE( <cExp> ) --> cType

VALTYPE() :

Determine the data type returned by an expression

VALTYPE( <exp> ) --> cType

Date & Time :

CDOW() :

Convert a date value to a character day of the week

CDOW( <dExp> ) --> cDayName

CMONTH() :

Convert a date to a character month name

CMONTH( <dDate> ) --> cMonth

CTOD() :

Convert a date string to a date value

CTOD( <cDate> ) --> dDate

DATE() :

Return the system date as a date value

DATE() --> dSystem

DAY() :

Return the day of the month as a numeric value

DAY( <dDate> ) --> nDay

DOW() :

Convert a date value to a numeric day of the week

DOW( <dDate> ) --> nDay

DTOC() :

Convert a date value to a character string

DTOC( <dDate> ) --> cDate

DTOS() :

Convert a date value to a string formatted as yyyymmdd

DTOS( <dDate> ) --> cDate

MONTH() :

Convert a date value to the number of the month

MONTH( <dDate> ) --> nMonth

SECONDS() :

Return the number of seconds elapsed since midnight

SECONDS() --> nSeconds

TIME() :

Return the system time

TIME() --> cTimeString

YEAR() :

Convert a date value to the year as a numeric value

YEAR( <dDate> ) --> nYear

Numeric :

ABS() :

Return the absolute value of a numeric expression

ABS( <nExp> ) --> nPositive

BIN2I() :

Convert a 16-bit signed integer to a numeric value

BIN2I( <cSignedInt> ) --> nNumber

BIN2L() :

Convert a 32-bit signed integer to a numeric value

BIN2L( <cSignedInt> ) --> nNumber

BIN2W() :

Convert a 16-bit unsigned integer to a numeric value

BIN2W( <cUnsignedInt> ) --> nNumber

EXP() :

Calculate e**x

EXP( <nExponent> ) --> nAntilogarithm

INT() :

Convert a numeric value to an integer

INT( <nExp> ) --> nInteger

I2BIN() :

Convert a numeric to a 16-bit binary integer

I2BIN( <nInteger> ) --> cBinaryInteger

LOG() :

Calculate the natural logarithm of a numeric value

LOG( <nExp> ) --> nNaturalLog

L2BIN() :

Convert a numeric value to a 32-bit binary integer

L2BIN( <nExp> ) --> cBinaryInteger

MOD()* :

Return dBASE III PLUS modulus of two numbers

MOD( <nDividend>, <nDivisor> ) --> nRemainder

ROUND() :

Return a value rounded to a specified number of digits

ROUND( <nNumber>, <nDecimals> ) --> nRounded

SQRT() :

Return the square root of a positive number

SQRT( <nNumber> ) --> nRoot

VAL() :

Convert a character number to numeric type

VAL( <cNumber> ) --> nNumber

String & Memo :

ALLTRIM() :

Remove leading and trailing spaces from character string

ALLTRIM( <cString> ) --> cTrimString

ASC() :

Convert a character to its ASCII value

ASC( <cExp> ) --> nCode

AT() :

Return the position of a substring within a string

AT( <cSearch>, <cTarget> ) --> nPosition

CHR() :

Convert an ASCII code to a character value

CHR( <nCode> ) --> cChar

HARDCR() :

Replace all soft CRs with hard CRs

HARDCR( <cString> ) --> cConvertedString

ISALPHA() :

Determine if the leftmost character is alphabetic

ISALPHA( <cString> ) --> lBoolean

ISDIGIT() :

Determine if the leftmost character is a digit

ISDIGIT( <cString> ) --> lBoolean

ISLOWER() :

Determine if the leftmost character is a lower case letter

ISLOWER( <cString> ) --> lBoolean

ISUPPER() :

Determine if the leftmost character is upper case

ISUPPER( <cString> ) --> lBoolean

LEFT() :

Extract a substring beginning with the first character

LEFT( <cString>, <nCount> ) --> cSubString

LOWER() :

Convert uppercase characters to lowercase

LOWER( <cString> ) --> cLowerString

LTRIM() :

Remove leading spaces from a character string

LTRIM( <cString> ) --> cTrimString

MEMOEDIT() :

Display or edit character strings and memo fields

MEMOEDIT( [ <cString> ],
    [ <nTop> ], [ <nLeft> ],
    [ <nBottom> ], [ <nRight> ],
    [ <lEditMode> ],
    [ <cUserFunction> ],
    [ <nLineLength> ],
    [ <nTabSize> ],
    [ <nTextBufferRow> ],
    [ <nTextBufferColumn> ],
    [ <nWindowRow> ],
    [ <nWindowColumn> ] ) --> cTextBuffer

MEMOLINE() :

Extract a line of text from character string or memo field

MEMOLINE( <cString>,
    [ <nLineLength> ],
    [ <nLineNumber> ],
    [ <nTabSize> ],
    [ <lWrap> ] ) --> cLine

MEMOREAD() :

Return the contents of a disk file as a character string

MEMOREAD( <cFile> ) --> cString

MEMOTRAN() :

Replace carriage return/line feeds in character strings

MEMOTRAN( <cString>,
    [ <cReplaceHardCR> ],
    [ <cReplaceSoftCR> ] ) --> cNewString

MEMOWRIT() :

Write a character string or memo field to a disk file

MEMOWRIT( <cFile>, <cString> ) --> lSuccess

MLCOUNT() :

Count the lines in a character string or memo field

MLCOUNT( <cString>, [ <nLineLength> ],  [ <nTabSize> ],
         [ <lWrap> ] ) --> nLines

MLCTOPOS() :

Return byte position based on line and column position

MLCTOPOS( <cText>, <nWidth>, <nLine>,
    <nCol>, [ <nTabSize> ], [ <lWrap> ] ) --> nPosition

MLPOS() :

Determine the position of a line in a memo field

MLPOS( <cString>, <nLineLength>,
     <nLine>, [ <nTabSize> ], [ <lWrap> ] ) --> nPosition

MPOSTOLC() :

Return line and column position based on byte position

MPOSTOLC( <cText>, <nWidth>, <nPos>,
     [ <nTabSize> ], [ <lWrap> ] ) --> aLineColumn

RAT() :

Return the position of the last occurrence of a substring

RAT( <cSearch>, <cTarget> ) --> nPosition

REPLICATE() :

Return a string repeated a specified number of times

REPLICATE( <cString>, <nCount> ) --> cRepeatedString

RIGHT() :

Return a substring beginning with rightmost character

RIGHT( <cString>, <nCount> ) --> cSubString

RTRIM() :

Remove trailing spaces from a character string

RTRIM( <cString> ) --> cTrimString

SET EXACT* :

Toggle exact matches for character strings

SET EXACT on | OFF | <xlToggle>

SOUNDEX() :

Convert a character string to soundex form

SOUNDEX( <cString> ) --> cSoundexString

SPACE() :

Return a string of spaces

SPACE( <nCount> ) --> cSpaces

STR() :

Convert a numeric expression to a character string

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

STRTRAN() :

Search and replace characters within a character string

STRTRAN( <cString>, <cSearch>, [ <cReplace> ],
    [ <nStart> ], [ <nCount> ] ) --> cNewString

STUFF() :

Delete and insert characters in a string

STUFF( <cString>, <nStart>, <nDelete>, <cInsert> ) --> cNewString

SUBSTR() :

Extract a substring from a character string

SUBSTR( <cString>, <nStart>, [ <nCount> ] ) --> cSubstring

TRIM() :

Remove trailing spaces from a character string

TRIM( <cString> ) --> cTrimString

UPPER() :

Convert lowercase characters to uppercase

UPPER( <cString> ) --> cUpperString