Difference between revisions of "Working With String Data in Recital"

From Recital Documentation Wiki
Jump to: navigation, search
(String Comparison Functions Return Value)
 
(62 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Working With String Data in Recital==
 
==Working With String Data in Recital==
 
===Changing the Case of a String===
 
===Changing the Case of a String===
 +
 +
* [[LOWER()|lower()]] - convert a string to lower case
 +
 +
<pre>
 +
character = lower(string as character)
 +
</pre>
  
 
* [[STRTOLOWER()|strtolower()]] - convert a string to lower case
 
* [[STRTOLOWER()|strtolower()]] - convert a string to lower case
Line 6: Line 12:
 
<pre>
 
<pre>
 
character = strtolower(string as character)
 
character = strtolower(string as character)
 +
</pre>
 +
 +
* [[UPPER()|upper()]] - convert a string to upper case
 +
 +
<pre>
 +
character = upper(string as character)
 
</pre>
 
</pre>
  
Line 14: Line 26:
 
</pre>
 
</pre>
  
* [[UCFIRST()|ucfirst()]] - convert a string to lower case with the first character of each word in upper case
+
* [[PROPER()|proper()]] - convert a string to lower case with the first character to upper case
 +
 
 +
<pre>
 +
character = proper(string as character)
 +
</pre>
 +
 
 +
* [[UCFIRST()|ucfirst()]] - convert a string to lower case with the first character to upper case
  
 
<pre>
 
<pre>
Line 21: Line 39:
  
 
===Converting to and from ASCII Values===
 
===Converting to and from ASCII Values===
 +
 +
* [[ASC()|asc()]] - return the numeric ASCII value of a character.
 +
 +
<pre>
 +
numeric = asc(string as character)
 +
</pre>
 +
 +
* [[CHR()|chr()]] - return the character corresponding to a numeric ASCII value.
 +
 +
<pre>
 +
character = chr(ASCII as numeric)
 +
</pre>
 +
 
===Printing Formatted Strings in Recital===
 
===Printing Formatted Strings in Recital===
 
Recital provides three functions for the output of strings with 'C' style parameter replacement and formatting.
 
Recital provides three functions for the output of strings with 'C' style parameter replacement and formatting.
Line 220: Line 251:
  
 
===Converting a String Into an Array===
 
===Converting a String Into an Array===
 +
* [[ASTORE()|astore()]] - fill an array from a string with separate character elements and return the number of elements
 +
 +
<pre>
 +
numeric = astore(arrayname, string as character, separator as character)
 +
</pre>
 +
 +
* [[EXPLODE()|explode()]] -  separate a character string into individual elements and return as an array
 +
 +
<pre>
 +
array = explode(separator as chatacter, string as character)
 +
</pre>
 +
 
===Converting an Array into a String===
 
===Converting an Array into a String===
 +
* [[ASTRING()|astring()]] - return an array as a character string, with the elements separated by a comma or other specified character
 +
 +
<pre>
 +
character = astring(arrayname [, separator as character])
 +
</pre>
 +
 +
* [[IMPLODE()|implode()]] - return an array as a character string, with the elements separated by a specified character
 +
 +
<pre>
 +
character = implode(separator as character, arrayname)
 +
</pre>
 +
 +
===Reading a File into a String===
 +
* [[FILETOSTR()|filetostr()]] - read the contents of a text file into a character string
 +
 +
<pre>
 +
character = filetostr(filename as character)
 +
</pre>
 +
 +
Note: please also see [[Working with Files and File Systems in Recital]].
 +
 +
===Writing a String to a File===
 +
* [[STRTOFILE()|strtofile()]] - write a string to a file, overwriting or optionally appending to any existing contents
 +
 +
<pre>
 +
numeric = strtofile(string as character, filename as character [, append as logical | options as numeric])
 +
</pre>
 +
 +
Note: please also see [[Working with Files and File Systems in Recital]].
 +
 
===String Conversion Functions===
 
===String Conversion Functions===
  
Line 244: Line 317:
  
 
<pre>
 
<pre>
character = etos(expression as expression)
+
character = etos(expression as expression [, length as numeric])
 +
</pre>
 +
 
 +
* [[MTOS()|mtos()]] - perform memo to string conversion
 +
 
 +
<pre>
 +
character = mtos(memo as memo)
 
</pre>
 
</pre>
  
Line 251: Line 330:
 
<pre>
 
<pre>
 
date = stod(YYYYMMDD as character)
 
date = stod(YYYYMMDD as character)
 +
</pre>
 +
 +
* [[STR()|str()]] - perform numeric to string conversion
 +
 +
<pre>
 +
character = str(number as numeric [, length as numeric [, decimals as numeric [, base as numeric]]])
 +
</pre>
 +
 +
* [[STRZERO()|strzero()]] - perform numeric to string with leading zeros conversion
 +
 +
<pre>
 +
character = strzero(number as numeric [, length as numeric [, decimals as numeric]])
 +
</pre>
 +
 +
* [[TOSTRING()|tostring()]] - perform expression to string conversion
 +
 +
<pre>
 +
character = tostring(expression as expression [, length as numeric])
 
</pre>
 
</pre>
  
Line 283: Line 380:
 
<pre>
 
<pre>
 
character = trim(string as character)
 
character = trim(string as character)
 +
</pre>
 +
 +
===Padding Recital Strings===
 +
* [[PADC()|padc()]] | [[CENTER()|center()]] - center string and pad both left and right
 +
 +
<pre>
 +
character = padc(string as character, length as numeric [, padwith as character])
 +
</pre>
 +
 +
* [[PADL()|padl()]] | [[LPAD()|lpad()]] - pad to the left
 +
 +
<pre>
 +
character = padl(string as character, length as numeric [, padwith as character])
 +
character = lpad(string as character, length as numeric [, padwith as character])
 +
</pre>
 +
 +
* [[PADR()|padr()]] | [[RPAD()|rpad()]] - pad to the right
 +
 +
<pre>
 +
character = padr(string as character, length as numeric [, padwith as character])
 +
character = rpad(string as character, length as numeric [, padwith as character])
 +
</pre>
 +
 +
* [[STR_PAD()|str_pad()]] - pad left, right or both
 +
 +
<pre>
 +
character = str_pad(string as character, length as numeric [, padwith as character [, padtype as character]])
 
</pre>
 
</pre>
  
 
===Comparing Strings in Recital===
 
===Comparing Strings in Recital===
===String Comparison Functions Return Value===
+
The [[DIFFERENCE()|difference()]] function returns an integer signifying the phonetic difference between two character strings.  A return value of 4 represents a close match, and 0 is returned when the two character expression have no letters in common.
The [[STRCMP()|strcmp()]] and [[STRCASECMP()|strcasecmp()]] functions return a numeric value as follows:
+
  
 +
<pre>
 +
numeric = difference(string1 as character, string2 as character)
 +
</pre>
 +
 +
The [[INLIST()|inlist()]] function checks whether a character string exists in a specified list of strings.
 +
 +
<pre>
 +
logical = inlist(searchfor as character, liststring1 as character, liststring2 as character [,...])
 +
</pre>
 +
 +
The [[LIKE()|like()]] function checks whether a character string matches a pattern, which may include wildcard characters.
 +
 +
<pre>
 +
logical = like(pattern as character, string as character)
 +
</pre>
 +
 +
The [[STRCMP()|strcmp()]] and [[STRCASECMP()|strcasecmp()]] functions are used to compare two strings, character by character.  They differ in that [[STRCMP()|strcmp()]] does a case-sensitive comparison and [[STRCASECMP()|strcasecmp()]] a case-insensitive comparison.
 +
 +
<pre>
 +
numeric = strcmp(string1 as character, string2 as character)
 +
</pre>
 +
 +
<pre>
 +
numeric = strcasecmp(string1 as character, string2 as character)
 +
</pre>
 +
 +
The [[STRCMP()|strcmp()]] and [[STRCASECMP()|strcasecmp()]] functions return a numeric value as follows:
  
 
{| class="wikitable"
 
{| class="wikitable"
 
!Return Value||Description
 
!Return Value||Description
 
|-
 
|-
|&#045;1||<expC1> is less than <expC2>
+
|&#045;1||string1 is less than string2
 
|-
 
|-
|0||<expC1> and <expC2> are identical
+
|0||string1 and string2 are identical
 
|-
 
|-
|1||<expC1> is greater than <expC2>
+
|1||string1 is greater than string2
 
|-
 
|-
 
|}
 
|}
  
===Accessing and Modifiying Characters in String===
+
===Extracting Substrings from a Recital String===
 +
* [[LEFT()|left()]] - extract substring from left
 +
 
 +
<pre>
 +
character = left(string as character, length as numeric)
 +
</pre>
 +
 
 +
* [[RIGHT()|right()]] - extract substring from right
 +
 
 +
<pre>
 +
character = right(string as character, length as numeric)
 +
</pre>
 +
 
 +
* [[STREXTRACT()|strextract()]] - extract substring
 +
 
 +
<pre>
 +
character = strextract(string as character, startdelimiter as character [, enddelimiter as character
 +
  [, occurrence as numeric [, flags as numeric]]])
 +
</pre>
 +
 
 +
* [[STRSTR()|strstr()]] - extract substring
 +
 
 +
<pre>
 +
character = strstr(string as character, startdelimiter as character)
 +
</pre>
 +
 
 +
* [[SUBSTR()|substr()]] - extract substring
 +
 
 +
<pre>
 +
character = substr(string as character, startposition as numeric [, length as numeric])
 +
</pre>
 +
 
 
===Searching for Characters and Substrings in a Recital String===
 
===Searching for Characters and Substrings in a Recital String===
===Extracting and Replacing Substrings in Recital===
+
* [[AT()|at()]] | [[ATNEXT()|atnext()]] - search for the first or specified occurrence of a character or substring in a character string and return its starting position
===Replacing All Instances of a Word in a Recital String===
+
 
 +
<pre>
 +
numeric = at(searchforthis as character, inthis as character [, occurrence as numeric])
 +
numeric = atnext(searchforthis as character, inthis as character [, occurrence as numeric])
 +
</pre>
 +
 
 +
* [[RAT()|rat()]] - search for the last or specified occurrence of a character or substring in a character string and return its starting position
 +
 
 +
<pre>
 +
numeric = rat(searchforthis as character, inthis as character [, occurrence as numeric])
 +
</pre>
 +
 
 +
* [[STRPOS()|strpos()]] - search for the first occurrence of a character or substring in a character string and return its starting position
 +
 
 +
<pre>
 +
numeric = strpos(searchforthis as character, inthis as character [, starthere as numeric])
 +
</pre>
 +
 
 +
===Searching for and Replacing Characters and Substrings in a Recital String===
 +
* [[HARDCR()|hardcr()]] - convert soft carriage returns (ASCII 10) to hard carriage returns (ASCII 13) in a character string
 +
 
 +
<pre>
 +
character = hardcr(string as character)
 +
</pre>
 +
 
 +
* [[OCCURS()|occurs()]] - check how many times a character or substring appears in a character string
 +
 
 +
<pre>
 +
numeric = occurs(searchforthis as character, inthis as character)
 +
</pre>
 +
 
 +
* [[STR_REPLACE()|str_replace()]] - search for and replace text within a character string or memo field
 +
 
 +
<pre>
 +
character = str_replace(replacethis as character, withthis as character, inthis as character [, replaced as numeric])
 +
</pre>
 +
 
 +
* [[STRTRAN()|strtran()]] | [[CHRTRAN()|chrtran()]] - search for and replace text within a character string or memo field
 +
 
 +
<pre>
 +
character = strtran(inthis as character, replacethis as character, withthis as character [, starthere as numeric [, repeat as numeric]])
 +
character = chrtran(inthis as character, replacethis as character, withthis as character [, starthere as numeric [, repeat as numeric]])
 +
</pre>
 +
 
 +
* [[STUFF()|stuff()]] - replace text within a character string or memo field
 +
 
 +
<pre>
 +
character = stuff(inthis as character, starthere as numeric, characters as numeric, withthis as character)
 +
</pre>
 +
 
 
===Miscellaneous String Functions===
 
===Miscellaneous String Functions===
===Summary===
+
* [[ISALPHA()|isalpha()]] - checks if the first character of a character string is alphabetic
 +
 
 +
<pre>
 +
logical = isalpha(string as character)
 +
</pre>
 +
 
 +
* [[ISDIGIT()|isdigit()]] - checks if the first character of a character string is a digit
 +
 
 +
<pre>
 +
logical = isdigit(string as character)
 +
</pre>
 +
 
 +
* [[ISLOWER()|islower()]] - checks if the first character of a character string is in lower case
 +
 
 +
<pre>
 +
logical = islower(string as character)
 +
</pre>
 +
 
 +
* [[ISUPPER()|isupper()]] - checks if the first character of a character string is in upper case
 +
 
 +
<pre>
 +
logical = isupper(string as character)
 +
</pre>
 +
 
 +
* [[REPLICATE()|replicate()]] - returns a string with the specified number of copies of the specified string
 +
 
 +
<pre>
 +
character = replicate(string as character, copies as numeric)
 +
</pre>

Latest revision as of 09:42, 23 July 2010

Working With String Data in Recital

Changing the Case of a String

  • lower() - convert a string to lower case
character = lower(string as character)
character = strtolower(string as character)
  • upper() - convert a string to upper case
character = upper(string as character)
character = strtoupper(string as character)
  • proper() - convert a string to lower case with the first character to upper case
character = proper(string as character)
  • ucfirst() - convert a string to lower case with the first character to upper case
character = ucfirst(string as character)

Converting to and from ASCII Values

  • asc() - return the numeric ASCII value of a character.
numeric = asc(string as character)
  • chr() - return the character corresponding to a numeric ASCII value.
character = chr(ASCII as numeric)

Printing Formatted Strings in Recital

Recital provides three functions for the output of strings with 'C' style parameter replacement and formatting.

The printf() function outputs the string to the current output: screen, printer destination, alternate file, etc..

printf(format as character, args [,...])

The sprintf() function returns the formatted string as a character value.

character=sprintf(format as character, args [,...])

The fprintf() function writes the formatted string to an open file using a file pointer reference.

fprintf(file pointer as numeric, format as character, args [,...])

Recital printf Formatting Specifiers

Formatting option Description
%s Convert to character string (similar to using etos() or tostring()
%d For date parameters
%f For floating point numeric parameters
%y For currency parameters
%t For datetime parameters
%T For datetime parameters; character day is also displayed
%l For logical parameters: True, False
%L For logical parameters: Yes, No


Formatting sequences can also contain the following options. These are specified in order, between the '%' and the data type letter.


Formatting option Description
- Left-justify
n Left pad with spaces to width n
n.p Left pad with spaces to width n and include the decimal point and p decimal places (%f only)

Example code printf()

// When %s is specified, the corresponding argument is converted to 
// character format (similar to specifying etos()).
// Widths correspond to the default values, e.g. numerics are 10
printf('It is %s, %s to be more precise\n',year(date()),datetime())
printf('The value of pi is %s\n',pi())
printf('They cost %s per %s\n',$99,100)
printf('Logicals can be %s or %s\n',.T.,.F.)
// Formatting sequences can contain a width, which will left pad with spaces 
printf('Right-justify and pad left: %10s this\n','Like')
// Left justify by placing a '-' directly following the '%' character 
printf('Left-justify and pad right: %-10s this\n','Like')
// %d is for numerics
printf('It is %d\n',year(date()))
// %t and %T are for formating datetime data types.
printf('It is %d, %t to be more precise\n',year(date()),datetime())
printf('It is %d, %T to be even more precise\n',year(date()),datetime())
// %f is for floating point numerics
printf('The value of pi is %f\n',pi())
// Decimal places can also be specified for floating point numerics (%f) 
printf('The value of pi to two decimal places is %4.2f\n',pi())
// %y is for formatting currency data types
printf('They cost %y per %d\n',$99,100)
printf('They cost %y per %d\n',$99,1000)
printf('They cost %y per %d\n',$99,10000)
//%l and %L are for formatting logical datatypes.
printf('Logicals can be %l or %l\n',.T.,.F.)
printf('Logicals can also be %L or %L\n',.T.,.F.)

Example code sprintf()

// When %s is specified, the corresponding argument is converted to 
// character format (similar to specifying etos()).
// Widths correspond to the default values, e.g. numerics are 10
cVAR=sprintf('It is %s, %s to be more precise',year(date()),datetime())
echo cVAR
cVAR=sprintf('The value of pi is %s',pi())
echo cVAR
cVAR=sprintf('They cost %s per %s',$99,100)
echo cVAR
cVAR=sprintf('Logicals can be %s or %s',.T.,.F.)
echo cVAR
// Formatting characters can contain a width, which will left pad with spaces 
cVAR=sprintf('Right-justify and pad left: %10s this','Like')
echo cVAR
// Left justify by placing a '-' directly following the '%' character 
cVAR=sprintf('Left-justify and pad right: %-10s this','Like')
echo cVAR
// %d is for numerics
cVAR=sprintf('It is %d',year(date()))
echo cVAR
// %t and %T are for formating datetime data types.
cVAR=sprintf('It is %d, %t to be more precise',year(date()),datetime())
echo cVAR
cVAR=sprintf('It is %d, %T to be even more precise',year(date()),datetime())
echo cVAR
// %f is for floating point numerics
cVAR=sprintf('The value of pi is %f',pi())
echo cVAR
// Decimal places can also be specified for floating point numerics (%f)
cVAR=sprintf('The value of pi to two decimal places is %4.2f',pi())
echo cVAR
// %y is for formatting currency data types
cVAR=sprintf('They cost %y per %d',$99,100)
echo cVAR
cVAR=sprintf('They cost %y per %d',$99,1000)
echo cVAR
cVAR=sprintf('They cost %y per %d',$99,10000)
echo cVAR
//%l and %L are for formatting logical datatypes.
cVAR=sprintf('Logicals can be %l or %l',.T.,.F.)
echo cVAR
cVAR=sprintf('Logicals can also be %L or %L',.T.,.F.)
echo cVAR

Example code fprintf()

fp=fcreate('fprintf.txt')
// When %s is specified, the corresponding argument is converted to 
// character format (similar to specifying etos()).
// Widths correspond to the default values, e.g. numerics are 10
fprintf(fp,'It is %s, %s to be more precise\n',year(date()),datetime())
fprintf(fp,'The value of pi is %s\n',pi())
fprintf(fp,'They cost %s per %s\n',$99,100)
fprintf(fp,'Logicals can be %s or %s\n',.T.,.F.)
// Formatting characters can contain a width, which will left pad with spaces 
fprintf(fp,'Right-justify and pad left: %10s this\n','Like')
// Left justify by placing a '-' directly following the '%' character 
fprintf(fp,'Left-justify and pad right: %-10s this\n','Like')
// %d is for numerics
fprintf(fp,'It is %d\n',year(date()))
// %t and %T are for formating datetime data types.
fprintf(fp,'It is %d, %t to be more precise\n',year(date()),datetime())
fprintf(fp,'It is %d, %T to be even more precise\n',year(date()),datetime())
// %f is for floating point numerics
fprintf(fp,'The value of pi is %f\n',pi())
// Decimal places can also be specified for floating point numerics (%f)
fprintf(fp,'The value of pi to two decimal places is %4.2f\n',pi())
// %y is for formatting currency data types
fprintf(fp,'They cost %y per %d\n',$99,100)
fprintf(fp,'They cost %y per %d\n',$99,1000)
fprintf(fp,'They cost %y per %d\n',$99,10000)
//%l and %L are for formatting logical datatypes.
fprintf(fp,'Logicals can be %l or %l\n',.T.,.F.)
fprintf(fp,'Logicals can also be %L or %L\n',.T.,.F.)
fclose(fp)

Output

It is       2009, 11/11/2009 11:41:51 AM to be more precise
The value of pi is  3.1415926
They cost $99.0000 per        100
Logicals can be True or False
Right-justify and pad left:       Like this
Left-justify and pad right: Like       this
It is 2009
It is 2009, 11/11/2009 11:41:51 AM to be more precise
It is 2009, Wednesday November 11 2009 11:41:51 to be even more precise
The value of pi is 3.141593
The value of pi to two decimal places is 3.14
They cost $99.0000 per 100
They cost $99.0000 per 1000
They cost $99.0000 per 10000
Logicals can be True or False
Logicals can also be Yes or No

Finding the Length of a Recital String

  • strlen() - return the numeric length of a string
numeric = strlen(string as character)

Converting a String Into an Array

  • astore() - fill an array from a string with separate character elements and return the number of elements
numeric = astore(arrayname, string as character, separator as character)
  • explode() - separate a character string into individual elements and return as an array
array = explode(separator as chatacter, string as character)

Converting an Array into a String

  • astring() - return an array as a character string, with the elements separated by a comma or other specified character
character = astring(arrayname [, separator as character])
  • implode() - return an array as a character string, with the elements separated by a specified character
character = implode(separator as character, arrayname)

Reading a File into a String

  • filetostr() - read the contents of a text file into a character string
character = filetostr(filename as character)

Note: please also see Working with Files and File Systems in Recital.

Writing a String to a File

  • strtofile() - write a string to a file, overwriting or optionally appending to any existing contents
numeric = strtofile(string as character, filename as character [, append as logical | options as numeric])

Note: please also see Working with Files and File Systems in Recital.

String Conversion Functions

  • ctod() - perform character to date conversion
date = ctod(string as character)
  • dtoc() - perform date to character conversion
character = dtoc(date as date)
  • dtos() - perform date to string conversion
YYYYMMDD as character = dtos(date as date)
  • etos() - perform expression to string conversion
character = etos(expression as expression [, length as numeric])
  • mtos() - perform memo to string conversion
character = mtos(memo as memo)
  • stod() - perform string to date conversion
date = stod(YYYYMMDD as character)
  • str() - perform numeric to string conversion
character = str(number as numeric [, length as numeric [, decimals as numeric [, base as numeric]]])
  • strzero() - perform numeric to string with leading zeros conversion
character = strzero(number as numeric [, length as numeric [, decimals as numeric]])
  • tostring() - perform expression to string conversion
character = tostring(expression as expression [, length as numeric])
  • val() - perform string to numeric conversion
numeric = val(string as character)

Removing Leading and Trailing Whitespace from a Recital String

  • alltrim() - remove leading and trailing whitespace
character = alltrim(string as character)
  • ltrim() - remove leading whitespace
character = ltrim(string as character)
  • rtrim() - remove trailing whitespace
character = rtrim(string as character)
  • trim() - remove trailing whitespace
character = trim(string as character)

Padding Recital Strings

character = padc(string as character, length as numeric [, padwith as character])
character = padl(string as character, length as numeric [, padwith as character])
character = lpad(string as character, length as numeric [, padwith as character])
character = padr(string as character, length as numeric [, padwith as character])
character = rpad(string as character, length as numeric [, padwith as character])
character = str_pad(string as character, length as numeric [, padwith as character [, padtype as character]])

Comparing Strings in Recital

The difference() function returns an integer signifying the phonetic difference between two character strings. A return value of 4 represents a close match, and 0 is returned when the two character expression have no letters in common.

numeric = difference(string1 as character, string2 as character)

The inlist() function checks whether a character string exists in a specified list of strings.

logical = inlist(searchfor as character, liststring1 as character, liststring2 as character [,...])

The like() function checks whether a character string matches a pattern, which may include wildcard characters.

logical = like(pattern as character, string as character)

The strcmp() and strcasecmp() functions are used to compare two strings, character by character. They differ in that strcmp() does a case-sensitive comparison and strcasecmp() a case-insensitive comparison.

numeric = strcmp(string1 as character, string2 as character)
numeric = strcasecmp(string1 as character, string2 as character)

The strcmp() and strcasecmp() functions return a numeric value as follows:

Return Value Description
-1 string1 is less than string2
0 string1 and string2 are identical
1 string1 is greater than string2

Extracting Substrings from a Recital String

  • left() - extract substring from left
character = left(string as character, length as numeric)
  • right() - extract substring from right
character = right(string as character, length as numeric)
character = strextract(string as character, startdelimiter as character [, enddelimiter as character 
  [, occurrence as numeric [, flags as numeric]]])
character = strstr(string as character, startdelimiter as character)
character = substr(string as character, startposition as numeric [, length as numeric])

Searching for Characters and Substrings in a Recital String

  • at() | atnext() - search for the first or specified occurrence of a character or substring in a character string and return its starting position
numeric = at(searchforthis as character, inthis as character [, occurrence as numeric])
numeric = atnext(searchforthis as character, inthis as character [, occurrence as numeric])
  • rat() - search for the last or specified occurrence of a character or substring in a character string and return its starting position
numeric = rat(searchforthis as character, inthis as character [, occurrence as numeric])
  • strpos() - search for the first occurrence of a character or substring in a character string and return its starting position
numeric = strpos(searchforthis as character, inthis as character [, starthere as numeric])

Searching for and Replacing Characters and Substrings in a Recital String

  • hardcr() - convert soft carriage returns (ASCII 10) to hard carriage returns (ASCII 13) in a character string
character = hardcr(string as character)
  • occurs() - check how many times a character or substring appears in a character string
numeric = occurs(searchforthis as character, inthis as character)
  • str_replace() - search for and replace text within a character string or memo field
character = str_replace(replacethis as character, withthis as character, inthis as character [, replaced as numeric])
  • strtran() | chrtran() - search for and replace text within a character string or memo field
character = strtran(inthis as character, replacethis as character, withthis as character [, starthere as numeric [, repeat as numeric]])
character = chrtran(inthis as character, replacethis as character, withthis as character [, starthere as numeric [, repeat as numeric]])
  • stuff() - replace text within a character string or memo field
character = stuff(inthis as character, starthere as numeric, characters as numeric, withthis as character)

Miscellaneous String Functions

  • isalpha() - checks if the first character of a character string is alphabetic
logical = isalpha(string as character)
  • isdigit() - checks if the first character of a character string is a digit
logical = isdigit(string as character)
  • islower() - checks if the first character of a character string is in lower case
logical = islower(string as character)
  • isupper() - checks if the first character of a character string is in upper case
logical = isupper(string as character)
  • replicate() - returns a string with the specified number of copies of the specified string
character = replicate(string as character, copies as numeric)