PAYMENT()

PAYMENT()

Payments for a loan

Syntax

       PAYMENT( nLoan, nInterest, nPeriods ) --> nPayment

Arguments

<nLoan> amount of money you get from the bank

<nInterest> rate of interest per period, 1 == 100%

<nPeriods> period count

Returns

<nPayment> Periodical payment one has to make to pay the loan <nLoan> back

Description

PAYMENT() calculates the payment one has to make periodically to pay back a loan <nLoan> within <nPeriods> periods and for a rate of interest <nInterest> per period.

debt in period 0 = <nLoan>
debt in period 1 = ((debt in period 0)-<nPayment>)*(1+<nInterest>/100)
debt in period 2 = ((debt in period 1)-<nPayment>)*(1+<nInterest>/100)

etc…

debt in period <nPeriod> = ((debt in period <nPeriod>-1)-<nPayment>)*(1+<nInterest>/100)

 -> has to be 0, so <nPayment> = <nLoan>*(<nInterest>/100)/(1-(1+<nInterest>/100)ˆ(-n))

Examples

       // You get a loan of 5172.56 at a interest rate of 0.5% per
       // month (6% per year).
       // For 5 years, you have to pay back every month

       ? payment( 5172.56, 0.005, 60 ) // --> 100.00

Tests

       payment( 5172.56, 0.0, 60 )   == 86.21
       payment( 5172.56, 0.005, 60 ) == 100.00

Compliance

PAYMENT() is compatible with CT3’s PAYMENT().

Platforms

All

Files

Source is finan.c, library is libct.

Seealso

PV(), FV(), PERIODS(), RATE()

PADRIGHT()

PADRIGHT()

Fills string to a certain length on the right

Syntax

       PADRIGHT( <cString>, <nLength>, [<cChar|nChar>] ) -> cString

Arguments

<cString> The string that is processed. <nLength> The selected new length for <cString>. <cChar|nChar> The character with which the beginning of the <cString> string is filled. The default value is a space, CHR(32).

Returns

The processed <cString> is returned.

Description

PADRIGHT() allows you to pad the end of a character string with characters, in accordance with a length specification. Spaces or any other characters that you choose can be used.

Notes

. The function works like the Harbour LEFT() function when <nLength> is shorter than the length of <cString>. If <nLength> is negative, PADRIGHT() returns a null string. . When the <cCharacter|nCharacter> parameter is not specified, spaces are automatically used for padding.

Examples

       .  The function works like LEFT():
              ? PADRIGHT("123456", 4)              // "1234"
           .  Pad the right with spaces:
              ? PADRIGHT("123456", 8)              // "123456  "
           .  Pad the right with the "." character:
              ? PADRIGHT("123456", 8, ".")         // "123456.."

Compliance

PADRIGHT() is compatible with CT3’s PADRIGHT().

Platforms

All

Files

Source is pad.c, library is libct.

Seealso

PADLEFT()

PADLEFT()

PADLEFT()

Fills string to a certain length on the left

Syntax

       PADLEFT( <cString>, <nLength>, [<cChar|nChar>] ) -> cString

Arguments

<cString> Designates the string that is processed.

<nLength> Designates the new length for <cString>.

<cChar|nChar> Designates the character with which the beginning of the <cString> string is filled. The default value is a space, CHR(32).

Returns

The processed <cString> is returned.

Description

PADLEFT() allows you to pad the beginning of character strings with characters, in accordance with a length specification. Spaces or any other characters you choose can be used.

Notes

. The function works like the Harbour RIGHT() function when <nLength> is shorter than the length of <cString>. If <nLength> is negative, PADLEFT() returns a null string. . When the <cCharacter|nCharacter> parameter is not specified, spaces are automatically used for padding.

Examples

       .  The function works like RIGHT():
          ? PADLEFT("123456", 4)              // "3456"
       .  Pad the left with spaces:
          ? PADLEFT("123456", 8)              // "  123456"
       .  Pad the left with the "." character:
          ? PADLEFT("123456", 8, ".")         // "..123456"

Compliance

PADLEFT() is compatible with CT3’s PADLEFT().

Platforms

All

Files

Source is pad.c, library is libct.

Seealso

PADRIGHT()

NUMTOKEN()

NUMTOKEN()

Onliner

Retrieves the number of tokens in a string

Syntax

       NUMTOKEN( <cString>, [<cTokenizer>], [<nSkipWidth>] ) -> nTokenCount

Arguments

<cString> Designates the string that is passed.

