D

<< Click to Display Table of Contents >>

Navigation:  Concordance Programming Language Reference > Functions >

D

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

Day

int day(int birthday);

Description - Extacts the day of the month from the date. The date can be a numeric representation of the date, as returned by ctod(), or a date field.

Return Value - The day of the month (1 - 31).

See Also - month(), year(), weekday()

Example

oneHundred(int billday)

{

text line;

 billday = billday + 100;

 puts(0,0,"100 days overdue is:");

 line = str(day(billday),2,0,'Z')+"/"+str(month(billday)2,0,'Z')+"/"+str(year(billday),4,0,'Z');

 puts(1,0,line);

}

 

DC

text dc(text string);

Description - dc() is used within a sort parameter string to specify a descending order sort. Enclose the entire sort string, or specific fields, within the dc() function to perform the descending or mixed order sort. Any data not enclosed within the dc() function is sorted in ascending order.

Return Value - The parameter string inverted for a descending order sort.

See Also - sort()

Example - See sort() for an example.

 

DDEConnect

int ddeConnect(text Service, text Topic);

Description - Begins a dynamic data exchange (DDE) conversation with another Windows application. Service is the name of an application which can respond to DDE messages. This is usually the program name without the .EXE extension. Topic is the name of a topic recognized by the server. This function is available only in Concordance for Windows.

Return Value - Returns a nonzero handle to that conversation. An error can occur if the application is not running, or if it is running but does not recognize the topic or support DDE.

See Also - ddeDisconnect(), ddeExec(), ddePoke(), ddeRequest()

Example

makeWorksheet()

