# # This contains subroutines for use in actions. # # # new_action_result() # # Purpose: This creates a new action result node, intended to be returned from the action (after modification) # as its result when it's done. # # Parameters: action_name: the name of the action # returns the action result # subroutine(new_action_result(string action_name), ( # Compute the full action name string full_action_name = command_line.action; node action; foreach action 'actions' ( if (@action{"shortcut"} eq command_line.action) then full_action_name = node_name(action); ); node result = new_node(); rename_node(result, "SawmillActionResponse"); @result{"Action"} = full_action_name; result; )); #### new_action_result() #### # # action_result_to_xml() # # Purpose: This converts an action result node to XML, suitable for returning from an action as its XML result. # # Parameters: result: the action result node # returns the action result node as an XML string # subroutine(action_result_to_xml_recursive(node result, string prefix), ( prefix . '<' . node_name(result) . '>'; if (num_subnodes(result)) then ( '\n'; node subnode; foreach subnode result ( action_result_to_xml_recursive(subnode, prefix . ' '); ); prefix; ); else @result; '\n'; )); #### action_result_to_xml_recursive() #### subroutine(action_result_to_xml(node result), ( action_result_to_xml_recursive(result, ""); )); #### action_result_to_xml() #### subroutine(action_fail(string message), ( string xml_result = ""; xml_result .= '\n'; xml_result .= 'Failure\n'; xml_result .= '' . message . '\n'; xml_result .= '\n'; xml_result; )); #### action_fail() ####