Examples: SetIndex


The following example is the trigger processing procedure that runs when the operations for a security task are to be displayed in the Security Task Setup window. The procedure uses the SetIndex procedure to specify the operation to be added to the list. The operation is examined, and the status information is used to control how the LoadListView procedure adds the operation to the list.

in integer dict_ID;
in integer security_type;
in integer security_series;

local sySecurityTaskOperationsState TaskOperationsState;
local long status;


if isopen(window syTaskEntry of form sySecurityTaskEntry) then
	if dict_ID = IG_PROD_ID then
		if security_type = 100 then
			status = Create(TaskOperationsState, table sySecurityAssignTaskOperations) of form sySecurityTaskOperations;
			if status <> OKAY then
				abort script;
			end if;

			if security_series = 1 then
				{Look up the security status of each item as it is added, so
				that the marked or unmarked state can be set}

				{Series 1 Item 1 -- ID is 101}
				call SetIndex of form sySecurityTaskOperations,
					TaskOperationsState,
					'Security Task ID' of window syTaskEntry of form sySecurityTaskEntry,
					IG_PROD_ID,
					101,
					security_type;

				status = Get(TaskOperationsState, GET + EQUAL) of form sySecurityTaskOperations;

				if status = OKAY then
					{User already has access}
					call LoadListView of form sySecurityTaskEntry, "Item 101", 101, security_type, dict_ID, true;
				else
					{User does not have access}
					call LoadListView of form sySecurityTaskEntry, "Item 101", 101, security_type, dict_ID, false;
				end if;

				{Series 1 Item 2 -- ID is 102}
				call SetIndex of form sySecurityTaskOperations,
					TaskOperationsState,
					'Security Task ID' of window syTaskEntry of form sySecurityTaskEntry,
					IG_PROD_ID,
					102,
					security_type;

				status = Get(TaskOperationsState, GET + EQUAL) of form sySecurityTaskOperations;

				if status = OKAY then
					{User already has access}
					call LoadListView of form sySecurityTaskEntry, "Item 102", 102, security_type, dict_ID, true;
				else
					{User does not have access}
					call LoadListView of form sySecurityTaskEntry, "Item 102", 102, security_type, dict_ID, false;
				end if;
			end if;

			if security_series = 2 then
				{Series 2 Item 1 -- ID is 201}
				call SetIndex of form sySecurityTaskOperations,
					TaskOperationsState,
					'Security Task ID' of window syTaskEntry of form sySecurityTaskEntry,
					IG_PROD_ID,
					201,
					security_type;

				status = Get(TaskOperationsState, GET + EQUAL) of form sySecurityTaskOperations;

				if status = OKAY then
					{User already has access}
					call LoadListView of form sySecurityTaskEntry, "Item 201", 201, security_type, dict_ID, true;
				else
					{User does not have access}
					call LoadListView of form sySecurityTaskEntry, "Item 201", 201, security_type, dict_ID, false;
				end if;

				{Series 2 Item 2 -- ID is 202}
				call SetIndex of form sySecurityTaskOperations,
					TaskOperationsState,
					'Security Task ID' of window syTaskEntry of form sySecurityTaskEntry,
					IG_PROD_ID,
					202,
					security_type;

				status = Get(TaskOperationsState, GET + EQUAL) of form sySecurityTaskOperations;

				if status = OKAY then
					{User already has access}
					call LoadListView of form sySecurityTaskEntry, "Item 202", 202, security_type, dict_ID, true;
				else
					{User does not have access}
					call LoadListView of form sySecurityTaskEntry, "Item 202", 202, security_type, dict_ID, false;
				end if;
			end if;

			call ClearRange of form sySecurityTaskOperations, TaskOperationsState;
			call Destroy of form sySecurityTaskOperations, TaskOperationsState;
		end if;
	end if;
end if;


Documentation Feedback