Storing Temporary Variables

Within source files, not all lines contain all fields. For example, in the Georgia screen shown below, entity values, such as 0565 0565 Test 3, are presented in the header of each report section after the Bus Area/Dept label, but are not presented in every line. Therefore, entity values must be stored in global variables and assigned to the lines of the source file.

For the Georgia file, to store entity values in global variables, in the Import Formats screen, you assign the following script to the Expression field of the Amount row. The script uses an if.. statement and the string function to determine whether lines contain the Bus Area / Dept: label. If a line contains the label, the script stores the entity value (located in position 33 and including 4 characters) in a global variable. If a line does not include the label, strfield returned.

To use a global variable, define a string variable outside the import function. When assigning a value to the variable inside the import function, designate it as global. By defining a variable outside the function, it is available to any function used in that session.

The global variables remain available throughout the current FDMEE data load process (unlike local variables, which lose their values when the current script is closed). Therefore, values stored from within one script can be retrieved by other scripts.

GeorgiaCenter = “” 
def GeorgiaGetCenter (strfield, strrecord):
    if strrecord[15:31] == “Bus Area / Dept:”:
        global GeorgiaCenter 
        GeorgiaCenter = strrecord[32:36]
    return strfield
The image shows the contents of the Georgia.glo GL file. The entity values are included in a header at the top of each report section.