# Assignment

= EQUAL SIGN

Syntax:

Then: f = v

"f" equals a real field, dummy field, or filename alias

"v" equals value to be assigned

"v" is an expression (only requires surrounding quotes around literal strings)

Description:

The equal sign operator (when used on a "then" line) assigns the value of the expression on its right to the field on its left. Assignments can be made to real field and dummy fields. Assignments can NOT be made to system maintained fields, only the system can do this.

NOTE: It is important to understand that the entire expression on the right of an equals sign will be calculated (fully processed to its actual value) before it is assigned to the field on the left.

In the case of numeric calculations, all operations are performed first (according to standard rules of precedence), then the assignment of the final value is made.

Examples:

Then: aa = "12"/"4"

In the above, field aa will be set equal to "3" not "12"/"4".

In the case of string operations, all manipulations and substitutions are made first and then the final value is assigned.

Then: aa=sales(12) { "," < sales(13) < sales(14)

In the above, the value of the three fields from the sales file will be joined in the designated manner and then assigned to the field aa.

VERY IMPORTANT: While it appears that filePro processing tables are working with algebraic equations, they are NOT. In algebra, the following would not be valid or correct:

Then: aa = aa + "1"

How could something be equal to itself plus 1? It can't. At least not in algebra and probably not too often in the real world either, but in filePro it makes perfect sense, and is perfectly legal. The above statement means take the current value of aa, add 1 to it and assign that newly calculated value to aa. This is changing the value of aa to something else, it is an assignment, not an equality.

NOTE: It is a quirk of filePro that the = operator is allowed on "if" lines. When used on "if" lines it is working as a comparison tool. In other words:

If: 4 = "Smith"

is the same as

If: 4 eq "Smith"

The above says "Does the value in field 4 match the value "Smith". If the fields/expressions being compared are numeric, the compare is a numeric compare. If the fields/expressions involved are strings an ASCII compare is performed.

HINT: It is STRONGLY suggested that you NEVER use the = (equals operator) on "if" lines. Always use "eq" instead. It will work for both numeric and string compares just as the equals operator, but you will never confuse it with = on a then line. You will never mistake it for an assignment. Your code will be easier to read. Incidentally, "eq" can never be used on a "then" line to replace the = operator. The strange behavior only works in one direction, this is another reason for not making use of the = operator quirk and use it only on "then" lines where it really belongs.