DevModify
- Last UpdatedJul 17, 2025
- 2 minute read
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 runtime. 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.
For SQL devices, this function is a blocking Cicode function.
|
NOTICE |
|
SECURITY BREACH VIA SQL INJECTION When using DevModify to change the table or column names used by an SQL device, ensure all names are valid for the database being used to avoid the possibility of an SQL injection attack. If names are provided by user input, ensure they are validated correctly. Failure to follow these instructions can result in equipment damage. |
Syntax
DevModify(sName, Format, Header, FileName, nType)
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.
nType:
A new device type, or -1 to use the existing device type.
|
Device Type |
Device |
|---|---|
|
ASCII_DEV |
ASCII file |
|
PRINTER_DEV |
Printer |
|
dBASE_DEV |
dBASE file |
|
SQL_DEV |
SQL database |
Return Value
0 (zero) if successful, otherwise an error code 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);