<cDelimiter> Designates the delimiter list used by the passer.

<nSkipWidth> Designates after what number of delimiter characters or sequences to count a token. This is helpful for counting empty tokens. The default value indicates that empty tokens are not taken into account.

Returns

The number of tokens contained in the <cString> is returned.

Description

Use NUMTOKEN() to determine how many words (or tokens) are contained in the character string. The function uses the following list of delimiters as a standard: CHR 32, 0, 9, 10, 13, 26, 32, 138, 141 and the characters , .;:!?/\<<>>()ˆ#&%+-* The list can be replaced by your own list of delimiters, <cDelimiter>. Here are some examples of useful delimiters:

      ---------------------------------------------------------------------
      Description         <cDelimiter>
      ---------------------------------------------------------------------
      Pages               CHR(12)(Form Feed)
      Sentences           ".!?"
      File Names          ":\."
      Numerical strings   ",."
      Date strings        "/."
      Time strings        ":."
      ---------------------------------------------------------------------

The skip value designates the number of characters after which a token is counted again. This also allows empty tokens, like blanks within a string, to be counted.

Examples

       .  A character string is searched using the standard delimiter
          list:
          ? NUMTOKEN("Good Morning!")      // Result: 2
       .  Your own list of delimiters can be specified for particular
          reasons.  Since the delimiter list for the following example only
          contains the characters ".!?", the result is 3.
          ? NUMTOKEN("Yes!  That's it. Maybe not?", ".!?")
       .  This example shows how to count empty tokens.  Parameters
          separated by commas are counted, but some of the parameters are
          skipped.  A token is counted after at least one delimiter (comma):
          String  :=  "one,two,,four"
          ? NUMTOKEN(String, ", ", 1)      // Result: 4

Tests

       numtoken( "Hello, World!" ) ==  2
       numtoken( "This is good. See you! How do you do?", ".!?" ) == 3
       numtoken( "one,,three,four,,six", ",", 1 ) ==  6

Compliance

NUMTOKEN() is compatible with CT3’s NUMTOKEN().

Platforms

All

Files

Source is token1.c, library is libct.

Seealso

TOKEN(), ATTOKEN(), TOKENLOWER(), TOKENUPPER(), TOKENSEP()

NUMAT()

NUMAT()

Number of occurrences of a sequence in a string

Syntax

       NUMAT( <cStringToMatch>, <cString>, [<nIgnore>] ) --> nCount

Arguments

<cStringToMatch> The search string. <cString> The string to search.

<nIgnore> The number of characters that are excluded from the search. The default value ignores none.

Returns

The function returns a value that specifies how frequently the <cStringToMatch> sequence was found in the <cString>.

Description

NUMAT() determines how often a particular <cStringToMatch> appears within <cString>. When you use <nIgnore> you can lock out a number of characters at the beginning of the <cString> and keep them out of the search. The setting for CSETATMUPA() impacts your results. The character string is searched from the left for each occurrence of the <cStringToMatch> string. If CSETATMUPA() is .F., then the search continues after the last character of the found sequence. If CSETATMUPA() is .T., then the search continues after the first character of the found sequence.

Note

. By implementing SETATLIKE(), wildcard characters can be used within the search expression.

Examples

       .  Count from the first position:
              ? NUMAT("ab", "abcdeabc")            // Result: 2
           .  Count from the second position.  <nIgnore> specifies that one
              space is to be skipped:
              ? NUMAT("ab", "abcdeabc", 1)         // Result: 1
           .  This example shows the impact of CSETATMUPA() when counting
              the string "aa" within the <cString> string:
              CSETATMUPA(.F.)                      // Off
              ? NUMAT("aa", "aaaab")               // Result: 2
              CSETATMUPA(.T.)                      // On
              ? NUMAT("aa", "aaaab")               // Result: 3
           .  Examples for the use of SETATLIKE() can be found under the
              corresponding function description.

Compliance

NUMAT() is compatible with CT3’s NUMAT().

Platforms

All

Files

Source is numat.c, library is libct.

Seealso

CSETATMUPA(), SETATLIKE()

NTOCMONTH()

NTOCMONTH()

Find a month name by the number of month

Syntax

       NTOCMONTH( <nMonth> ) -> cMonth

Argument

<nMonth> Designates a month number for which a month name is returned.

Returns

NToCMonth() returns the name that corresponds to the month number.

Description

NToCMonth() determines the month name that corresponds to its month number. January is 1, February is 2, …, December is 12. If a number outside this range is passed, the function returns a null string as a value.

