Documentation
IPS_SetScriptFile
bool IPS_SetScriptFile (int $ScriptID, string $FileName)
Parameters
| ScriptID | ID of the script |
| FileName | File name of the PHP file (relative to the "/scripts" folder) |
Returns
If the function succeeds, it returns TRUE, otherwise FALSE.
Description
This function binds the file with the name FileName to the script with the ID ScriptID. Usually, the file name of a script consists of the ID and the extension ".ips.php". The use of this function enables different file names. The file must already exist, otherwise the function fails with "File #... does not exist".
The file name is not connected to the script name, which is shown in the object tree. The script and file name can be completely different. The ID of the script is also unaffected by this function. Neither the name nor the script file name can be used to directly identify the script. The numerical ID of the script is used for direct identification.
Example
$ScriptName = "Example.ips.php"; //script file
$ScriptID = IPS_CreateScript(SCRIPTTYPE_PHP);
IPS_SetName($ScriptID, "Example");
$Script = IPS_GetScript($ScriptID);
//Rename the file to $ScriptName
rename(IPS_GetKernelDir().'/scripts/'.$Script['ScriptFile'], IPS_GetKernelDir().'/scripts/'.$ScriptName);
//Assign the new file name ("Example.ips.php") to the script
IPS_SetScriptFile($ScriptID, $ScriptName);