IBM Z and LinuxONE - IBM Z

IBM Z

The enterprise platform for mission-critical applications brings next-level data privacy, security, and resiliency to your hybrid multicloud.

 View Only

Update EGL functions not to utilize the 'return’ statement when the function’s return type is ‘void’

By Dionne Nerissa posted Wed October 18, 2023 05:59 AM

  

The EGL return statement exits from a function and returns a value to the calling function. The return statement controls the next statement that follows the function call.

In this blog, we shall see what happens when the EGL function code with a return statement is null or void, and we will check the response when we select/clear the option “Error when omitting return statement” in RBD Windows preference.

Steps to create and run void function code in Java:

Step-1: Create a JAVA project.

Follow the below steps to create a java project:

1. Navigate to File-->New-->EGL project.

2. EGL Project window will appear.

3. Enter the Project name.

4. Select the General Project option.

5. Select Java in the Target runtime Platform.

6. click Next and then Finish.

7. Right-click the EGL source in the general project.

8. Go to New-->Program.

10. Enter the Package name and Program name.

11. Click Finish.

12. Simple code has been added with a null or void function.

Step-2: Enable the “Error when omitting return statement” option.

Follow the below steps to enable the Error when omitting the return statement option:

1. Navigate to Window-->Preference.

2. Preferences window will appear.

3. Go to EGL.

4. Select Error when omitting return statement checkbox and click OK.

5. Click Apply and then OK.

6. RBD flags this line as an error as the user coded using the void function.

7. The user is unable to generate the code as the code error is generated using the return void function.

Step-3: Disable the “Error when omitting return statement” option.

Follow the below steps to disable the Error when omitting the return statement option:

1. Navigate to Window-->Preference.

2. Preferences window will appear.

3. Go to EGL.

4. Clear the Error when omitting return statement checkbox and click OK.

5. Click Apply and then OK.

6. Now, the error disappears as it accepts the Void value.

Step-4: Run the generated code on the JAVA application.

Follow the below steps to run the generated code:

1. Go to Project Explorer.

2. Under the Project Explorer, expand EGLGEN/Java Source.

3. Right-click .java file.

4. Select Run As.

5. The code is generated, and the output is displayed on the console.

Thus, this RBD feature helps to omit the Void statement or a function in the code.

Dionne A Nerissa

QA - Senior Software Engineer

0 comments
13 views

Permalink