script_params_read()
Description
Reads the script parameters (INI-style settings string) assigned to the currently running script and stores the raw text in the destination array.
Syntax
script_params_read(dest_array[]);
Parameters
Variable | Input |
dest_array[] | Output array where the raw script parameters string (read from settings) will be stored. |
Returns
Return value | Return explanation |
SCRIPT_OPERATION_SUCCESS | Success. Script parameters were read into dest_array. |
-1 | Failed. |
Function call example
Reading script parameters into a buffer
#include <io>
#include <read>
#include <float>
#include <string>
#include <core>
#include <write>
#include <define>
#include <socket>
#include <debug>
#include <script_parameters>
#define INI_FILE_SIZE 200
#define RS232_SPEED 115200
#define WORD_LENGTH WORDLENGTH_8
#define STOP_BITS STOPBITS_1
#define PARITY PARITY_NONE
new ini_file[INI_FILE_SIZE];
main()
{
new ret_val;
Init(RS232, RS232_SPEED, WORD_LENGTH, STOP_BITS, PARITY);
debug_init(RS232);
write_buf(RS232, 16, "Script started\r\n");
ret_val = script_params_read(ini_file);
debug_print("ret_val: %i\r\n", ret_val);
if (ret_val == SCRIPT_OPERATION_SUCCESS)
{
debug_print(ini_file);
debug_print("\r\n");
}
for(;;)
{
Delay(1000);
}
}
Notes and Warnings
The destination array must be large enough to hold the full INI string assigned to the script — if the parameter string is larger than the buffer, it will be truncated.
script_params_read() does not parse the content. Use script_params_ini_val_get() to extract a specific key's value from the buffer.
#include <script_parameters> must be added in order to use this function.