Program part in EGL source format

You declare a program part in an EGL file, which is described in EGL source format. When you write that file, do as follows:

The next example shows a called program part with two embedded functions, along with a stand-alone function and a stand-alone record part:

  Program myProgram type basicProgram (employeeNum INT)
  { 
    includeReferencedFunctions 
  }

    // program-global variables
      employees record_ws;
      employeeName char(20);


    // a required embedded function
    Function main() 
      // initialize employee names
      recd_init();

      // get the correct employee name
      // based on the employeeNum passed
      employeeName = getEmployeeName(employeeNum);
    end

    // another embedded function
    Function recd_init()
      employees.name[1] = "Employee 1";
      employees.name[2] = "Employee 2";
    end
  end

  // stand-alone function
  Function getEmployeeName(employeeNum INT) returns (CHAR(20))

    // local variable
    index BIN(4);
    index = 2;
    if (employeeNum > index)
      return("Error");
    else
      return(employees.name[employeeNum]);
    end

  end

  // record part that acts as a typeDef for employees
  Record record_ws type basicRecord
    10 name CHAR(20)[2];
  end

For other details, see the topic for a particular type of program.

Related concepts
Parts
Program part

Related reference

Basic program in EGL source format
EGL source format
Function part in EGL source format
Text UI program in EGL source format