C

<< Click to Display Table of Contents >>

Navigation:  Concordance Programming Language Reference > Functions >

C

The following topic discusses the Concordance Programming Language (CPL) functions that begin with the letter C. For more information on CPL functions, see Functions, About the Advanced Programming Features, and About CPL Functions.

Capitalize

text capitalize(text string);

Description - Produces a duplicate of the parameter string capitalized. All words will begin with an upper case letter, all non-initial letters are lower case. Does not change the original.

Return Value - The parameter with capitalized text.

See Also - upper(), lower()

Example

main()

{

text author;

 author = "e e cummings";

 puts(0,0,capitalize(author));

 puts(1,0,author);

}

Output

   E E Cummings

   e e cummings

 

CCol

int ccol();

Description - Current column position of the cursor.

Return Value - Cursor's column position.

See Also - crow(), cursor()

 

ChDir

text chdir(text directoryPath);

Description - Changes the current drive and directory to the one specified by directoryPath.

Return Value - A zero if successful, non-zero if the directory or drive does not exist.

See Also - diskspace(), getcwd()

Example

main()

{

 /* Change to drive E: *\

 chdir("E:");

 /* Change directories. */

 chdir("concord5\DATA");

 /* Change drive and directories. */

 chdir("F:\apps\concord5");

 /* Display the current drive and path. */

 puts(10,40,"The current directory is "+getcwd());

}

 

Chr

text chr(int c);

Description - Converts the value of c to a text variable.

Return Value - The single character converted to a text type variable.

See Also - asc()

Example

main

{

int handle;

text line;

 /* Send a form feed to the printer. */

 if ((handle = open("prn","w")) <> -1) {

  line = "Page ejected..."+chr(12);

  write(handle,line,len(line));

  close(handle);

 }

}

 

Clock

int clock();

Description - The clock() function gets the number of thousandths of a second since the program was started.

Return Value - Returns -1 if the clock is not available.

See Also - time(), today()

Example

main()

{

int i, start;

 start = clock();

 for(i = 0; i < 100; i = i + 1)

  puts(0,0,"Count ="+str(i,7,0,','));

 start = (clock() - start) / 1000;

 puts(1,0,"That took "+str(start,7,0,',')+" seconds.");

 getkey();

}

 

Close

int close(int handle);

Description - The file associated with handle is closed. Handle must be a value returned earlier by a call to open().

Return Value - A -1 if an error is encountered while closing the file.

See Also - open()

 

CloseDB

int closedb(int db);

Description - Data base associated with db handle is closed.

Return Value - A 0 if successful, -1 if not successful.

Example

main()

{

int db;

 db = opendb("recipes");

 if (db >= 0) {

  puts(0,0,"There are "+str(db.documents,8,0,',')+" recipes in the cookbook");

  if (closedb(db) == -1)

   puts(0,1,"Error closing database.");

 }

 else

  puts(0,0,"Can't open database.")

 getkey();

}

 

Cls

cls([int color]);

Description - Clears the screen to TextColor_, the default color, or to the specified color if one is passed as a parameter. Under Windows, the color should be a background color.

Return Value - None.

See Also - scroll()

Example

colors()

{

int i, oldColor;

 /* Show the basic set of colors. Display the */

 /* color's number centered in the screen. */

 oldColor = TextColor_;

 for(i = 1; i <= 127; i = i + 1) {

  TextColor_ = i;

  cls();

  puts(MaxRow_/2,0,pad("Color "+str(i),'C',80));

  getkey();

 }

 TextColor_ = oldColor;

}

 

Concat

concat(int db; text FileName);

Description - Concatenates a database to the opened database whose handle is db. FileName should be the path and name of a database file to concatenate.

Return Value - Zero if the database was concatenated, nonzero if an error occurred. Cause for error includes: too many concatenated databases, the maximum is sixteen; the requested database is already concatenated; file not found; database is in exclusive use by another user.

See Also - concatclear()

 

ConcatClear

concatclear(int db);

Description - All databases concatenated to the database whose handle is db are closed. The database is no longer concatenated after this call returns. All queries are reset and cleared by this call.

Return Value - None

See Also - concat()

 

Count

int count(int db);

Description - Returns the number of documents in the current query. db should be a valid handle returned by a call to opendb(). To find the total number of documents in the database, use:

 x = db.documents;

Return Value - Count of documents in the current query. A value less than zero if the database is not open.

See Also - hits()

 

CreateDB

int createdb( text  FileName;

  text  FieldNames[];

  int  types[];

  int  lengths[];

  int  places[];

  int  formats[];

  int  keyField[]);

