Skip to content
Mandla edited this page Sep 25, 2017 · 14 revisions

TemplateActivation

The TemplateActivation module controls the now deprecated form on the Form sheet of the freeform excel file. It's functionality has been replaced by the pop up form controlled by the ufrmMain Form.

TemplateGlobalFunctions

The TemplateGlobalFunctions module contains the functional code that is shared across all the forms.

Function Description
ClipBoard_SetData() and CopyTextToClipboard() The initial section declares the constants and functions required to enable the two functions used to copy data to the clip board, which follow directly.
InitialiseForm() Sets the CURRENT_FORM_OBJ and CURRENT_FORM_ID to refer to the object and form id of the most recent form to have been clicked. These global variables are then used throughout the code base for efficiency and modularity.
GetInputValue() Provides a standard interface from extracting data from different field types.
CheckRequiredInputs() Loops over the input fields of the active form, and checks whether those that are required have been filled.
CheckSpelling() Loops over the input fields of the active form, and checks for spelling errors in spell check specified fields.
CheckSpellingWords() Deprecated.
ValidateTimeInputs() Evaluates whether the input in a time field is valid, according to the 24 hour hhmm clock format. This function does not throw an error for an empty input, as this would require all time inputs to be mandatory.
ValidateComboBoxes() Ensures that the input in combo boxes is either empty, "YES", or "NO" (Case insensitive). An exception exists for the "Inward Crew/Stock Checked" combo box on the TO form, which is also allowed to have "N/A" as a valid input.
SetActiveChildFields() When a combo box has it's value set or changed, this function de/activates all it's child fields according to the relationship specified in the initOptionFields array.
SetErrorText() Sets form error text field using standardised text for various error types.
isInt() Evaluates whether an input value is numeric.
isRadio() Determines whether an input is a combo box or not.
extractTextAndCopy() Formats input text once error checking is complete.
ShowTextMenu(), MakeMenu(), and TextMenu() Enable the use of a right click menu on forms, and copy and pasting content using this menu.

TemplateCopyLogic

The TemplateCopyLogic module defines the code that runs when the copy button is pressed on a form, in the RunCopyLogic() function. It handles the calls for error checking, input formatting, and copying to the clipboard by calling functions in the TemplateGlobalFunctions module. It also feeds errors back to the form, updating label colours and error text for clarity.

ConstParams

The ConstParams module outlines the relationships and specifies the structure of each form. When changes are made to the application, almost all modifications to the code base occur in this file. As such, it is structured to be as easy manipulated and straightforward to understand as possible. It is broken down into four sections, which are explained in the rest of this chapter.

Universal Constants

The first section in this file specifies the constants that are not exclusive to any particular form. They are declared for convenience as well as for clarity and readability. The only cause for change would be when additional forms are created, at which point NUM_FORMS would need to be incremented. Additionally, a new form name constant would need to be created with the FM_ prefix. This constant would then be used to configure the necessary parameters and specifications for the new form throughout the rest of the ConstParams module.

Form Constants

The form constants section is divided into two sub-sections. The first lists all the fields on that form, assigning the value of their order in the form (which corresponds with the number in the field's form ID) to a moniker that allows each field to easily be recognised when handled everywhere else in the code base.

The second sub-section assigns an additional moniker to those fields that are option fields, enabling a forms option fields to be iterated through in a convenient manner.

' Eg. Form Constants for TO Form
Public Const TO_INP_CTCHECKED = 1
Public Const TO_INP_SHOWS = 2
Public Const TO_INP_SSM_LOG = 3
...

Public Const TO_OPT_CTCHECKED = 1
Public Const TO_OPT_SSM_LOG = 2
...

Note: Both of these sections must be updated when fields are added or removed to a form. Additionally, the values of the fields that follow must also be adjusted.

General Params

There are seven general parameters for each form, some or all of which will need to be updated when changes are made to the form they refer to.

Field Description
NUM_OPTS The number of option fields (combo boxes) on the form
NUM_FIELDS The number of fields of all types on the form
NUM_COMMAS The number of line breaks in the form output
FULL_RANGE The cells in the field sheet used to contain this form's input and titles
CELL_RANGE The cells in the field sheet used to contain this form's input
X_OFFSET Horizontal offset of this form's cells in the field sheet
Y_OFFSET Vertical offset of this form's cells in the field sheet

Parameter Array Initialisation

Six arrays are used throughout the application to enforce certain parameter types and conditions that dictate form input. These arrays correspond to the following series of initialisation functions whose content must be configured to match their respective forms. The arrays are sized automatically according to the respective NUM_FIELDS value specified in the General Params section, and each fields moniker can be used to specify whether it is active for that particular array's purpose:

' Set field CTCHECKED in FO as a required input
requiredInputs(FO_INP_CTCHECKED) = 1
  • initRequiredInputs()

    Specifies which inputs will throw errors if not filled on a particular form.

  • initSpellCheckedInputs()

    Specifies which inputs have active spell checking.
    When a spell checking error is thrown, field is highlighted but incorrect text is not underlined.

  • initTimeTextInputs()

    Specifies which inputs exclusively take time values formatted according to four digit 24h clock.

  • initLineBreakList()

    Specifies which form fields to add a line break after in the input that gets sent to the clipboard.

  • initOptionInputs()

    Specifies which fields are option fields (combo boxes), which require a 'yes' or 'no' input.

  • initOptionFields()

    Specifies which option fields have child fields.
    Allocates child fields to their parent field.
    Establishes whether child fields become activated on 'yes' or 'no' input:

      CHILD_NRM constant: child is active when parent is active.  
      CHILD_REV constant: child is active when parent is inactive.  
    

Errors

Errors are accumulated in the errorTypes array. This array contains six integers, representing errors of different kinds, in order to facilitate the subsequent error messages that get displayed on the form. It is filled in the functions defined in the TemplateGlobalFunctions module.

For errors defined by a custom set of conditions (such as particular combinations of fields on a form that must be filled in, or where at least one must be filled in), the CheckSpecialErrors() is used. This function has a space for custom error conditions to be defined for each form, assigned a type, and checked against the current submitted input.

Error messages are assigned in the TemplateCopyLogic() function, terminating the function before any content is copied to the clipboard so that the user can rectify the problematic input. These messages are chosen according to the different error types that have been accumulated. These error types are defined in the ConstParams module, and are described below.

Type Description
ERROR_TIME Invalid value entered in time field
ERROR_MULTI Particular combination of inputs needed
ERROR_NOT_YES Field requires a positive response
ERROR_REQUIRED Required field left empty
ERROR_SPELLING Spelling error made in given field
ERROR_INVALID Invalid option entered into combobox

Note: The ERROR_MULTI error type has no default associated message, and when used for a custom error, requires the accompanying error text to be manually created.

Clone this wiki locally