dDate|nMonth can be a date or a month number. If empty uses the system date. If nMonth is a 2, LastDayOM() will not know if it is a leap year or not. If dDate is invalid, returns 0
dDate Designates which date to use to set the system date.
lMode Designates whether the date should also be set in the CMOS-RAM of an AT. The default is do not write (.F.). Note that in Windows platform this adjust is automatic, therefore this parameter is without effect.
Returns
SetDate() returns .T. when the date is successfully set.
Description
When you use this function to set the system date from within your application, all files acquire this date with each write procedure.
Examples
LOCAL dNewDate
// Set the system date in each case; but the hardware clock only
// on an AT:
dNewDate := 0d19910730
IF IsAt()
SetDate( dNewDate, .T. )
ELSE
SetDate( dNewDate )
ENDIF
// Or, more compactly:
SetDate( dNewDate, IsAt() )
cTime Designates a character string that contains the time that is to become the system time.
lMode Designates whether the time should also be set in the CMOS-RAM of an AT. The default is do not write to CMOS-RAM. Note that in Windows platform this adjust is automatic, therefore this parameter is without effect.
Returns
The function returns .T. when the time is set successfully.
Description
When you use this function to convert the time into the system time from within your application, all files acquire this time with each write procedure.
Examples
LOCAL cNewTime
// Set the system time in each case; but the hardware clock only
// on an AT:
cNewTime := "10:20:00"
IF IsAt()
SetTime( cNewTime, .T. )
ELSE
SetTime( cNewTime )
ENDIF
// Or, more compactly:
SetTime( cNewTime, IsAt() )
cTime Designates a character string that contains the time to test.
Returns
TimeValid() returns .T. when cTime is a valid time; or .F. when cTime is an invalid time.
Description
With input that requires time manipulation, writing your own UDF to check time inputs was unavoidable up to now. TimeValid() permits Complete checking of a time designation. You can use this function effectively with a VALID clause within a READ mask.
Note
Note the format for time designations. There must always be two digits for hours, minutes, seconds, and hundredths; otherwise, the time it is regarded as invalid. Valid examples are "12", "12:59", "12:59:59", and "12:59:59:99". By contrast, invalid examples are "24", "12:60", or "12:1", and/or "12:". If you work with time strings that are not completely filled and that you need to check with TimeValid(), then they must be RTrim()-med prior to the use of TimeValid() (see following Examples).
Examples
LOCAL cBegin, GetList := {}
// Using the VALID clause with RTrim(), all valid times are
// accepted, even if no seconds or minutes are specified:
cBegin := Space( 11 )
@ 5, 10 SAY "Please input time for beginning work:";
GET cBegin VALID TimeValid( RTrim( cBegin ) )
READ
// Using a VALID clause without TRIM, hours and minutes must be
// specified, so that TimeValid() can confirm a valid time:
cBegin := Space( 5 )
@ 5, 10 SAY "Please input time for beginning work:" ;
GET cBegin VALID TimeValid( cBegin )
READ
Pauses a specified time in increments of 1/100 seconds
Syntax
WaitPeriod( [<nDelay>] ) → lNotElapsed
Arguments
nDelay Designates the waiting period at initialization in 1/100ths of seconds. Values from 1 to 8, 640, 000 (one day) are possible.
Returns
WaitPeriod() returns .T., if the time span designated at initialization has not elapsed.
Description
This function sets a time span for a DO WHILE loop to run. The function must initialize prior to the loop, since you must specify the nDelay parameter in 1/100th seconds. Subsequently, the function can be implemented without a parameter for additional loop conditions. It returns .T., as long as the designated time span has not yet run out.
Note:
The function notes the status of the internal timer at initialization. From that point on, the initialization should always precede the respective DO WHILE; otherwise, the time delay is incorrect. The passing of midnight (the time resets to the 0 value) is taken into account.
Examples
// Run a loop for 5 seconds:
WaitPeriod( 500 ) // Initialization, 5 seconds
DO WHILE <cond1> .AND. <cond2> .AND. WaitPeriod()
// ...
ENDDO
nOldMode The current or old argument error throwing mode.
Description
All CT3 functions are very compliant in their reaction to wrong parameters. By using the CSetArgErr() function, you can make the library throw an error with the severity nNewMode. It is then up to the error handler to substitute the return value. nNewMode can be one of the severity modes defined in ct.ch:
CT_ARGERR_WHOCARES corresponds to ES_WHOCARES
CT_ARGERR_WARNING corresponds to ES_WARNING
CT_ARGERR_ERROR corresponds to ES_ERROR
CT_ARGERR_CATASTROPHIC corresponds to ES_CATASTROPHIC
CT_ARGERR_IGNORE
The last is the default behaviour and switches any argument error throwing off.
The function Acos() is the inverse function of Cos(). It takes a cosine value and returns the smallest(!) angle whose cosine equals to the argument. The return value is given in radiants (full angle equals 2 * Pi() - see DToR() if you need to convert it into degrees). Note, that nCosine must be between -1 and 1 and that nRadiant is always between 0 and Pi().
The function Asin() is the inverse function of Sin(). It takes a sine value and returns the smallest(!) angle whose sine equals to the argument. The return value is given in radiants (full angle equals 2 * Pi() - see DToR() if you need to convert it into degrees). Note, that nSine must be between -1 and 1 and that nRadiant is always between -Pi() / 2 and Pi() / 2.
The function Atan() is the inverse function of Tan(). It takes a tangent value and returns the smallest(!) angle whose tangent equals to the argument. The return value is given in radiants between -Pi() / 2 and Pi() / 2 (full angle equals 2 * Pi() - see DToR() if you need to convert it into degrees).
nSine the sine of an angle nCosine the cosine of an angle
Returns
nRadiant the angle whose tangent is nSine/nCosine
Description
The function Atn2() is an alternate function for calculating the arcus tangent, Atn2( x, y ) = Atan( x / y). It takes two arguments, the sine and the cosine of the angle that should be calculated. Thus, in contrast to the Atan() function, Atn2() can distinguish whether the sine or the cosine has a negative sign (or both being positive or negative), so that the return value can be between -Pi() and Pi() and covers the full angle. The return value is given in radiants (full angle equals 2 * Pi() - see DToR() if you need to convert it into degrees).
The function Cos() calculates the cosine of an angle whose size is given in radiants (full angle equals 2 * Pi() - see DToR() for angle size given in degrees). A common geometric interpretation of the Cos() function is the ankathede-hypotenuse-ratio of a right-angled triangle.
The function Cosh() calculates the hyperbolic cosine of the argument. In analytical mathematics it is defined as 1 / 2 * ( Exp( nArea ) + Exp( -nArea ) ). A common geometric interpretation of the Cosh() function is the maximum x value of the points in the area with the given size nArea, that is bound by the x axis, a straight line through the point of origin (this one is fixed by the area) and the hyperbola x ^ 2 - y ^ 2 = 1.
The function Cot() calculates the cotangent of an angle whose size is given in radiants (full angle equals 2 * Pi() - see DToR() for angle size given in degrees). A common geometric interpretation of the Cot() function is the ankathede-counterkathede-ratio of a right-angled triangle, or, Cot( x ) = Cos( x ) / Sin( x ) = 1 / Tan( x ).
The function Fact() calculates the faculty to the integer given in nNumber. The faculty is defined as n! = 1*2*...*n and is often used in statistics. Note, that faculties above 21 are too big so that the function must return a -1.
nDeposit amount of money invested per period nInterest rate of interest per period, 1 == 100% nPeriods period count
Returns
nFutureValue Total value of the capital after nPeriods of
paying nDeposit and nInterest interest being paid every period and added to the capital (resulting in compound interest)
Description
FV() calculates the value of a capital after nPeriods periods. Starting with a value of 0, every period, nDeposit (Dollars, Euros, Yens, ...) and an interest of nInterest for the current capital are added for the capital (nInterest=Percent/100). Thus, one gets the non-linear effects of compound interests: value in period 0 = 0 value in period 1 = ((value in period 0)*(1+nInterest/100)) + nDeposit value in period 2 = ((value in period 1)*(1+nInterest/100)) + nDeposit
etc....
value in period nPeriod = ((value in period nPeriod-1)*(1+nInterest/100))< + nDeposit
= nDeposit * sum from i=0 to nPeriod-1 over (1+nInterest/100)^i = nDeposit * ((1+nInterest/100)^n-1) / (nInterest/100)
Examples
// Payment of 1000 per year for 10 years at a interest rate
// of 5 per cent per year
? FV( 1000, 0.05, 10 ) // --> 12577.893
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)
// 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
nLoan amount of money you get from the bank nPayment amount of money you pay back per period nInterest rate of interest per period, 1 == 100%
Returns
nPeriods number of periods you need to pay the loan back
Description
Periods() calculates the number of periods one needs to pay back a loan of nLoan with periodical payments of nPayment 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)
Note, however that in the case of nPayment <= nLoan * ( nInterest / 100 ), one would need infinite time to pay the loan back. The functions does then return -1.
Examples
// You get a loan of 5172.56 at a interest rate of 0.5% per
// month (6% per year).
// You can afford to pay 100 back every month, so you need
? Periods( 5172.56, 100, 0.005 ) // --> 60.0
// months to cancel the loan.
Returns Pi, the perimeter-to-diameter-ratio of a circle
Syntax
Pi() → nPi
Returns
nPi the math constant Pi with maximum precision available
Description
The function Pi() can be used if the constant Pi is needed with maximum precision. One of the most known interpretations of this number is the constant perimeter-to-diameter-ratio of circles.
Examples
// the diameter of a circle-like swimming pool is 3.4 meters, how
// long is the perimeter?
? Str( Pi() * 3.4, 5, 3 ) + " meters" // --> "10.681 meters"
nPayment amount of money paid back per period nInterest rate of interest per period, 1 == 100% nPeriods period count
Returns
nPresentValue Present value of a loan when one is paying back
nDeposit per period at a rate of interest of nInterest per period
Description
PV() calculates the present value of a loan that is paid back in nPeriods payments of nPayment (Dollars, Euros, Yens,...) while the rate of interest is nInterest per period: debt in period 0 = nPresentValue 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)
// You can afford to pay back 100 Dollars per month for 5 years
// at a interest rate of 0.5% per month (6% per year), so instead
// of 6000 Dollars (the amount you will pay back) the bank will pay
// you
? PV( 100, 0.005, 60 ) // --> 5172.56
nLoan amount of money you get from the bank nPayment amount of money you pay back per period nPeriods number of periods you pay the loan back
Returns
nInterest estimated rate of interest per period, 1 == 100%
Description
Rate() calculates the rate of interest per period for the given loan, payment per periods and number of periods. This is done with the same equation used in the Payment() or Periods() function:
However, this equation cannot be solved for nInterest in a "closed" manner, i.e. nInterest = ..., so that the result can only be estimated.
Examples
// You get a loan of 5172.56, pay 100 back every month for
// 5 years (60 months). The effective interest rate per
// period (=month) is
? Rate( 5172.56, 100, 60 ) // --> 0.005
The function RToD() can be used to convert sizes of angles given in radiant (like those returned by the Asin(), Acos() or Atan() functions) to degrees that are commonly used geometry and mechanics.
The function Sign() determines the sign of nNumber. If nNumber is > 0, then Sign(nNumber) returns 1 If nNumber is < 0, then Sign(nNumber) returns -1 If nNumber is == 0, then Sign(nNumber) returns 0
The function Sin() calculates the sine of an angle whose size is given in radiants (full angle equals 2 * Pi() - see DToR() for angle size given in degrees). A common geometric interpretation of the Sin() function is the counterkathede-hypotenuse-ratio of a right-angled triangle.
The function Sinh() calculates the hyperbolic sine of the argument. In analytical mathematics it is defined as 1 / 2 * ( Exp( nArea ) - Exp( -nArea ) ). A common geometric interpretation of the Sinh() function is the maximum y value of the points in the area with the given size nArea, that is bound by the x axis, a straight line through the point of origin (this one is fixed by the area) and the hyperbola x ^ 2 - y ^ 2 = 1.
The function Tan() calculates the tangent of an angle whose size is given in radiants (full angle equals 2 * Pi() - see DToR() for angle size given in degrees). A common geometric interpretation of the Tan() function is the counterkathede-ankathede-ratio of a right-angled triangle, or, Tan( x ) = Sin( x ) / Cos( x ).
cFloatingPointNumber Designate a string that contains a Harbour number in floating point format. ATTENTION: different implementations or platforms of Harbour, they could produce different format in the string returned by FToC().
Returns
CToF() return the floating point number that corresponds to the string passed.
Description
Character strings created with FToC() or XToC() are convert into Harbour floating point number
nFloatingPointNumber Designate any Harbour number.
Returns
FToC() return a string with the size of DOUBLE. ATTENTION: different implementations or platforms of Harbour, they could produce different format in the string returned by FToC().
Description
Harbour internal numbers in Floating Point are stored in data type DOUBLE. FToC() returns these bits as an string. In this way, numbers con be saved more compactly.
nDegreeFahrenheit temperature in degree Fahrenheit
Returns
nDegreeCelsius temperate in degree Celsius
Description
Celsius() converts temperature values measured in the Fahrenheit scale to the Celsius scale.
Examples
// melting point of water in standard conditions
? Celsius( 32.0 ) // --> 0.0
// boiling point of water in standard conditions
? Celsius( 212.0 ) // --> 100.0
nDegreeFahrenheit temperature in degree Fahrenheit
Description
Fahrenheit() converts temperature values measured in the Celsius scale to the Fahrenheit scale.
Examples
// melting point of water in standard conditions
? Fahrenheit( 0.0 ) // --> 32.0
// boiling point of water in standard conditions
? Fahrenheit( 100.0 ) // --> 212.0
[@]cString is the string that should be edited nValue is a integer value that should be added to the
ASCII value of the character at the nPositionth position
[nPosition] is the position of the character that should be edited.
If not supplied, the last character of [@]cString is edited.
[lCarryOver] NEW: is set to .T. if the substring from position 1 to
position nPosition should be treated as an integer written to the base 256. Thus, the addition of nValue can affect to whole substring (see EXAMPLES). Default is .F., the original behaviour of this function.
Returns
The edited string is returned. The return value can be suppressed by using the CSetRef() function. The string must then be passed by reference [@].
Description
AddAscii() can be used to add or subtract integer values from ASCII values in a string. The new lCarryOver parameter allows to treat a string as an integer written to the base 256. Since nValue is limited to a signed long, only substrings 4 characters long can be affected by one AddAscii() call. If the length of [@]cString is smaller than nPosition, the string remains unchanged. The same happens, if uninterpretable parameters are passed to this function.
Examples
// Add 32 to the ASCII value of the character at the last position
// in the string
? AddAscii( "SmitH", 32 ) // --> "Smith"
Status
Ready
Compliance
AddAscii() is compatible with CT3's AddAscii(). A new, 4th, parameter has been added who defaults to the original behaviour if omitted.
cStringToMatch is the substring scanned for cString is the scanned string [nCounter] determines how many occurrences are of
cStringToMatch in cString are searched Default: search last occurrence
[nIgnore] determines how many character from the start
should be ignored in the search Default: 0
Returns
cRestString the portion of cString after the nCounterth
occurrence of cStringToMatch in cString If such a rest does not exist, an empty string is returned.
Description
This function scans cString for cStringToMatch. After the nCounterth match (or the last one, depending on the value of nCounter) has been found, the portion of cString after that match will be returned. If there aren't enough matches or the last match is identical to the end of cString, an empty string will be returned. After a match has been found, the function continues to scan after that match if the CSetAtMupa() switch is turned off, with the second character of the matched substring otherwise. The function will also consider the settings of SetAtLike().
Examples
? AfterAtNum( "!", "What is the answer ? 4 ! 5 !" ) // --> ""
? AfterAtNum( "!", "What is the answer ? 4 ! 5 ?" ) // --> " 5 ?"
// TODO: add some examples here with CSetAtMupa() and SetAtLike()
calculate the sum of the ASCII values of the characters in a string
Syntax
AsciiSum( <cString> ) → nAsciiSum
Arguments
cString the string to be processed
Returns
nAsciiSum sum of the ASCII values in cString
Description
The AsciiSum() function sums up the ASCII values of the characters in cString. Be aware that the function is not position sensitive, i.e. a change of position of a certain character in the string does not change the ASCII sum.
cString is the processed string [nPosition] is an optional position within cString
Default: last position in cString
Returns
nAsciiValue the ASCII value of the character at the specified
position
Description
The AscPos() function returns the ASCII value of the character that can be found at the position nPosition in cString. If nPosition is larger than the length of cString, 0 is returned.
cStringToMatch is the sequence to be adjusted within cStringcString is the string that contains cStringToMatchnAdjustPosition specifies the position to that cStringToMatch
will be adjusted
[nCounter] specifies which occurrence of cStringToMatch
in cString is to be adjusted Default: last occurrence
[nIgnore] specifies how many characters should be omitted
in the scan
[nFillChar|cFillChar] specifies the character that is used for the
adjustment
Returns
cString the changed string
Description
TODO: add a description, some examples and tests here
cStringToMatch is the substring scanned for cString is the scanned string [nCounter] determines how many occurrences are of
cStringToMatch in cString are searched Default: search last occurrence
[nIgnore] determines how many character from the start
should be ignored in the search Default: 0
Returns
nPosition the position of the nCounterth
occurrence of cStringToMatch in cString. If such an occurrence does not exist, 0 is returned.
Description
This function scans cString for cStringToMatch. After the nCounterth match (or the last one, depending on the value of nCounter) has been found, the position of that match will be returned. If there aren't enough matches or there is no last match, 0 will be returned. After a match has been found, the function continues to scan after that match if the CSetAtMupa() switch is turned off, with the second character of the matched substring otherwise. The function will also consider the settings of SetAtLike().
Examples
? AtNum( "!", "What is the answer ? 4 ! 5 !" ) // --> 28
? AtNum( "!", "What is the answer ? 4 ! 5 ?" ) // --> 24
<TODO: add some examples here with CSetAtMupa() and SetAtLike()>
cStringToMatch is the substring searched for in cStringcString is the processed string cReplacement is the replacement for sequences found [nCounter] specifies the number of replacements
Default: last occurrence
[lMode] if set to .T., only the nCounterth sequence
of cStringToMatch will be replaced, else all sequences will be replaced. Default: .F.
[nIgnore]) specifies how many characters in cString from
the beginning should be ignored by the function Default: 0
Returns
cString
Description
The AtRepl() function searches and replaces sequences in a string. First, the function ignores the first nIgnore characters of cString. Then, if lMode is set to .T., it searches for the nCounterth occurrence of cStringToMatch in cString. If successful, the sequence will be replaced with cReplacement. If lMode is set to .F., the same search is performed, but EVERY occurrence of cStringToMatch till the nCounterth (inclusive) will be replaced with cReplacement. Note that, in this case, the replacements are performed even if the nCounterth occurrence does not exist. By using the CSetAtMupa() switch you can decide whether the function restarts searching after a found sequence of after the first character of that sequence. The function allows the use of wildcards in cStringToMatch and looks for the settings of SetAtLike().
[nTokenCount] specifies the count of the token whose
position should be calculated Default: last token
[nSkipWidth] specifies the maximum number of successive
tokenizing characters that are combined as one token stop, e.g. specifying 1 can yield to empty tokens Default: 0, any number of successive tokenizing characters are combined as one token stop
Returns
nPosition The start position of the specified token or
0 if such a token does not exist in cString.
Description
The AtToken() function calculates the start position of the nTokenCountth token in cString. By setting the new nSkipWidth parameter to a value different than 0, you can specify how many tokenizing characters are combined at most to one token stop. Be aware that this can result to empty tokens there the start position is not defined clearly. Then, AtToken() returns the position there the token would start if its length is larger than 0. To check for empty tokens, simply look if the character at the returned position is within the tokenizer list.
Examples
AtToken( "Hello, World!" ) // --> 8 (empty strings after tokenizer are not a token !)
Status
Ready
Compliance
AtToken() is compatible with CT3's AtToken(), but has an additional 4th parameter to let you specify a skip width equal to that in the Token() function.
cStringToMatch is the substring scanned for cString is the scanned string [nCounter] determines how many occurrences are of
cStringToMatch in cString are searched Default: search last occurrence
[nIgnore] determines how many character from the start
should be ignored in the search Default: 0
Returns
cRestString the portion of cString before the nCounterth
occurrence of cStringToMatch in cString If such a string does not exist, an empty string is returned.
Description
This function scans cString for cStringToMatch. After the nCounterth match (or the last one, depending on the value of nCounter) has been found, the portion of cString before that match will be returned. If there aren't enough matches or the last match is identical to the start of cString (i.e. the last match is the first match), an empty string will be returned. After a match has been found, the function continues to scan after that match if the CSetAtMupa() switch is turned off, with the second character of the matched substring otherwise. The function will also consider the settings of SetAtLike().
Examples
? BeforAtNum( "!", "What is the answer ? 4 ! 5 !" ) // --> "What is the answer ? 4 ! 5 "
? BeforAtNum( "!", "What is the answer ? 4 ! 5 ?" ) // --> "What is the answer ? 4 "
<TODO: add some examples here with CSetAtMupa() and SetAtLike()>
The CharAdd() function constructs a new string from the two strings passed as parameters. To do this, it adds the ASCII values of the corresponding characters of both strings and places a character in the resulting string whose ASCII value equals to that sum (modulo 256). If the first string is passed by reference, the resulting string is stored in cString1, too. By setting the CSetRef()-switch to .T., the return value can be omitted. If cString2 is shorter than cString1 and the last character of cString2 has been processed, the function restarts with the first character of cString2.
Combine corresponding ASCII value of two strings with bitwise AND
Syntax
CharAnd( <[@]cString1>, <cString2> ) → cAndString
Arguments
[@]cString1 first string cString2 second string
Returns
cAndString string with bitwise AND combined ASCII values
Description
The CharAnd() function constructs a new string from the two strings passed as parameters. To do this, it combines the ASCII values of the corresponding characters of both strings with a bitwise AND-operation and places a character in the resulting string whose ASCII value equals to the result of that operation. If the first string is passed by reference, the resulting string is stored in cString1, too. By setting the CSetRef()-switch to .T., the return value can be omitted. If cString2 is shorter than cString1 and the last character of cString2 has been processed, the function restarts with the first character of cString2.
[cString] is the string for whom the function generates a
character histogram Default: "" (empty string)
Returns
aCharacterCount an array with 256 elements where the nth element
contains the count of character #(n-1) in cString
Description
The CharHist() function generates a character histogram of those characters that are contained in cString. This histogram is stored in an 256-element array where the nth element contains the count of ASCII character #(n-1) in cString.
[cString] is the string for whom the function generates a list
of all characters Default: "" (empty string)
Returns
cCharacterList a list of the characters in cString
Description
The CharList() function generates a list of those characters that are contained in cString. This list can contain each character only once, so that its maximum length is 256. The list lists those characters first that are occurring in cString first.
[@]cString is the string that should be mirrored [lDontMirrorSpaces] if set to .T., spaces at the end of
cString will not be mirrored but kept at the end Default: .F., mirror the whole string
Returns
cMirroredString the mirrored string
Description
The CharMirr() function mirrors a string, i.e. the first character will be put at the end, the second at the last but one position etc.. One can use this function for index searches, but then, the spaces at the end of the string should not be mirrored. One can omit the return value of the function by setting the CSetRef() switch to .T., but cString must then be passed by reference to get a result.
cString1 String that will be mixed with the characters from cString2 [cString2] String whose characters will be mixed with the one from
cString1. Default: " " (string with one space char)
Returns
cMixedString Mixed string
Description
The CharMix() function mixes the strings cString1 and cString2. To do this it takes one character after the other alternatively from cString1 and cString2 and puts them in the output string. This procedure is stopped when the end of cString1 is reached. If cString2 is shorter than cString1, the function will start at the begin of cString2 again. If on the other hand cString2 is longer than cString1, the surplus characters will be omitted.
Generates a list of all characters not contained in a string
Syntax
CharNoList( [<cString>] ) → cCharacterList
Arguments
[cString] is the string for whom the function generates a list
of all characters not contained in that string Default: "" (empty string)
Returns
cCharacterList a list of the characters that are not contained in cString
Description
The CharNoList() function generates a list of those characters that are not contained in cString. This list can contain each character only once, so that its maximum length is 256. The list is alphabetically sorted.
Process each character in a string with bitwise NOT operation
Syntax
CharNot( <[@]cString> ) → cNotString
Arguments
[@]cString string to be processed
Returns
cNotString string with bitwise negated characters
Description
The CharNot() function constructs a new string from the string passed as parameter. To do this, it performs a bitwise NOT operation to the characters of the string and places a character in the resulting string whose ASCII value equals to the result of that operation. It can be easily seen that the resulting ASCII-value equals 255 minus input ASCII value. If the string is passed by reference, the resulting string is stored in cString, too. By setting the CSetRef()-switch to .T., the return value can be omitted.
[cCharactersToReduce] specifies the characters the multiple
occurrences of which should be reduced to one Default: All characters.
cString specifies the processed string
Returns
cReducedString the string with the reduced occurrences
Description
The CharOne() function reduces multiple occurrences of characters in cString to a single one. It is important to note that the multiple occurrences must occur directly one behind the other. This behaviour is is in contrast to the CharList() function.
Examples
? CharOne( "122333a123" ) // "123a123"
? CharOne( "A B CCCD" ) // "A B CD"
? CharOne( " ", "A B A B" ) // "A B A B"
? CharOne( "o", "122oooB12o" ) // "122oB12o"
cThisCharactersOnly specifies the characters that must not be
deleted in cString.
cString is the string that should be processed
Returns
cReducedString A string with all characters deleted but those
specified in cThisCharactersOnly.
Description
The CharOnly() function calculates the intersectional set of two strings. To do this, it deletes all characters from cString that do not appear in cThisCharacterOnly.
Combine corresponding ASCII value of two strings with bitwise OR
Syntax
CharOr( <[@]cString1>, <cString2> ) → cOrString
Arguments
[@]cString1 first string cString2 second string
Returns
cOrString string with bitwise OR combined ASCII values
Description
The CharOr() function constructs a new string from the two strings passed as parameters. To do this, it combines the ASCII values of the corresponding characters of both strings with a bitwise OR-operation and places a character in the resulting string whose ASCII value equals to the result of that operation. If the first string is passed by reference, the resulting string is stored in cString1, too. By setting the CSetRef()-switch to .T., the return value can be omitted. If cString2 is shorter than cString1 and the last character of cString2 has been processed, the function restarts with the first character of cString2.
cSearchString is a string of characters that should be replaced [@]cString is the processed string cReplaceString is a string of characters that replace the one
of cSearchString
[lMode] sets the replacement method (see description)
Default: .F.
Returns
cString the processed string
Description
The CharRepl() function replaces certain characters in cString with others depending on the setting of lMode. If lMode is set to .F., the function takes the characters of cSearchString one after the other, searches for them in cString and, if successful, replaces them with the corresponding character of cReplaceString. Be aware that if the same characters occur in both cSearchString and cReplaceString, the character on a certain position in cString can be replaced multiple times. if lMode is set to .T., the function takes the characters in cString one after the other, searches for them in cSearchString and, if successful, replaces them with the corresponding character of cReplaceString. Note that no multiple replacements are possible in this mode. If cReplaceString is shorter than cSearchString, the last character of cReplaceString is used as corresponding character for the the "rest" of cSearchString. One can omit the return value by setting the CSetRef() switch to .T., but then one must pass cString by reference to get the result.
[@]cString string to be processed nBitsToRLL number of bit positions to be rolled to the left
Returns
cRLLString string with bitwise rolled left characters
Description
The CharRll() function constructs a new string from the string passed as parameter. To do this, it performs a bitwise ROLL LEFT (RLL) operation to the characters of the string and places a character in the resulting string whose ASCII value equals to the result of that operation. Be aware that, in contrast to CharShl(), bits rolled out on the left are put in again on the right. If the string is passed by reference, the resulting string is stored in cString, too. By setting the CSetRef()-switch to .T., the return value can be omitted.
[@]cString string to be processed nBitsToRLR number of bit positions to be rolled to the right
Returns
cRLRString string with bitwise rolled right characters
Description
The CharRlr() function constructs a new string from the string passed as parameter. To do this, it performs a bitwise ROLL RIGHT (RLR) operation to the characters of the string and places a character in the resulting string whose ASCII value equals to the result of that operation. Be aware that, in contrast to CharShr(), bits rolled out on the right are put in again on the left. If the string is passed by reference, the resulting string is stored in cString, too. By setting the CSetRef()-switch to .T., the return value can be omitted.
[@]cString string to be processed nBitsToSHL number of bit positions to be shifted to the left
Returns
cSHLString string with bitwise shifted left characters
Description
The CharShl() function constructs a new string from the string passed as parameter. To do this, it performs a bitwise SHIFT LEFT (SHL) operation to the characters of the string and places a character in the resulting string whose ASCII value equals to the result of that operation. Be aware that bits shifted out of the byte are lost. If you need a bit rotation, use the CharRll() function instead. If the string is passed by reference, the resulting string is stored in cString, too. By setting the CSetRef()-switch to .T., the return value can be omitted.
[@]cString string to be processed nBitsToSHR number of bit positions to be shifted to the right
Returns
cSHRString string with bitwise shifted right characters
Description
The CharShr() function constructs a new string from the string passed as parameter. To do this, it performs a bitwise SHIFT RIGHT (SHR) operation to the characters of the string and places a character in the resulting string whose ASCII value equals to the result of that operation. Be aware that bits shifted out of the byte are lost. If you need a bit rotation, use the CharRlr() function instead. If the string is passed by reference, the resulting string is stored in cString, too. By setting the CSetRef()-switch to .T., the return value can be omitted.
Generates a sorted list of all characters in a string
Syntax
CharSList( [<cString>] ) → cSortedCharacterList
Arguments
[cString] is the string for whom the function generates a
sorted list of all characters Default: "" (empty string)
Returns
cSortedCharacterList a sorted list of the characters in cString
Description
The CharList() function generates a sorted list of those characters that are contained in cString. This list can contain each character only once, so that its maximum length is 256. The function gives the same result as CharSort( CharList( cString ) )
Examples
? CharSList( "Hello World !" ) // --> " !HWdelor"
Status
Ready
Compliance
CharSList() is only available in Harbour's CT3 library.
[@]cString is the string that should be processed [nElementLength] specifies the length of the elements that
should be sorted Default: 1
[nCompareLength] specifies how many characters within one
element should be used for comparison Default: nElementLength
[nIgnoreCharacters] specifies the number of characters at the
beginning of cString that should be ignored in the sort process Default: 0
[nElementOffset] specifies the offset of the comparison string
within a element Default: 0
[nSortLength] specifies how many characters in cString,
starting from the nIgnoreCharacters position, should be sorted Default: hb_BLen( cString ) - nIgnoreCharacters
[lDescending]) specifies whether the process should
sort descending or not
Returns
cSortedString the string resulting from the sort process
Description
The CharSort() function sorts the characters within a string cString. With the parameters nIgnoreCharacters and nSortLength, you can determine that only the substring from position nIgnoreCharacters+1 to position nIgnoreCharacters+nSortLength within cString should be sorted. The sorting algorithm is determined with the other parameters. nElementLength specifies the length of one element, i.e. there are nSortLength/nElementLength elements that are sorted. Note that surplus characters are not sorted but stay at their position. To do the sorting, the function uses the Quicksort algorithm implemented in the C-lib qsort() function. This algorithm needs to know how to compare and order two elements. This is done by comparing the ASCII values of a substring within each element. This substring is determined by the parameters nElementOffset and nCompareLength and the order by lDescending. By setting the CSetRef() switch to .T., one can omit the return value of the function, but one must then pass cString by reference.
Subtracts corresponding ASCII value of two strings
Syntax
CharSub( <[@]cString1>, <cString2>) → cSubString
Arguments
[@]cString1 first string cString2 second string
Returns
cSubString string with subtracted ASCII values
Description
The CharSub() function constructs a new string from the two strings passed as parameters. To do this, it subtracts the ASCII values of the corresponding characters of both strings and places a character in the resulting string whose ASCII value equals to that difference (modulo 256). If the first string is passed by reference, the resulting string is stored in cString1, too. By setting the CSetRef()-switch to .T., the return value can be omitted. If cString2 is shorter than cString1 and the last character of cString2 has been processed, the function restarts with the first character of cString2.
cSwappedString a string where neighbour characters are swapped
Description
The CharSwap() function loops through cString in steps of two characters and exchanges the characters from the odd and the even positions. By setting the CSetRef() switch to .T., one can omit the return value of this function, but one must then pass cString by reference.
Combine corresponding ASCII value of two strings with bitwise XOR
Syntax
CharXor( <[@]cString1>, <cString2> ) → cXOrString
Arguments
[@]cString1 first string cString2 second string
Returns
cXOrString string with bitwise XOR combined ASCII values
Description
The CharXor() function constructs a new string from the two strings passed as parameters. To do this, it combines the ASCII values of the corresponding characters of both strings with a bitwise XOR-operation and places a character in the resulting string whose ASCII value equals to the result of that operation. If the first string is passed by reference, the resulting string is stored in cString1, too. By setting the CSetRef()-switch to .T., the return value can be omitted. If cString2 is shorter than cString1 and the last character of cString2 has been processed, the function restarts with the first character of cString2.
Examples
// easy encryption
? CharXor( "This is top secret !", "My Password" ) // --> <encrypted sentence>
Thus, these functions allow to pass the string by reference @ to the function so that it may not be necessary to return the transformed string. By calling CSetRef( .T. ), the above mentioned functions return the value .F. instead of the transformed string if the string is passed by reference to the function. The switch is turned off (.F.) by default.
cStaticTokenEnvironment a binary string encoding a TE
Returns
cOldStaticEnvironment a string encoding the old global TE
Description
The RestToken() function restores the global TE to the one encoded in cStaticTokenEnvironment. This can either be the return value of SaveToken() or the value stored in the 4th parameter in a TokenInit() call.
cStaticTokenEnvironment a binary string encoding the global TE
Description
The SaveToken() function can be used to store the global TE for future use or when two or more incremental tokenizers must the nested. Note however that the latter can now be solved with locally stored token environments.
[nMode] CT_SETATLIKE_EXACT - characters are compared exactly
CT_SETATLIKE_WILDCARD - characters are compared using
a wildcard character
The default value is CT_SETATLIKE_EXACT.
[[@]cWildcard] determines the character that is subsequently used
as a wildcard character for substring scanning. The default value is "?". NEW: If this parameter is passed by reference @, the current wildcard character is stored in cWildcard.
Returns
nOldMode old (if nMode is a numeric value) or
current state of the switch
Description
In the following CT3 functions, strings are compared on a character base:
With the SetAtLike() function, one can determine when characters are considered to match within these functions. If CT_SETATLIKE_WILDCARD is set (e.g. "?"), then "?" matches every other character.
nMode can be one of the following values that are defined in ct.ch:
CT_SETATLIKE_EXACT CT_SETATLIKE_WILDCARD
Status
Ready
Compliance
This function is fully CT3 compatible, but allows to pass the second parameter by reference so that the current wildcard character can be determined.
cString1 string at the "starting point" of the transformation process, default is "" cString2 string at the "end point" of the transformation process, default is "" nReplacementPenalty penalty points for a replacement of one character, default is 3 nDeletionPenalty penalty points for a deletion of one character, default is 6 nInsertionPenalty penalty points for an insertion of one character, default is 1
Returns
nDistance penalty point sum of all operations needed to transform cString1 to cString2
Description
The StrDiff() functions calculates the so called "Edit" or "Levensthein" distance of two strings. This distance is a measure for the number of single character replace/insert/delete operations (so called "point mutations") required to transform cString1 into cString2 and its value will be the smallest sum of the penalty points of the required operations.
Be aware that this function is both quite time - O( hb_BLen( cString1 ) * hb_BLen( cString2 ) ) - and memory consuming - O( ( hb_BLen( cString1 ) + 1 ) * ( hb_BLen( cString2 ) + 1 ) * sizeof( int ) ) - so keep the strings as short as possible. E.g., on common 32-bit systems ( sizeof( int ) == 4 ), calling StrDiff() with two strings of 1024 bytes in length will consume 4 MiB of memory. To not impose unneeded restrictions, the function will only check if ( hb_BLen( cString1 ) + 1 ) * ( hb_BLen( cString2 ) + 1 ) * sizeof( int ) <= UINT_MAX, although allocating UINT_MAX bytes will not work on most systems. If this simple check fails, -1 is returned.
Also, be aware that there can be an overflow when the penalty points are summed up: Assuming that the number of transformation operations is in the order of Max( hb_BLen( cString1 ), hb_BLen( cString2 ) ), the penalty point sum, that is internally stored in an "int" variable, is in the order of ( Max( hb_BLen( cString1 ), hb_BLen( cString2 ) ) * Max( nReplacementPenalty, nDeletionPenalty, nInsertionPentaly ). The StrDiff() does not do an overflow check due to time performance reasons. Future versions of StrDiff() could use a type different to "int" to store the penalty point sum to save memory or to avoid overflows.
The function is aware of the settings done by SetAtLike(), that means that the wildcard character is considered equal to ALL characters.
Examples
? StrDiff( "ABC", "ADC" ) // 3, one character replaced
? StrDiff( "ABC", "AEC" ) // 3, ditto
? StrDiff( "CBA", "ABC" ) // 6, two characters replaced
? StrDiff( "ABC", "AXBC" ) // 1, one character inserted
? StrDiff( "AXBC", "ABC" ) // 6, one character removed
? StrDiff( "AXBC", "ADC" ) // 9, one character removed and one replaced
[nTokenCount] specifies the count of the token that
should be extracted Default: last token
[nSkipWidth] specifies the maximum number of successive
tokenizing characters that are combined as one token stop, e.g. specifying 1 can yield to empty token Default: 0, any number of successive tokenizing characters are combined as one token stop
[@cPreTokenSep] If given by reference, the tokenizer before
the actual token will be stored
[@cPostTokenSep] If given by reference, the tokenizer after
the actual token will be stored
Returns
cToken the token specified by the parameters given above
Description
The Token() function extracts the nTokenCountth token from the string cString. In the course of this, the tokens in the string are separated by the character(s) specified in cTokenizer. The function may also extract empty tokens, if you specify a skip width other than zero. Be aware of the new 5th and 6th parameter there the Token() function stores the tokenizing character before and after the extracted token. Therefore, additional calls to the TokenSep() function are not necessary.
Token() is compatible with CT3's Token(), but two additional parameters have been added there the Token() function can store the tokenizers before and after the current token.
lSeparatorPositionBehindToken.T., if TokenAt() should return
the position of the separator character BEHIND the token. Default: .F., return start position of a token.
nToken a token number @cTokenEnvironment a token environment
Returns
nPosition
Description
The TokenAt() function is used to retrieve the start and end position of the tokens in a token environment. Note however that the position of last character of a token is given by TokenAt( .T. ) - 1 !!
If the 2nd parameter, nToken is given, TokenAt() returns the positions of the nTokenth token. Otherwise the token pointed to by the TE counter, i.e. the token that will be retrieved by TokenNext()NEXT is used.
If the parameter @cTokenEnvironment is supplied (must be by reference), the information from this token environment is used, otherwise the global TE is used.
Examples
LOCAL cString := "The quick brown fox jumps over the lazy dog"
TokenInit( cString ) // initialize a TE
DO WHILE ! TokenEnd()
? "From", TokenAt(), "to", TokenAt( .T. ) - 1
? TokenNext( cString ) // get all tokens successively
ENDDO
? TokenNext( cString, 3 ) // get the 3rd token, counter will remain the same
TokenExit() // free the memory used for the global TE
Status
Ready
Compliance
TokenAt() is compatible with CT3's TokenAt(), but there are two additional parameters featuring local token environments and optional access to tokens.
Check whether additional tokens are available with TokenNext()
Syntax
TokenEnd( [<@cTokenEnvironment>] ) → lTokenEnd
Arguments
@cTokenEnvironment a token environment
Returns
lTokenEnd.T., if additional tokens are available
Description
The TokenEnd() function can be used to check whether the next call to TokenNext() would return a new token. This cannot be decided with TokenNext() alone, since an empty token cannot be distinguished from a "no more" tokens. If the parameter @cTokenEnvironment is supplied (must be by reference), the information from this token environment is used, otherwise the global TE is used. With a combination of TokenEnd() and TokenNext(), all tokens from a string can be retrieved successively (see example).
Examples
TokenInit( "a.b.c.d", ".", 1 ) // initialize global TE
DO WHILE ! TokenEnd()
? TokenNext( "a.b.c.d" ) // get all tokens successively
ENDDO
Status
Ready
Compliance
TokenEnd() is compatible with CT3's TokenEnd(), but there are is an additional parameter featuring local token environments.
lStaticEnvironmentReleased.T., if global token environment is successfully released
Description
The TokenExit() function releases the memory associated with the global token environment. One should use it for every TokenInit() using the global TE. Additionally, TokenExit() is implicitly called when the thread or application ends.
Examples
LOCAL cString := "The quick brown fox jumps over the lazy dog"
TokenInit( cString ) // initialize a TE
DO WHILE ! TokenEnd()
? TokenNext( cString ) // get all tokens successively
ENDDO
? TokenNext( cString, 3 ) // get the 3rd token, counter will remain the same
TokenExit() // free the memory used for the global TE
Status
Ready
Compliance
TokenExit() is a new function in Harbour's CT3 library.
nSkipWidth specifies the maximum number of successive
tokenizing characters that are combined as one token stop, e.g. specifying 1 can yield to empty token Default: 0, any number of successive tokenizing characters are combined as one token stop
@cTokenEnvironment is a token environment stored in a binary
encoded string
Returns
lState success of the initialization
Description
The TokenInit() function initializes a token environment. A token environment is the information about how a string is to be tokenized. This information is created in the process of tokenization of the string cString - equal to the one used in the Token() function with the help of the cTokenizer and nSkipWidth parameters.
This token environment can be very useful when large strings have to be tokenized since the tokenization has to take place only once whereas the Token() function must always start the tokenizing process from scratch.
Unlike CT3, this function provides two mechanisms of storing the resulting token environment. If a variable is passed by reference as 4th parameter, the token environment is stored in this variable, otherwise the global token environment is used. Do not modify the token environment string directly !
Additionally, a counter is stored in the token environment, so that the tokens can successively be obtained. This counter is first set to 1. When the TokenInit() function is called without a string a tokenize, the counter of either the global environment or the environment given by reference in the 4th parameter is rewind to 1.
Additionally, unlike CT3, TokenInit() does not need the string cString to be passed by reference, since one must provide the string in calls to TokenNext() again.
Examples
TokenInit( cString ) // tokenize the string <cString> with default
// rules and store the token environment globally
// and eventually delete an old global TE
TokenInit( @cString ) // no difference in result, but eventually faster,
// since the string must not be copied
TokenInit() // rewind counter of global TE to 1
TokenInit( "1,2,3", "," , 1 ) // tokenize constant string, store in global TE
TokenInit( cString, , 1, @cTE1 ) // tokenize cString and store TE in
// cTE1 only without overriding global TE
TokenInit( cString, , 1, cTE1 ) // tokenize cString and store TE in
// GLOBAL TE since 4th parameter is
// not given by reference !!!
TokenInit( ,,, @cTE1 ) // set counter in TE stored in cTE1 to 1
Status
Ready
Compliance
TokenInit() is compatible with CT3's TokenInit(), but there is an additional parameter featuring local token environments.
[nSkipWidth] specifies the maximum number of successive
tokenizing characters that are combined as one token stop, e.g. specifying 1 can yield to empty token Default: 0, any number of successive tokenizing characters are combined as one token stop
Returns
cString the string with the lowercased tokens
Description
The TokenLower() function changes the first letter of tokens in cString to lower case. To do this, it uses the same tokenizing mechanism as the Token() function. If TokenLower() extracts a token that starts with a letter, this letter will be changed to lower case. You can omit the return value of this function by setting the CSetRef() switch to .T., but you must then pass cString by reference to get the result.
Examples
? TokenLower( "Hello, World, here I am!" ) // "hello, world, here i am!"
? TokenLower( "Hello, World, here I am!",, 3 ) // "hello, world, here I am!"
? TokenLower( "Hello, World, here I am!", ",", 3 ) // "hello, World, here I am!"
? TokenLower( "Hello, World, here I am!", " W" ) // "hello, World, here i am!"
Status
Ready
Compliance
TokenLower() is compatible with CT3's TokenLower(), but a new 4th parameter, nSkipWidth has been added for synchronization with the the other token functions.
[@]cString the processed string nToken a token number @cTokenEnvironment a token environment
Returns
cToken a token from cString
Description
With TokenNext(), the tokens determined with the TokenInit() functions can be retrieved. To do this, TokenNext() uses the information stored in either the global token environment or the local one supplied by cTokenEnvironment. Note that, is supplied, this 3rd parameter has always to be passed by reference.
If the 2nd parameter, nToken is given, TokenNext() simply returns the nTokenth token without manipulating the TE counter. Otherwise the token pointed to by the TE counter is returned and the counter is incremented by one. Like this, a simple loop with TokenEnd() can be used to retrieve all tokens of a string successively.
Note that cString does not have to be the same used in TokenInit(), so that one can do a "correlational tokenization", i.e. tokenize a string as if it was another! E.G. using TokenInit() with the string "AA, BBB" but calling TokenNext() with "CCCEE" would give first "CC" and then "EE" (because "CCCEE" is not long enough).
Examples
LOCAL cString := "The quick brown fox jumps over the lazy dog"
// default behaviour
TokenInit( cString ) // initialize a TE
DO WHILE ! TokenEnd()
? TokenNext( cString ) // get all tokens successively
ENDDO
? TokenNext( cString, 3 ) // get the 3rd token, counter will remain the same
TokenExit() // free the memory used for the global TE
Status
Ready
Compliance
TokenNext() is compatible with CT3's TokenNext(), but there are two additional parameters featuring local token environments and optional access to tokens.
nNumberofTokens number of tokens in the token environment
Description
The TokenNum() function can be used to retrieve the total number of tokens in a token environment. If the parameter @cTokenEnvironment is supplied (must be by reference), the information from this token environment is used, otherwise the global TE is used.
Examples
TokenInit( "a.b.c.d", ".", 1 ) // initialize global TE
? TokenNum() // --> 4
Status
Ready
Compliance
TokenNum() is a new function in Harbour's CT3 library.
Retrieves the token separators of the last Token() call
Syntax
TokenSep( [<lMode>] ) → cSeparator
Arguments
[lMode] if set to .T., the token separator BEHIND the token
retrieved from the Token() call will be returned. Default: .F., returns the separator BEFORE the token
Returns
Depending on the setting of lMode, the separating character of the the token retrieved from the last Token() call will be returned. These separating characters can now also be retrieved with the Token() function.
Description
When one does extract tokens from a string with the Token() function, one might be interested in the separator characters that have been used to extract a specific token. To get this information you can either use the TokenSep() function after each Token() call, or use the new 5th and 6th parameter of the Token() function.
[nSkipWidth] specifies the maximum number of successive
tokenizing characters that are combined as one token stop, e.g. specifying 1 can yield to empty token Default: 0, any number of successive tokenizing characters are combined as one token stop
Returns
cString the string with the uppercased tokens
Description
The TokenUpper() function changes the first letter of tokens in cString to upper case. To do this, it uses the same tokenizing mechanism as the Token() function. If TokenUpper() extracts a token that starts with a letter, this letter will be changed to upper case. You can omit the return value of this function by setting the CSetRef() switch to .T., but you must then pass cString by reference to get the result.
Examples
? TokenUpper( "Hello, world, here I am!" ) // "Hello, World, Here I Am!"
? TokenUpper( "Hello, world, here I am!",, 3 ) // "Hello, World, Here I am!"
? TokenUpper( "Hello, world, here I am!", ",", 3 ) // "Hello, world, here I am!"
? TokenUpper( "Hello, world, here I am!", " w" ) // "Hello, wOrld, Here I Am!"
Status
Ready
Compliance
TokenUpper() is compatible with CT3's TokenUpper(), but a new 4th parameter, nSkipWidth has been added for synchronization with the the other token functions.
Numerical value of a character at a certain position
Syntax
ValPos( <cString>, [<nPosition>] ) → nDigitValue
Arguments
cString is the processed string [nPosition] is an optional position within cString
Default: last position in cString
Returns
nDigitValue the numerical value of the character at the specified
position
Description
The ValPos() function returns the numerical value of the character that can be found at the position nPosition in cString. If no digit can be found at this position or if nPosition is larger than the length of cString, 0 is returned.
[cDoubleCharactersToReduce] specifies the double characters the multiple
occurrences of which should be reduced to one Default: All characters.
cString specifies the processed string
Returns
cReducedString the string with the reduced occurrences
Description
The WordOne() function reduces multiple occurrences of double characters in cString to a single one. It is important to note that the multiple occurrences must occur directly one behind the other.
cThisDoubleCharactersOnly specifies the double characters that must
not be deleted in cString.
cString is the string that should be processed
Returns
cReducedString A string with all double characters deleted
but those specified in cThisCharactersOnly.
Description
The WordOnly() function calculates the intersectional set of two strings based on double characters. To do this, it deletes all double characters from cString that do not appear in cThisDoubleCharacterOnly.
cDoubleCharacterSearchString is a string of double characters
that should be replaced
[@]cString is the processed string cDoubleCharacterReplaceString is a string of double characters that
replace the one of cSearchString
[lMode] sets the replacement method (see description)
Default: .F.
Returns
cString the processed string
Description
The WordRepl() takes the double characters of cDoubleCharacterSearchString one after the other and searches for them in cString. For lMode set to .F., this search is successful, if the double character sequence in cString starts at an odd position or at any position, if lMode is set to .T. If this happens, the double character sequence will be replaced with the corresponding double character sequence of cDoubleCharacterReplaceString. If cDoubleCharacterReplaceString is shorter than cDoubleCharacterSearchString the last double sequence of cDoubleCharacterReplaceString is used for the "rest" of cDoubleCharacterSearchString. Note that the last double character sequence in "AABBC" is "BB" in this context !! After the replacement the function restarts the search in cStringBEHIND the replacement if the CSetAtMupa() switch is turned off, or BEHIND the first character of the replacement if the switch is turned on. (see examples for this !) One can omit the return value of this function by setting the CSetRef() to .T., but one must then pass cString by reference to get a result.
[@]cString is the string that should be processed [lSwapCharacters] specifies whether an additional swap should be
done within the double characters Default: .F., no additional swap
Returns
cSwappedString a string where neighbouring double characters are
swapped
Description
The WordSwap() function loops through cString in steps of four characters and exchanges the double characters from the first and second position with the one from the third and forth position. Additionally the function can perform a swap of the both char of each double character. By setting the CSetRef() switch to .T., one can omit the return value of this function, but one must then pass cString by reference.
nTop - top row number, default 0 nLeft - left column number, default 0 nBottom - top row number, default MaxRow()nRight - right column number, default MaxCol()cNewChar|nNewChar - new character for the screen area,
as a numeric value in the range of 0 to 255 or as a character string, default value is the CLEARB.
cOldChar|nOldChar - character to exchange. Specify the parameter
as a numeric in the range of 0 to 255 or as a character string. The default is to exchange all characters.
Returns
Returns an empty string.
Description
Exchanges particular characters in a screen area. TODO: add documentation
cAttr Designates the alphanumeric color attribute that is
converted in NN/NN or CC/CC form.
Returns
ColorToN() returns a number that corresponds to the combined numeric color attribute.
Description
COLOR TO (N)umeric The function changes an alphanumeric color attribute from NN/NN or CC/CC into a combined numeric attribute. These combined attribute values are useful with the CA-Cl*pper Tools functions StrScreen(), ScreenMix(), ScreenAttr(), and the CA-Cl*pper commands SAVE/RESTORESCREEN.
nAttr Designates the value for the combined numeric color
attributes.
lColorCode If designated as .F. or if the parameter is omitted,
NToColor() returns a string with a numeric color code. When designated as .T., NToColor() returns a string with the CA-Cl*pper alpha color coding.
Returns
NToColor() returns the designated color attribute in the NN/NN or CC/CC form.
Description
NToColor() converts a color attribute returned from another function in numeric form, into the alphanumeric data format. Use this attribute in conjunction with the CA-Cl*pper SET COLOR TO command.
cString - the string to output. Although undocumented, can be NIL. nRow - row number, defaults to cursor row. nCol - column number, defaults to cursor column.
Returns
Returns an empty string.
Description
Outputs a string at specified coordinates without changing character attributes.
nRow Designates the line from which to determine the attribute.
The default is the cursor line.
nColumn Designates the column from which to determine the
attribute. The default is the cursor column.
Returns
ScreenAttr() returns the attribute at the designated position.
Description
ScreenAttr() returns the current screen attribute at nRow and nColumn. You can query targeted attributes this way and save them to use later, or process them later with InvertAttr().
cFontString Binary string containing a valid font definition. nFontArea Number of a font area where the font must be loaded. nOffset First character code to be loaded. nCounter Number of characters to load. lCompute When .T., the function computes font height automatically.
cColor|nColor - the color to change in CA-Cl*pper color notation or
as a number from 0 to 15.
nRedValue, nGreenValue, and nBlueValue specify the palette
settings for the respective portions in the range from 0 to 63. If no RGB value is specified, the palette register is reset to its default value (currently unsupported).
If the function is called without parameters, the palette registers for all colors are reset to their default values (currently unsupported).