Description - Creates a new database with the requested file name and structure. This function will not create the database if another database already exists by the same name.

oThe fields are defined by giving them a name, a type, a length, and optionally places and format entries. The type can be 'T', 'D', 'N', or 'P', for Text, Date, Numeric, and Paragraph field types respectively.

oThe length entry designates the total width of the field for text and numeric fields. Length indicates the display format for date fields, MDY, YMD, or DMY. It sets the left margin of paragraph fields.

oThe places array is only used for numeric field types, and its presence is optional. The format array can contain numeric display formats Z, $, or "," for zero filled, currency and comma numeric types. If the format array is passed, the places array must also be provided.

oThe keyField array specifies the key fields in the database. A non-zero entry creates a key field.

oAll rules that apply to creating databases in the Concordance full-screen Database Create mode apply to this function. See the reference manual for a full explanation.

This function is not implemented in the Concordance Runtime Module. It will always return a creation error in the Runtime module.

Return Value - Zero if the database structure was valid and a database was created. A nonzero return value is an error code in the reference manual error listings, or in the concordp.msg or runcpl.msg file. This function only creates the database, it does not open it.

See Also - createfs(), struc(), modify(), opendb()

Example

/* Create a new database. */

MakeNew()

{

char string[80];

int err, newHandle;

text names[4];

int lengths[4], types[4], key[4];

 newHandle = -1;

 getfile("New Database", "*.DCB", string);

 if (len(string) <> 0)

 {

  names[0] = "BIRTHDATE"; types[0] = 'D';

  lengths[0] = 'M';   key[0] = 1;

  names[1] = "EARNINGS"; types[1] = 'N';

  lengths[1] = 10;   key[1] = 0;

  names[2] = "NAME";  types[2] = 'P';

  lengths[2] = 16;   key[2] = 0;

  names[3] = "AUTHORED"; types[3] = 'P';

  lengths[3] = 16;   key[3] = 0;

  err = createdb(string,names,types,lengths);

  if (err == 0)

   newHandle = opendb(string);

 }

 return(newHandle);

}

 

CreateFS

int createfs();

Description - Concordance full screen create command. It first prompts the user for a database name, then presents the database create screen. See the Concordance Reference Manual for a full description of database create.

This function is not implemented in the Concordance Runtime Module. It will always return an error when called from the Runtime module.

Return Value - A handle to the newly created and opened database. A value less than zero if the user canceled the database create.

See Also - modify(), createdb(), struc()

 

CreateReplica

int createReplica(int db; text databaseName; int copyAttachments);

Description - Creates a replica database using all records in the current query, in the current sorted order. The replica has all security settings and document tags in the current database, but it is not indexed. The optional parameter, copyAttachments, will copy attachments with the database if set to TRUE.

Return Value - A zero signals success

See Also - replicate(), resolve()

 

Crow

int crow();

Description - Current cursor row.

Return Value - Row position of the cursor.

See Also - ccol(), cursor()

 

CTod

int ctod(char string[][; char format]);

Description - Convert character string or text variable to date format. The format, if specified, can be 'Y', 'M' or 'D' to select YYMMDD, MMDDYY and DDMMYY formats of the string parameter. The default is 'M' format if none is specified.

Return Value - The date as an integer.

See Also - dtoc()

Example

days()

{

int DaysBefore2000;

 DaysBefore2000 = ctod("1/1/2000") - today();

 return(DaysBefore2000);

}

 

Cursor

cursor(int row, column);

Description - Moves the cursor to the specified row and column coordinates. The screen begins in the upper left corner with row 0, column 0. An 80 column screen goes from row 0 to row 24, and from column 0 to column 79.

Return Value - None.

See Also - ccol(), crow(), cursoron(), cursoroff()

 

CursorOff

cursoroff();

Description - Hides the cursor.

Return Value - None.

See Also - cursoron()

Example

main()

{

 cursoroff();

 puts(0,0,"The cursor has disappeared.");

 puts(1,0,"Hit any key to show the cursor.");

 getkey();

 cursoron();

}

 

CursorOn

cursoron();

Description - Enables the display of the cursor.

Return Value - None.

See Also - cursoroff()

 

Cut

text cut(text data);

Description - Copies the data to the cut and paste buffer. The data replaces the current contents of the buffer. It remains in the buffer until another cut() replaces it. The buffer is shared by the programming language with the editor's cut & paste functions. Cutting text with the editor will also flush the buffer and replace the data.

oThe Windows version cuts to the system clipboard. Note that other programs have access to the clipboard, and they can clear or replace the data.

Return Value - The text value that was cut.

See Also - paste()