Helper functions

Rather than write all of this code every time you want to retrieve a value from a window in another dictionary, consider writing a general-purpose routine. For example, the following function retrieves the value from the specified window.

Function name: GetWindowValue

 

function returns integer status;

in integer prod_id;
in string form_name;
in string window_name;
in string field_name;
out anonymous field ret_val;
optional out integer storagetype;
optional out string compile_errors;

local text code;
local string compile_message;
local integer error_count;

{Build the sanScript code to execute.}
code = "inout anonymous ret_val.";
code = code + "if isopen(form " + form_name + ") then ";
code = code + "ret_val = " + field_name + " of window " + window_name + " of form " + form_name + ".";
code = code + "end if.";

{Execute the code.}
error_count = execute(prod_id, code, compile_message, ret_val);
if error_count = 0 then
	{Success. Return the value.}
	if missing(storagetype) = false then
		storagetype = datatype(ret_val);
	end if;
	status = error_count;
else
	{Errors in the pass-through sanScript.}
	status = error_count;
	if missing(compile_errors) = false then
		compile_errors = compile_message;
	end if;
end if;

The following example uses the GetWindowValue() function to retrieve the value of the Applicant Number field in the HR_Applicant_Tracking window of the HR_Applicant form.

local string appl_number;
local integer result;
local integer datatype;

{Get the Applicant Number.}
result = GetWindowValue(414, "HR_Applicant", "HR_Applicant_Tracking", "'Applicant Number'", appl_number, datatype);


Documentation Feedback