1 / 9

EGL Sequential File Access

EGL Sequential File Access. This section describes how to access serial (sequential) files from a program. It assumes you understand EGL projects, the language, tools and build-files. Sequential File I/O - Using a Program to Write to a Sequential File.

kemp
Download Presentation

EGL Sequential File Access

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EGL Sequential File Access This section describes how to access serial (sequential) files from a program. It assumes you understand EGL projects, the language, tools and build-files.

  2. Sequential File I/O- Using a Program to Write to a Sequential File  Let’s say that you want to write a program that reads your relational database, processed rows, and writes out an external file (like a report or some other batch process). Here are the steps: • Create a batch program to write to a sequential file • Create a new record of type: serialRecord – which contains a reference to a logical name associated with an external file • Write EGL logic to read and/or write to an external file • Modify the project default Build file. Add a new resource association part • Add an Association element for the external file • Logical (internal) name • File type • (Physical) file name/file spec • Specify for the project default Build file the option to point to the new Resource Association for the external file • Debug or Run the batch program • From the above you can see that much of the work revolves around modifying the project Build Descriptor file. • Up to now we’ve barely used it for anything! That is about to change, but first we’ll create a new batch EGL program.

  3.  Sequential File I/O– New Program – 1 of 2 • From Project Explorer, create a new standalone EGL program, in the \programs\ folder, named: fileWriter • Add two records as shown here (note copy/paste code from the Notes section of the slides) • Serial record – to access a sequential file • Basic record – just for more practice  • Press Ctrl/S – and remove any EGL syntax errors

  4.  Sequential File I/O– New Program – 2 of 2 Add the following business logic  • By copying all of the code from the Notes section of the slide… and replacing all of the code in your new fileWriter program • Press Ctrl/S - and remove any errors • Press Ctrl/G – to generate Java for the program Notes: endOfFile is an EGL reserved word that you can think of as an “enumerated condition” – like an “88-level” in COBOL When the actual end-of-file (past last record of the file) condition happens, the endOfFile condition will be true.

  5.  Add a new Resource Association – 1 of 3 Here are the steps: 1. (From Window menu) Select Show View > Outline 2. (From Project Explorer) Open batchBuildfile.eglbld 3. (From the Outline view) Right click over batchBuild.eglbld - and select: • Add Part... From add EGL Build Part select:  Resource Associations • Click Next > From Resource Associations Part specify: • Name: resAssociation • Click Finish

  6.  Add a new Association to the Resource Association – 2 of 3 Add a new Association: - Click Add Association - (Re)Name the file: custFile - Select: System: win File Type: seqws - Specify the systemName c:\customerData.dat - Select text: YES • Press Ctrl/S Note: if pointing systemName to a directory, it must already exist

  7.  Add the Resource Association to the Build file – 3 of 3  Select: batchBuild file.eglbld • Uncheck Show only specified options and find the resourceAssociations option • Using the drop-down select: resAssociation • Press Ctrl/S

  8.  Debug the Program  From Project Explorer: • Open fileWriter.egl and add some break-points • Right-click over fileWriter.egl and select: Debug EGL Program • Respond OK to all database prompts. • Verify your work: • Follow the logic • View the variable • values

  9.  Verify the External Data File  From Windows Explorer – or My Computer, open: c:\customerData.dat

More Related