<< Click to Display Table of Contents >> Navigation: Concordance Programming Language Reference > Functions > L |
The following topic discusses the Concordance Programming Language (CPL) functions that begin with the letter L. For more information on CPL functions, see Functions, About the Advanced Programming Features, and About CPL Functions.
int last(int db, document, field, offset); |
•Description - Advances to the last document retrieved in the current query set. On return the document, field, and offset parameters, if they are passed, will contain the relative document number, field number and offset into that field that indicates the offset of the retrieved word. The document's number is its position relative to other documents in the query. Some searches, such as query zero, will return field values of zero. Check the field parameter before using it to access a field's data.
oThe hit list is positioned on the first hit for the last document. Additional calls to nexthit() will retrieve information about the other items in the hit list.
•Return Value - Returns the physical document number of the last document retrieved by the query. Information about the hit word is returned only if one or more of the document, field, and offset parameters are passed.
oReturns a value less than or equal to zero if the query or database is empty, or if the document could not be read.
•See Also - first(), next(), nexthit(), prev(), prevhit(), count(), docno()
int len(text note); |
•Description - Determines the length, in characters, of the text variable, character array, or database field. The results are not valid for numeric or date fields.
•Return Value - Integer length in bytes of the parameter.
•See Also - sizeof()
int load( int db; char filename[]; [int comma, quote, newline; [int row, column, color]]); |
•Description - Loads the database from the parameter file name. The file must contain database records in delimited ASCII format.
oThe fields loaded, and the order in which they are loaded, is set by assigning a number to the "order" entry of the field definition. You can assign any number from -128 to 127, but Concordance will only load fields with consecutive numbers from 1 to the last field number defined in the database. You should always renumber the fields before loading the database. Concordance uses, and changes, the field order in several full screen modes including Print, Load, and Unload. See the for-loop example below.
oThe optional parameters, comma, quote and newline, are used to delimit the fields during the load process. If they are left off Concord ance will use its internal ASCII default values, 20, 254 and 174 respectively. It is recommended that you leave the comma, quote and newline parameters off if transferring data between Concordance databases. However, they are required if the screen status parameters are passed.
•Return Value - A count of the number of documents loaded from the delimited ASCII file. A count less than expected can indicate a disk full condition, or that the user pressed the [Esc] key to cancel the operation.
•See Also - unload(), loadfs(), unloadfs(), import()
Example
main() { int db, i, count; /* Permanately sort all records in the */ /* database in ascending order. */ if ((db = opendb("helpdesk")) <> -1) { sort(db,"db->DATE"); /* Renumber all fields to unload in */ /* order. This step is necessary */ /* since the order previously set, */ /* or set in Print, is retained */ /* until reset. Never assume the */ /* order includes all fields. */ for(i = 1; i <= db.fields; i = i + 1) db.order[i] = i; count = db.documents; if (unload(db,"helpdesk.dat") <> count) puts(0,0,"Error unloading database."); else { zap(db); if (load(db,"helpdesk.dat") <> count) puts(0,0,"Error reloading data."); else { erase("helpdesk.dat"); index(db); } } closedb(db); puts(0,1,"Press any key to continue..."); getkey(); } } |
loadfs(int db); |
•Description - Invokes Concordance full screen load mode. The screen is automatically saved before entering Load, it is restored after returning.
•Return Value - None.
int lockdb(int db); |
•Description - Will attempt to lock the current database for exclusive use. This will always succeed in single user versions of Concordance. Network versions will fail if another user is accessing the database. The database cannot be accessed by other network users while it is locked.
oThe database is automatically locked and unlocked by Concordance during pack and modify procedures.
•Return Value - Returns a zero if the lock operation was successful, a nonzero value if unsuccessful.
•See Also - unlockdb()
int lockdoc(int db); |
•Description - Will attempt to lock the current document in the network version of Concordance. This has no effect in non-network versions of the program. A locked document cannot be changed and saved to file by other users. Reading another document, or using one of the Concordance full screen functions, such as loadfs() or global(), will unlock the document. However, the document is automatically locked again when it is reloaded.
oDocuments are automatically locked by Concordance when read into memory. Your program should unlock them as a courtesy to other network users if you do not intend to edit or modify them.
•Return Value - Returns a zero if the lock operation was successful. Concordance will make ten attempts to lock the document before giving up.
•See Also - unlockdoc(), locked()
int locked(int db); |
•Description - Determines if the current document is locked. A locked document can be used, edited, and modified, but none of the changes will be saved to file. Documents are automatically locked in network versions of Concordance, unless they have been unlocked by a call to the unlockdoc() function.
•Return Value - A zero if the document is not locked. A value of one if you have locked the document by a call to lockdoc(), and a value greater than one if the document is locked by another user on the network. Non-network versions of Concordance will always return zero.
•See Also - lockdoc()
Example
getdoc(db,document) { int trys; /* Try to get document up to 10 times. */ trys = 10; readdoc(db,document); while((trys > 0) and locked(db)) { readdoc(db,document); trys = trys - 1; } lockdoc(db); /* Return a nonzero if we got a lock. */ return(locked(db) == 1); } |
text lower(text author); |
•Description - Produces a duplicate of the variable in lower case. Does not change the original.
•Return Value - The parameter in lower case.
•See Also - capitalize(), upper()
Example
main() { text author; author = "E E Cummings"; puts(0,0,lower(author)); puts(1,0,author); } |
Output
e e cummings E E Cummings |
int lseek(int handle, offset, mode); |
•Description - Moves the next read or write position in the file to the specified offset. The mode indicator tells lseek how to move, as follows:
oMode 'B' Move relative to the beginning of file.
oMode 'P' Move relative to the present position.
oMode 'E' Move relative to the end of the file.
oUse offset = lseek(handle, 0, 'P') to determine the present location in the file.
•Return Value - The new position in the file, as an offset in bytes from the beginning of the file. The first byte in the file is at offset zero. Returns a -1 if the move was unsuccessful.
text ltrim(text string); |
•Description - Removes all leading white space from the text variable, character array, or field. White space consists of spaces, tabs, carriage returns, and line feeds.
•Return Value - Returns a duplicate of the string, does not modify the original.
•Version - Version 6.0 and later