Identifiers within strings




The names of several identifiers appear WITHIN STRINGS!



This dialog appears because the options for camouflaging identifiers specify,
that some character strings can contain references to identifier names.

Please pay particular attention to this step and the following instructions!
It may cause runtime errors that may, because of the later camouflage of identifiers,
be difficult or even impossible to be corrected!



Upper list: Strings that are probably contain a REFERENCE to an identifier.
Words in these source–code lines, that are identical with identifiers,
will be REPLACED by their code name!

Lower List: Strings that are probably NOT contain a reference to an identifier.
Words in these source–code lines, which are identical with identifiers, remain UNCHANGED!

Please check the lists and move incorrectly assigned entries into the other list.


Proceed as follows:

1. Firstly consider the entries in the list above.
    Check if the within the string contained word represents
    a reference to the specified identifier on the right side
    (see below "Background Information").

    If this is NOT the case (it is an accident that the word is indentical to the identifier),
    then select that line and click on "contains NO reference" to transfer it
    into the list below.

    An exclusion rule can be created for text patterns in the source–code
    if this case occurs repeatedly, (see below "Exception rule").

2. Secondly, edit all entries in the list below in the same way.
    Here the question is reversed:
    If a string contains a word that represents a REFERENCE to an
    identifier, then select that line and click on "contains REFERENCE" to transfer it
    into the top list.


Symbols for column "Status":

* Entry has now been assigned manually

> Entry has been assigned to this list manually during a previous program run

+ Entry corresponding to an existing exception rule
(see below "Exception rule")

# Entry is new or modified in comparision to the previous program run (*)
Pay particular attention to these entries!

You can select specific entries with the buttons "changed"
below each list (also via keystroke combination Alt+1 resp. Alt+2).

~ Entry has been hidden temporarily in the current program run (*)

= Entry has been hidden temporarily in a previous program run (*)


(*) According to these entries, you can filter the list also.



Handling of the list:

The list is sorted on the column whose header is highlighted.
To sort on another column, click on its header.
Clicking on the same header a second time reverses its order.


Ctrl + Space: (de)activates all entries in the sort column that have
the same content as the current entry

Ctrl + A: selects ALL entries
Ctrl + N: selects NO entrie

Ctrl + Click: selects several separate entries
Shift + Click: selects a contiguous group of entries

The selection of entries can also happen with:

Letter/number: Next list entry that begins in the sort column
with the respective characters

Key Plus: next selected entry
Key Minus: previous selected entry



Button [contains NO reference] / [contains REFERENCE]

Moving of the selected entries into the respective other list.

The moved entries always appear there at the bottom of the list.
If needed, they can be sorted later by clicking on a column heading.


Button [Undo]

The last entry shift can be undone.
Press the backspace key or click the Undo–Button in the middle between the lists.

Warning! Undo is only possible for the LAST shifting
and only as long as no selection filter has been used
or the lists have not been sorted!


Button [changed]

