<< Click to Display Table of Contents >> Navigation: Available Functions > Get_Token() |
Syntax
Get_Token( <CharacterField>, <Word>, <Delimiter> )
Purpose
To extract a specific word from a character field.
Parameters
<CharacterField> is the name of any character field in DonorQuest, such as the last or first name field.
<Word> is the number of the desired word.
<Delimiter> is usually a quoted space (" "). In general, <Delimiter> is whatever separates words within the field from which you wish to extract a single word. In most cases, words within fields are separated by a space, but you may also have fields in which commas or semicolons are used to separate words or groups of words.
Returns
A specific word from within <CharacterField>.
Usage
Get_Token() can be used with reports to print a specific word from any character field in DonorQuest. But its power goes well beyond simply dealing with words within fields. The term "token" really applies to any part of a character field that is delimited by a special character or characters. This ability lets you create subfields within fields.
For example, let's say your organization is holding an auction, and you want to store the following extra information with each gift:
1. A number representing the item purchased.
2. A number representing the number of bids placed for the item in selling it.
3. A general comment.
Since there is not a dedicated donation field for each of these items, they must all go in the donation comment field. However, if you establish a convention for auction item donations in which you use semicolons to separate each of these items in the donation comment field, you will be able to specifically extract each of them as if they were stored in separate fields in DonorQuest reports and data exports.
Example
The following examples illustrate the use of Get_Token() outlined above. This example is based on an instance of the .Donation_Comment. being equal to "123; 5; Donor very excited with purchase!"
CALL |
RESULT |
---|---|
.Donation_Comment. |
123; 5; Donor very excited with purchase! |
Get_Token( .Donation_Comment., 1, ";" ) |
123 |
Get_Token( .Donation_Comment., 2, ";" ) |
5 |
Get_Token( .Donation_Comment., 3, ";" ) |
Donor very excited with purchase! |
The technique outlined above could be easily adapted to memo text lines, allowing you to have multiple fields within particular memo text lines. The solicitation system in DonorQuest actually uses this technique to store the date, campaign code, date of last follow up, and number of follow-ups for each solicitation cycle, all in the text field of a single memo line. Each "field" within the single memo text entry are separated (delimited) by a semicolon (";").