P

<< Click to Display Table of Contents >>

Navigation:  Concordance Programming Language Reference > Functions >

P

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

Pack

int pack(int db);

Description - Invokes Concordance full screen pack mode. The database is packed, all documents marked for deletion are removed. The search files are optimized if there is enough room on the disk. The screen is automatically saved before entering Pack and restored after exiting.

Return Value - Zero if successful.

 

Pad

text pad(char string[], align; int width);

Description - Duplicates the string and pads it with spaces to width number of characters. The string will be left, center, or right justified within the spaces depending on the value of align:

oL String is left justified

oC String is centered

oR String is right justified

oV Vertical alignment, adds or truncates lines to maximum height

Return Value - A duplicate of the original string padded with the specified number of spaces. The string is truncated if the width is less than the length of the string. The returned text value will never be longer than width.

Example

main()

{

puts(0,0,"|"+pad("hello",'L',21)+"|");

puts(1,0,"|"+pad("hello",'C',21)+"|");

puts(2,0,"|"+pad("hello",'R',21)+"|");

}

Output

|hello |

| hello |

| hello|

 

Paste

text paste();

Description - Returns a copy of the data in the cut and paste buffer. The same data is returned over and over again until it is replace by a cut() or by the user from the editor. The Windows version uses the system clipboard.

Return Value - The contents of the cut and paste buffer.

See Also - cut()

 

Prev

int prev(int db, document, field, index);

Description - Concordance moves to the previous document in the current query.

Return Value - Returns the physical document number of the previous document retrieved in the query. Returns a value less than or equal to zero if the current document is the first in the query, i.e., there is no previous document, or if the query set is empty. An error reading the document from file will also return a value less than or equal to zero.

oInformation about the first hit in the document is returned in the document, field, and index parameters. These parameters are optional. See first() for more detailed information on the return values.

See Also - goto(), first(), last(), next(), prevhit(), nexthit(), count(), hits()

 

PrevHit

int prevhit(int db, document, field, offset);

Description - Moves to the previous hit in the current query. If this moves to the previous document, then that document is read. Information about the hit list item is returned.

odb is a valid database handle returned by a call to opendb(). The document, field, and offset parameters are optional.

Return Value - Returns a value less than or equal to zero if the document could not be read or if the current hit is the first in the database, i.e., there is no previous document.

oInformation about the hit word is returned in the document, field, and offset parameters.

See Also - goto(), first(), last(), prev(), next(), nexthit(), count(), hits()

 

Print

print( int db,

outputFileHandle,

firstDocument, lastDocument;

text printFormatFileName;

[int statusRow[,

statusColumn[,

statusColor]]]);

Description - Loads the print format file, file extension .FMT, and prints the document range in the current active query. The output is sent to the open file whose handle is outputFileHandle. The document count is displayed on the screen at statusRow, statusColumn in statusColor. The Windows version displays the print status in a dialog box.

oPrint format files store all settings that can be set in full screen print mode. The settings are stored as plain text, and are created with the Documents/Print/Save menu option. They can be edited with any text editor. The print format file parameter can be a file name or an empty string, "", to accept the current settings. Any option not specified in the print format file is left alone, it is not reset by its absence. For instance, the file could contain only print margins, page length, and the setup string.

oThe Windows version requires a valid print format file parameter. It ignores the outputFileHandle parameter and prints to the current device.

Return Value - None.

See Also - printfs(), report(), reportfs()

Example

PrintThisList(int db)

{ /* Example for DOS and OS/2 */

int fileHandle;

if ((fileHandle = open("LPT1","w")) >= 0) {

print(db,fileHandle,1,count(db),"HPLASER",10,40);

close(fileHandle);

}

}

 

PrintFS

printfs(int db);

Description - Invokes the Concordance full screen print menu. See description in the Concordance Reference Manual. The screen is automatically saved before entering this mode and restored after exiting.

Return Value - None.

See Also - print(), reportfs()

 

Program

text program();

Description - Returns the name and DOS path of the currently running CPL program. The full program path may not be available if the program was executed as a command line prompt with Concordance.

Return Value - The name of the CPL program with the full DOS path if available.

 

PutEnv

int putenv(text nameAndValue);

Description - This function places the value into environment list. The environment list consists of a name and a value. These can be displayed from the DOS prompt by typing SET. The following is an example of a set value.

oPATH=C:\;C:\DOS

oValues are placed into the environment by passing the name followed by an equal sign and the value. Items are deleted from the environment by passing the name followed by an equal sign only.

oSpace for environment variables is limited. Consequently, the putenv() function may fail if there isn't enough room to add another value.

Return Value - Zero indicates success, -1 indicates failure.

See Also - getenv()

Example

The following program assigns a string to an environmental value and deletes another value.

main()

{

putenv("USERID=SMITHJ");

putenv("UPDATE=");

}

 

PutS

puts(int row, column; char string[]; [int color[, background]]);

Description - Displays the text variable or character string on the screen at the row and column, in the specified color.

oColor and background color are optional parameters. For DOS and OS/2 the color can be any value from 0 to 255, though values 127 and over may blink. Only Windows will use the background color parameter.

oWindows uses colors in the range 0 - 16,777,215. The colors consist of three values: red, green, and blue. They are created by the RGB() function, defined in your program, as follows:

oint white = RGB(255,255,255);

oRGB(char red, grn, blu)

{

return(((blu*65536)|(grn*256)|red);

}

Return Value - None.

See Also - putsl()

Example

main()

{

int row, col, color;

/* Fill the screen with colors. */

for(col = 0; col < 74; col = col + 6)

for(row = 0; row < 25; row = row + 1) {

puts(row, col, "Color ", color, RGB(190,190,190));

color = color + 1;

}

}

 

PutSl

putsl(int row, col, length; char string[]; [int color[, background]]);

Description - Displays the string at the row and column position on the screen. The length parameter specifies the number of characters in the string to be displayed. The color for Concordance normal text is used if the color and background parameters are omitted. Background color is only used by Windows.

Return Value - None.

See Also - puts()

Example

/* Display one screen of the text field. */

showfield(int db, i, offset)

{

int length, row;

wrap(db->i, 75);

offset = findline(db->i, offset, length);

row = 0;

while((offset > 0) and (line < 25)) {

putsl(row, 0, length, addr(db->i, offset));

offset = findnline(db->i, offset, length);

row = row + 1;

}

/* Return the offset of the next line. */

return(offset);

}