Note

The function’s operation depends on the country specific adaptation of your Harbour compiler. With an English version of Harbour, only English day names are returned.

Example

       In English Harbour returns:
           ? NToCMonth(1)         //"January"
           ? NToCMonth(2)         //"February"
           ? NToCMonth(12)        //"December"
           ? NToCMonth(14)        //""

Compliance

NTOCMONTH() is compatible with CT3’s NTOCMONTH().

Platforms

All

Files

Source is dattime2.prg, library is libct.

Seealso

CTOMONTH()

NTOCDOW()

NTOCDOW()

Find day name by num of day

Syntax

       NTOCDOW( <nDay> ) -> cDay

Argument

<nWeekday> Designates a weekday number from 1 to 7.

Returns

NTOCDOW() returns a name that corresponds to its weekday number.

Description

This function converts a weekday number into the corresponding name. Sunday is 1, Monday is 2, Saturday is 7. If you pass a number outside of this range, the function returns a 0 value. Example In English Harbour returns: ? NTOCDOW(1) // “Sunday” ? NTOCDOW(4) // “Wednesday” ? NTOCDOW(7) // “Saturday” ? NTOCDOW(8) // “”

Note

. Function operation depends on the country-specific adaptation of your Harbour compiler. With an English version of Harbour, only English day names are returned.

Compliance

NTOCDOW() is compatible with CT3’s NTOCDOW().

Platforms

All

Files

Source is dattime2.prg, library is libct.

Seealso

CTODOW()

NTOC()

NTOC()

Converts the numbers in a digit string into a different number base

Syntax

       NTOC( <xNumber>[, <nBase>][,<nLength>][,<cPadChar>] ) -> <cNumber>

Arguments

<xNumber> Corresponds to a decimal number or hexadecimal character string to convert. <nBase> Designates the number system base, from 2 to 36 (inclusive), to use in the result. The default is the decimal system, base 10. <nLength> Designates the length of the string that results. The maximum length is 255. The default is the length required for the conversion. <cPadChar> Designates a pad character to pad the string result on the left. The default value is a space.

Returns

NTOC() returns a character string that contains the conversion result of <nLONG|cHexLONG> into the <nBase> number system.

Description

NTOC() converts a decimal number or hexadecimal string into a number string. The result is a number in base <nBase> or, if <nBase> is not specified, in base 10. Use <nLength> to determine the length of the result string. However, if <nLength> is longer than the length necessary for the result, the result string is padded on the left with spaces or with a character selected with <cPad>.

Note

. If incompatible parameter combinations are specified, NTOC() returns one or more asterisks (*) as a result.

Examples

       .  Convert to base 10:
              ? NTOC (60000)                //"60000"
              ? NTOC (60000, 10, 7)         //"    60000"
           .  Convert to base 2:
              ? NTOC(60000, 2)              // "1110101001100000"
              ? NTOC("FFFF", 2)             // "1111111111111111"
              ? NTOC("30", 2, 8, "0")       // "00110000"
           .  Convert to base 16:
              ? NTOC(43981, 16)             // "ABCD"
           .  Convert to base 36:
              ? NTOC(43981, 36, 4)          // "XXP"
           .  Invalid parameters (overflow):
              ? NTOC("GGGG", 2)             // "*"
              ? NTOC(60000, 10, 3)          // "***"
              ? NTOC(60000, 1, 4)           // "****"

Platforms

All

Files

Source is numconv.prg, library is libct.

Seealso

CTON()

MDY()

MDY()

Returns the date as a string in Month DD, YY or Month DD, YYYY

Syntax

       MDY( [<dDate>] ) -> cDateString

Argument

<dDate> Designates the date from which to create a string. The default is the system date.

Description

Returns the date as a string in Month DD, YY or Month DD, YYYY If dDate is NULL, the system date is used MDY() returns the date in a character string that contains the day, name of month, and year. Harbour SET CENTURY ON/OFF switch determines whether or not the year is displayed in 2 or 4 digits. If the function is called without a parameter, it automatically uses the current system date.

Note

. The returned month name always depends on which Harbour nations module is in use. A German or French version of Harbour returns the appropriate month names, despite its characteristically American display.

Examples

       ? "Today :", DATE(), MDY()
         dDate := CTOD("02/01/89")
         ? dDate, MDY( dDate )

See also

DMY()

Compliance

MDY() is compatible with CT3’s MDY().

Platforms

All

Files

Source is dattime2.prg, library is libct.

Seealso

DMY()