Cicode Programming Reference > Cicode Function Categories > Device Functions Introduction > DevModify

DevModify

Modifies the attributes of a device. The device needs to be closed before you can modify a device.

This function allows you to dynamically change the file name or other attributes of a device at run time. You can use a single device to access many files. For example, you can create a device called Temp with a file name of TEMP.DBF. Using this function you could dynamically change the file name to access any dBASE file.

This function is useful in conjunction with the FormOpenFile() or FormSaveAsFile() functions. (These functions allow the operator to select file names easily.)

When using this function, you should be careful that no other Cicode function is already using the same device. Check the return value of this function before opening the device or you will destroy the data in the device to which it is already attached. If the device is already open, calling DevModify will return an error (and raise a hardware alarm to notify user).

If DevModify returns error, it means it has not modified the device and the device parameters will remain as they were before the call to DevModify.

Use a semaphore to help protect your Cicode.

Syntax

DevModify(Name, Format, Header, FileName, Type)

Name:

The name of the device.

Format:

A new format for the device or "*" to use the existing format.See Format Templates for more information.

Header:

A new header for the device or "*" to use the existing header.

FileName:

A new file name for the device or "*" (asterisk) to use the existing filename.

Type:

A new device type.

Device Type

Device

ASCII_DEV

ASCII file

PRINTER_DEV

Printer

dBASE_DEV

dBASE file

SQL_DEV

SQL database

or -1 to use the existing device type.

Return Value

0 (zero) if successful, otherwise an error is returned.

Related Functions

DevOpen, DevClose, DevSetField, DevInfo, DevAppend, FormOpenFile

Example

! change the file name of MyDev
DevModify("MyDev", "*", "*", "c:\data\newfile.dbf", -1);
! change the fields and file name of MyDev
DevModify("MyDev", "{time}{date}{tags}", "*", "C:\DATA\OLDFILE.DBF", -1);
! change the device to TXT file
DevModify("MyDev", "*", "*", "C:\DATA\OLDFILE.TXT", ASCII_DEV);

See Also

Device Functions