Variable Substitution part 3
The way a variable is defined can have an impact on the way in which ACL interprets it. Compare, for example, the following two variables:
v_temp1 = 5 + 8
v_temp2 = "5+8"
In the first case, v_temp1 is defined as a numeric with the value of 13. ACL read the equation and interpreted as a numeric equation and preserved the value of the equation. In the second instance, the value "5+8" would be preserved as an ASCII character field. While the first variable will have only one use, the second variable will have two possible uses. First, it can be used as the ASCII characters "5+8". Second, it could be used as the numeric value 13. The way that it is used, will determine which outcome is achieved. If the variable is used with quotation marks, then it will be read as the ASCII values. If it is used without quotation marks, then it will be read a the numeric value 13.
This opens up the door for a number of variations. For example, the expression:
EXTRACT FIELDS v_temp2 as "Amt" "%v_temp2%" as "Name" to TEMP1
Will create two fields AMT and Name. v_temp2 will always be 13, name will always be "5 + 8". But suppose that instead of capturing a numeric equation, you captured a fieldname.
v_temp1 = User_ID
v_temp2 = "User_ID"
How will those two variables be read? Are they the same? No. They are two different values. The first variable will identify the cell contents for the field User_ID and capture that value. So, if the value of the first field is "Porter Broyles" Then v_temp1 will preserve that value, and Porter Broyles will be assigned to v_temp1 until it is actively changed. v_temp2, however, will be more dynamic. V_temp2 is not defined as the field "User_ID" it is defined as the characters "User_ID". Depending on how you use it, you can end up with vastly different results.
EXTRACT FIELDS %v_temp2% as "User_ID2" "%v_temp2%" as "Field_name" to TEMP1
This will result in two fields. The first field will be the contents of the field "User_ID". It will be different on every record (assuming every record is unique.) The second field, "Field_name" will be constant with the value "User_ID".