If there are new or modified entrys in comparision to the previous program run
(marked with # in column "Status")
then you can jump directly to this.

Alternatively, there are also the shortcuts

Alt + 1 (upper list)
Alt + 2 (lower list)


Button [Filter]

Allow the specific choice of entries with the help of certain criteria.
For further explanation, refer to the help for the filter function.


Button [ – ]

Suppression of the currently selected items.
This allows you to increase the clarity while editing.

Lists in which rows are hidden are highlighted in color.

Attention!
Hidden entries are not deleted or ineffective!
They will be unhide and effective again at the latest when leaving the dialog.


Button [ + ]

Fetch back of hidden entries into the respective list.
These are inserted according to the current sort.





Background Information

Some statements and VBA programming techniques require the disclosure of an identifier in textual form
(e.g. the name of a procedure or UserForm).

Example: Application.OnKey  "{F1}",  "Help" assigns the procedure "Sub Help()" the key F1.

'Help' is the name of a procedure and therefore WITHIN the string "Help"
a REFERENCE to an IDENTIFIER.


The same word may occur in another string, WITHOUT being a reference.

Example: MsgBox  "For help please press key F1."

'Help' is simply a word that just happens to be used in the procedure "Sub Help()",
but it is NOT a reference to these procedure.


In camouflaging the identifier of "Sub Help()" the word 'help' changes for example to 'TforU'.
In the first case, the instruction has to be free of syntax errors:

Application.OnKey  "{F1}",  "TforU" because "Sub Help()" is now "Sub TforU()"

If the word 'help' was replaced in EACH string with 'TforU',
the result in the second example would result in meaningless text:

MsgBox  "For TforU press please key F1"


A decision whether or not 'Help' should be replaced
in this case is possible depending on the respective VBA statement.

But when constants are used, this requires an excessive effort:

Example: Const  PROC_HELP = "Help"
Const  MESSAGE_123 = "For help please press key F1"
...
Application.OnKey  "{F1}",  PROC_HELP
...
MsgBox  MESSAGE_123


CrunchCode finds the word 'help' ONLY in those lines where constants are declared.
The entire source–code would have to be analyzed to determine the context for these constants, and decide
whether 'Help' is a reference to the identifier of "Sub Help()" or just simple text.

Finally with the use of more complex programming (such as the provision of messages in dynamic arrays),
this method is absolutely not any more possible because the assignment of texts to instructions takes place
during runtime and cannot be determined in the static source–code.


Therefore, CrunchCode takes the following steps:

1. Determine all text in which words occur that are identical with defined identifiers.

2. Application of string rules (see below) to decide whether a word within a string
   is a reference to an identifier or not.

3. Creation of two lists based on the processing rules:

– REFERENCE–list (above):
  Contains source–code lines which, because of the rules and structures,
  the particular word is (probably) a REFERENCE to an identifier

– TEXT–ONLY list (below):
  Contains all source–code lines in which, because of the rules and structures,
  each word is TEXT ONLY and does not refer to an identifier

4. Examination and correction of the lists by the user.
    The correction is done by marking and subsequent displacement
    of the entries into the other list.

****************************************************************
5. Later, ONLY THE TEXTS OF THE TOP LIST are relevant!
    The identifiers will only be replaced by their camouflage names in these texts .
    The text parts in the lower list remain unchanged.

****************************************************************


HINT: You can easily reduce the number of here listed entries
and avoid complications associated with identifiers within strings,
if you

a) use the so–called Hungarian notation:

    Here, each identifier gets a prefix and like that its type is recognizable
    (e.g.: "strText": "str" = string, "prcHelp": "prc" = procedure etc.).

    Because words such as "prcHelp" do not exist in normal languages,
    it is possible to distiguish within strings clearly between
    normal text and references to identifiers.

b) do not specify names as a string, if it is syntactically possible:

    Example:
    In UserForms are used procedures, whom handed over as parameter
    the name of the respective UserForm:

     Sub XXX(strDialogName As String)
     ...
     End Sub

    A call in the form

     XXX "UserForm1" (identifier–name within a string!)

    can be replaced here by

     XXX Me.Name (no identifier–name, no string)




Exception rule

Words in strings that should not be camouflaged because they are identical with
identifiers by chance only, often occur in characteristic text patterns.

These text patterns can be defined as exception rules,
so that in future such words are excluded from camouflaging.

You can create a new exception rule:

– IMMEDIATELY AFTER MOVING an entry from the upper to the lower list
– if you click in the LOWER list on an entry, which still has no associated rule

This exception rule can then be instantly applied to all entries in the upper list.

Further explanation is in the help for exception rules.

Hint: For the entries in the lower list, which were placed there on the basis
of an exception rule (flag "+"), this button indicates the respective used rule.




String rules

The string rules mentioned above caused by four factors:

1. In that the user moves an entry from one list to another.

    This has priority over all other rules!

Currently shifted entries are marked with *.

    CrunchCode registers each of these transfers and in the future
    these are always assigned to the previously selected list.

Such entries are marked with >

2. By the settings for camouflaging identifiers, given during the program startup
    (see "Options": "Identifiers WITHIN Strings").

    Example:

– If an option states that strings exist that refer to
  PROCEDURE names, then all strings, which contain words identical to
  PROCEDURE identifiers are entered into the (reference) list above.

– If an option states that NO strings exist that refer to
  variable names, then all strings, which contain words identical to
  VARIABLE identifiers are entered into the lower (text only) list.

3. By providing special rules for command lines, where within a string
    an identifier should not be camouflaged.
    (see above "Exception rule"
    or Start menu "Camouflaging names/project" –> "Options" –> "Exception rules").

4. If none of the previous steps has led to a decision to which of the lists the entry should be assigned,
    then CrunchCode will always place it in the UPPER (reference) list.
    Because at first it assumes that it could be a reference.