{

int ddeHandle, i;

text topicList, sheetName;

 /* Establish a link to the spreadsheet. */

 ddeHandle = ddeConnect("Excel","System");

 /* Create a new work sheet. */

 ddeExec(ddeHandle,"[New(1)]");

 /* Retrieve a list of available spreadsheets. */

 topicList = ddeRequest(ddeHandle,"Selection");

 /* Disconnect */

 ddeDisconnect(ddeHandle);

 /* Isolate the name of the first spreadsheet. */

 /* Establish a new conversation based on the spreadsheet, */

 /* this will allow us to modify the spreadsheet.*/

 sheetName = substr(topicList,1,match(topicList,"!",1) - 1);

 ddeHandle = ddeConnect("Excel",sheetName);

 /* Fill it with data. */

 for(i = 1; i < 10; i = i + 1)

  ddePoke(ddeHandle,"R1C"+str(i),str(i));

 /* Make a chart. */

 ddeExec(ddeHandle,'[Select("R1C1:R1C10")]');

 ddeExec(ddeHandle,'[New(2,1)]');

 /* Terminate the DDE conversation. */

 ddeDisconnect(ddeHandle);

 

DDEDisconnect

ddeDisconnect(int ddeHandle);

Description - Disconnects from the dynamic data exchange (DDE) conversation previously opened by using ddeConnect().

Return Value - None.

See Also - ddeConnect(), ddeExec(), ddePoke(), ddeRequest()

 

DDEExec

ddeExec(int ddeHandle, text command);

Description - Uses an open dynamic data exchange conversation handle to send a command to another application. The command depends on the application and topic specified when the conversation was initiated.

Return Value - Success value returned by the server. Generally 0 means the ddeExec() was not processed, 16384 means the server was busy, and 32768 signifies success.

See Also - ddeConnect(), ddeDisconnect(), ddePoke(), ddeRequest()

 

DDEPoke

ddePoke(int ddeHandle, text item, text data);

Description - Sends data to the DDE server application. The item is a value, such as a spreadsheet row and column or database field name, which is recognized by the server. The data is a string containing the data sent to the other application.

Return Value - Success value returned by the server. Generally 0 means the ddeExec() was not processed, 16384 means the server was busy, and 32768 signifies success.

See Also - ddeConnect(), ddeDisconnect(), ddeExec(), ddeRequest()

 

DDERequest

ddeRequest(int ddeHandle, text item);

Description - Sends a dynamic data exchange (DDE) request to the open conversation. This generally retrieves data from the server, though the action taken is dependant on the server, the topic, and the item.

Return Value - The DDE server must return a text value.

See Also - ddeConnect(), ddeDisconnect(), ddeExec(), ddePoke()

Example

int dh;

text listOfFields, field, fieldData;

 /* Establish a link to the database */

 dh = ddeConnect("Concordance","Resumes");

 /* Retrieve a list of fields in the database. */

 listOfFields = ddeRequest(dh,"List of Fields");

 /* Retrieve data from the first field */

 field = substr(listOfFields,1,match(listOfFields,',',1)-1);

 fieldData = ddeRequest(dh,field);

 /* Disconnect from the database */

 ddeDisconnect(dh);

 

Debug

int debug(int mode);

Description - Turns single step debugging on or off. Mode should be 1 to turn debugging on, 0 to turn it off, and -1 to disable it. Debugging can also be turned on and off by pressing [Alt-F1], unless debug(-1) has disabled it.

Return Value - Value of previous setting.

 

Delete

delete(int db);

Description - Marks the current document for deletion. The document isn't removed from the database until it is packed.

Return Value - None.

See Also - deleted(), recall(), pack()

 

IsDeleted

delete(int db);

Description - Marks the current document for deletion. The document isn't removed from the database until it is packed.

Return Value - None.

See Also - deleted(), recall(), pack()

 

DeleteText

int deleteText(db->FIELD; int offset; int length)

Description - The first parameter identifies a field in the database. The deleteText() function deletes a block of text at offset for length number of bytes. This function preserves rich text formatting and properly processes annotations. Any annotations contained by the block of deleted text are also deleted.

Return Value - The number of bytes deleted.

See Also - insertText()

Version - Concordance version 7 and later.

 

DiskSpace

int diskspace(int drive, totalSpace, freeSpace);

Description - Determines the amount of total and free space on the drive specified. The drive should be a letter, such as 'A', 'C', etc.

Return Value - Zero if successful, non-zero if an error occurred or the drive does not exist.

oUpon returning, the variables totalSpace and freeSpace will contain the total bytes available on the disk and the free space remaining, respectively. Allocated space can be calculated with:

int allocatedSpace, totalSpace, freeSpace;

 if (diskspace('C',totalSpace,freeSpace) == 0)

  allocatedSpace = totalSpace - freeSpace.

See Also - chdir(), getcwd()

Version - Version 5.32 and later

 

DocNo

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

Description - Returns the relative document number in the current query. After issuing a first(), docno() would return the number 1, even though the first document retrieved in the query may be the 25th document in the database. Docno() always returns a number relative to the current query set, not a physical document number in the underlying database.

odb must be a value returned by a call to opendb().

oIf the optional parameters document, field, and offset are provided they will contain the same information documented in, and returned by, the first() function.

Return Value - A relative document number. Returns a value less than or equal to zero if there are no documents in the current query set.

See Also - goto(), first(), last(), prev(), next(), prevhit(), nexthit(), recno()

Example

main()

{

int db, document;

 db = opendb(" recipes.dat");

 if (db <> EOF) {

  search(db," chocolat*");

   goto(db,5);

  document = docno(db);

  /* document now equals 5, the fifth

   document located in the search.

   The document's physical position

   in the underlying database may

   be almost any number. */

 }

}

 

DToc

text dtoc(int birthday[; char format]);

Description - Converts the date value to a character string. This function will return the exact date contained in a date field, even if the date is invalid, i.e., 12/00/81 or 99/99/9999. To test for a valid date use:

if (dtoc(db->DATE) <> dtoc(db->DATE+0))

  badDate(db);

else

  goodDate(db);

oThe optional format parameter can be 'Y', 'M' or 'D' to indicate the date format for conversion: YYMMDD, MMDDYY, or DDMMYY. The default format 'M' is used if the parameter is not explicitly set.

Return Value - A character string representing the date.

See Also - ctod()

Example

whatDayIsToday()

{

 puts(12,35,"Today is "+ dtoc(today()));

}