How To

  • Editing a File
  • Starting the Record Editor
  • Create a new Record Layout
  • Create a Record Layout for a File via the Wizard
  • Create a Record Layout via Definition Screens
  • Record Layout Definition
  • Field Records
  • Child Records
  • Extra Panel
  • Defining Combo Field
  • Edit a Record Layout

  • Combing / splitting Screens.
  • Child Record Screen
  • Dates
  • Set the Date Display Format
  • Defining Date Type
  • Using Comboboxs
  • Creating a Combobox List
  • Define a Combo Field
  • Combobox in the Editor
  • Sort Trees
  • Starting a Sort Tree view
  • Record Trees
  • Creating a Record Tree View
  • Velocity
  • Installing Velocity from RecordEditor Download
  • Installing Existing Copy of Velocity
  • Writing a Velocity template for use in the RecordEditor
  • Exporting using a Velocity Template
  • Script Support
  • Introduction to Scripting
  • Adding another scripting Language
  • Running Macro's (scripts)
  • Variables / Functions available to scripts
  • Creating new display
  • Executing Saved Tasks
  • Update Scripts
  • Other Example Scripts
  • Saving a Function in the RecordEditor
  • Changing the Look and Feel or Icons
  • Looks and Feel Tab
  • Icon Tab
  • Setting up for Linux
  • Screen Position
  • Looks and Icons
  • Improving the running of RecordEditor HSQL
  • Setting the Default DB
  • Embedded HSQL DB Definition
  • Embedded DB options
  • Big Files
  • Java Considerations
  • Large File Model
  • Parameters
  • Define a New Field Type

  • How To


    Editing a File


    Starting the Record Editor

    The Record Editor can either be started from

    When the Record Editor starts, it displays the Edit Start Screen

    Fields on this screen are

    Field

    Description

    File

    Name of the file to edit, you can select a file by using the Find File button to the right.

    Database

    The system stores it's record definitions in a database. The system can also connect to multiple Databases. This Combo allows you which DB to use. You could have different Test / Production Layout DB's.

    System

    The Record Layouts can be grouped into different systems. This Combo Box is used to select a specific System.

    Record Layout

    The Record Layout used to format the file. Only layouts belonging to the selected System (above) are displayed.

    Note: A Record Layout describes the format of a file, each layout consists of either

    • A series of fields.
    • A serious of record (which intern consist of a series of fields).

    Buttons on the Screen

    Button

    Description

    Choose File

    Start the File Chooser dialogue which will navigate the File system and the user to choose a file.

    Reload

    Reloads System and Record Layout details from the database.

    Layout Wizard

    Start the Record Creation wizard. This wizard displays the file and lets you select the fields (by clicking on the first character in the field). See for more detail.

    Note: This option is only available in the Full Editor.

    Create Layout

    Bring up the Record Layout Creation screen. See "Record Layout Definition" for more detail.

    Note: This option is only available in the Full Editor.

    Edit

    Edit the file.

    Browse

    View the file, but no changes are possible.


    Create a new Record Layout


    Create a Record Layout for a File via the Wizard

    The easiest way to create a Layout for a file is to use Layout Wizard. To do this:

    1. Start the Full Editor.

    2. Enter the filename which you want create the layout for (you can use the find file button to search for it if need be).

    3. Press the Layout Wizard button circled in red in the picture below

    4. On the first wizard screen you enter:

      File Structure

      Format of the file, for Windows/Unix text files Default Reader is fine

      Layout Name

      Name of this new Record Layout

      System

      System this layout belongs to. This field is used group record layouts together. You can update the systems by selecting the Edit Layout --> Edit System Table drop down menu.

    5. The second Layout Screen displays the first 30 records on the file. You indicate the start of a field by clicking on the starting column. To remove a field click on the starting column again. Each successive field will have alternating background color.

    6. On the final screen you enter field names and field types.


    Create a Record Layout via Definition Screens

    From both the Full Editor and the Record Layout Edit programs you can select Create Layout from the Record Layouts drop down menu.

    You can then create the layout on the "Record Layout Definition" screen.

    Note: In the Record Layout Edit program you can also select the Create Record Layout menu option.


    Record Layout Definition

    The record layout Definition screen is used to create new Record Layouts or edit specific layouts.

    The fields on this section of the screen are:

    Field

    Description

    Buttons

    The buttons at the top of Record Screen Save, Create, Repeat, Delete and reload Record Details to/from the Database.

    Record Name & Description

    Self Evident

    Record Type

    There are 3 basic Record Types (+ binary versions of these):

    Record Layout

    A normal record consisting of a one or more fixed length fields.

    Delimited

    Standard Delimiter (i.e. Comma or Tab Delimited) Record. Delimiter files are only partially supported (no updates allowed).

    Group of Records

    The record consists of a Group of other records. Typically there is a field that determines what record to use. It is common for a file to contain

    • A File Header Record
    • Many Detail Records
    • A file trailer record

    This would be a good candidate for using a Group of Records. In this case you would define 4 records:

    • File Header Record
    • Detail Record
    • Trailer Record
    • Master Record (Group of Records) that references the three previous (child) records.

    See "Child Records" for the Child Record Definition screen section.

    System

    System this Record Layout belongs to. You can Change Create new systems by updating the System Table via the

    Lines to Insert

    This is the lines to insert in the Field Table / Sub-Record Table when the insert button (just below) is pressed.

    Table Buttons

    The second row of buttons refer to the Field Table / Sub-Record Table immediately below the buttons

    Record Details

    Lastly we have a Tab Box holding the "Field Records"/"Child Records" tables + the "Extra Panel". These panels define record details.

    Note: The "Child Records" panel is displayed when Record Type=Group of Records or Group of Binary records Records otherwise "Field Records" is displayed.

    Field Records

    This panel is used to define the records fields. Fields in the Table are:


    Field Description
    Position Position in the Record. The start of the record is Postion=1 and not 0 as in C / Java.
    Length Length of the field in bytes. Leave blank for Comma / Tab (etc) delimited files
    Field Name Name of the field. This is the column/row name used for this field in the RecorEditor
    Description Field Description. This is used as a Column Header Mouse over in the Record editor. For example if the description was entered as

    Then if you hold the cursor over the column heading in the RecordEditor you get

    Field Type Type of Field. See for details.
    Decimal Pos Number of places after the decimal point
    Cell Format Formatting to be applied to this field.
    Parameter User parameter's. This is a value that can be used by user written types (e.g. for generic Combo or Date Routines).
    Default Value Information only, Not currently used (relates to work).
    Cobol Name Information only, Cobol Field Name
    Field Id Do not Change. It is the field key and is displayed for my testing.

     
    

    Child Records

    This panel is displayed when Record Type=Group of Records or Group of Binary records Records. Fields in the Table are:


    Field Description
    Child Record The child record of the Current parent record
    Field Start Not Currently used
    Field Field that determines which record to use. In the above example:
    1. The records DCR0470 S11 .. S14, O21 each contain a field Record Type
    2. When editing a file where Record Type="S11" then the RecordLayout of DCR0470 S11 would be used.
      While if Record Type="S13" then the RecordLayout of DCR0470 s13 would be used.
    FieldValue Field value that the Field above is tested against.

    Extended Record Selection Button - Starts the Extended Record Selection dialog
    Tree Parent Logical Parent Record for the record. This can be used to build a Tree using the Record Layout Tree option of the View menu in the RecordEditor

    Note: if Field is blank and FieldValue=* then this is the default record.

     
    

    Record Selection Screen

    To start the Record selection editor Press the appropriate button on the record group screen:

    On the record Selection you enter fields and the criteria

    For the Field, operator and value fields just enter the values. For the And / Or value you can change by clicking on the And / Or, it will swap

    The screen only supports simple expressions of the form

            (     field1 = value1
              and field2 = value2
              and field3 > value3
             )
          or (    field4 < value4
              and field5 > value5
             )
          or (    field6 = value6
              and field7 > field8
                 ..........
     
    

    The system only supports simple Or ~ And boolean expressions. It does not support complicated expressions or And ~ Or boolean expressions.

    If Field values are entered at the Group level They will be included as well.

    The above will be interpreted as

           Record Type = S1
      and
          (
              (    Case Pack id  = P
               and Pack Qty      > 0
              )
           or (    Case Pack id  = S
               and Pack Qty      < 0
              )
          )
     
     
    

    Extra Panel

    On the extra panel contains an adhoc mixture of options


    Field Description
    Cobol Copybook Cobol Copybook name (if imported from a Cobol/XML Copybook). When a Cobol copybook is imported the LayoutEdit will replace an existing file with the same name.
    Font Name Font Name to be used. If it is blank, the System default font will be used. A typical use might be to display Native mainframe data on a PC.
    Delimiter Delimiter to use in Delimited files (i.e. comma, tab etc).
    Quote Quote character to use in delimited files.
    Record Separator Record Separator to use.
    default Use the computers normal (or default) line separator.
    <crlf> Windows style separator.
    <cr> Unix/Linux file separator.
    <lf> Macintosh line separator.
    File Structure Structure of the files. Controls which IO routines are used to read / write the file. File Structures are defined in Table 5.

    Defining Combo Field

    To use a Combo List (Say AmsPoDownloadType) you must

    1. Set the Cell Format to Combobox

    2. Enter Combo list in the Parameter Field


    Edit a Record Layout

    To edit a Record Layout (say Price) you will need to


    Combing / splitting Screens.

    By default the record editor will show child views as separate tags on the main screen:

    It is possible to have each view be created in a separate Screen (as it was prior to version 0.90) by selecting the Create separate screens option below (note to reach this screen select Edit >>> Edit Options)

    You can dock / undock screens using the widows or right click menu's.

    and

    The options are

    Undock Tab

    Move tab to a separate screen

    Undock all tabs

    Move all tabs into separate screens

    Dock Tab/screen

    Add the current screen as a tab onto the main screen

    Dock related screens

    Combine all the screens for the current file as tabs on the one screen.

    Show Child Record

    Create a "child record screen" that will display the currently selected record this is usefull in multi-record files and files with a large number of fields. See "Child Record Screen"

    Remove Child Record

    Remove the child record from the list screen.


    Child Record Screen

    Record List Screens can now have a "Child Record Screen" which displays the record selected in the List screen


    Dates

    All dates get converted to Java's Date Objects. If a field is not a valid date, it will not be converted to a date and will not be displayed.

    You should only use Dates

    In other cases use a Date Format.


    Set the Date Display Format

    Date Display format can be set using the Edit RecordEditor Startup Properties program. Go to the Other Options tag and update the DateFormat variable.

    Alternatively you can edit the properties file directly (with an editor like jEdit). This file file will be in <properties Directory>/Recordedit_<version>/Params.Properties where

    <properties Directory>

    Where program properties are held. On Windows XP it will be Documents and Settings/<user name>.

    <version>

    Is MSAccess or HSQL or Generic depending on which version you installed

    SignificantCharInFiles.1=6
    DateFormat=dd.MMM.yyyy
    DefaultFileDirectory=<install>/SampleFiles/*
    


    Defining Date Type

    There is now an option to define Date Types to the RecordEditor.

    The fields are

    Type Name

    Name of the Types as you will see it in the Layout Editor.

    Base Type

    What is the storage Format, for normal Text files choose Char, but in binary files you can use Binary Integer, Mainframe Packed Decimal etc.

    Date Format

    Format of the date (dd - Day, MM - Month, yy - Year etc). This field is Case Sensitive. Day and Year are lower case, Month is uppercase (mm is minutes).

    Sample Formats


    Format Result
    MMddyy For US style dates eg 310199
    dd.MMM.yyyy For dates like 31.Jan.1999
    dd/MM/yyyy For dates like 31/01/1999


    Using Comboboxs


    Creating a Combobox List

    Take the Create Combo option from the Layout Editor

    Next Enter the Combo Details:

    Note: The Combo Type controls wether the user is preseneted with a list of values or a description of the values. Possible values are:

    Standard Combo

    The user will be presented with a list of possible values.

    Key / Value Combo

    The user will see the Combo Value but file will be updated with Combo Code.


    Define a Combo Field

    Next you need to you define the ComboBox in a Layout Definition. Please note you need to select a Cell_Format of ComboBox Format, ... and enter the Combo List Name in the Parameter field. In this example it is AmsPoDownloadType.

    You can use the Parameter Popup to select the layout:


    Combobox in the Editor

    Now when you edit the file, the Record Type field is displayed as a combobox

    It can be updated by selectiong from the various options

    Finally as seen on the Record Screen, the Data Values is quite different from the Text value.


    Sort Trees

    Sort Tree view is a way to summarise the Data in a File. The program will sort the file and group records with the same sort Keys together to form a Tree. Longer Term I hope to display a Summary Record for each Tree Node.


    Starting a Sort Tree view

    First select the Sorted Tree View option of the View Menu.


    Next Enter the Sort fields


    Finally the values of the Sort Fields (in this case the Australian States and Location Type) form the Tree Nodes:


    Record Trees

    Record Tree view builds a Tree View based on the logical relationship between records in a file.

    For example the Ams PO file consists of 3 records

    PO Header

    Purchase Order Summary record, it holds Purchase order details like PO number, Supplier etc. Each PO record has one or more Product Records

    Product

    Product/DC summary. It holds Product / DC Details. Each Products Record can have multiple Store Allocations records.

    Store Allocations

    Holds Store Allocations (i.e. Quantity allocated to each store) organised in array.

    Logically records in the Ams PO file are arranged like:


    Creating a Record Tree View

    The first step is to select the Record Based Tree option on the view Menu:


    You then fill in the Parent record for each Record Type and press the Build button


    The RecordEditor then creates a Tree View with each PO represented as a Tree Root:


    Velocity

    Velocity is basically a fancy mail merge program. It allow you imbed variables + basic logic in a File. Velocity will replace a variable with its value creating a generated document. Velocity is good for creating web pages or XML documents.

    If you install velocity into the RecordEditor you can export selected lines using Velocity


    Installing Velocity from RecordEditor Download

    To install Velocity you must

    1. download the Velocity ZIP file from the RecordEditor site.

    2. Unzip the file into the RecordEditor lib directory, On Windows this will be

      MsAccess Version

      C:\Program Files\RecordEdit\MSaccess\lib

      HSQL Version

      C:\Program Files\RecordEdit\HSQL\lib

      HSQLDB Version

      C:\Program Files\RecordEdit\HSQLDB\lib

      Generic Version

      C:\Program Files\RecordEdit\Generic\lib


    Installing Existing Copy of Velocity

    To install Velocity you need to

    1. Have a version of Velocity on Your PC

    2. Add the 2 Jar files velocity-1.4.jar and velocity-dep-1.4.jar (where the velocity version is 1.4) to the RecordEditor using the Edit RecordEditor Startup Properties program.

    3. Set the Velocity Directory in the Edit RecordEditor Startup Properties program.


    Writing a Velocity template for use in the RecordEditor

    The RecordEditor present all the records selected by the user in a list called $records. You can loop through this list with Velocity foreach command as follows.

    19:   #foreach( $rec in $records )
                 .... 
    29:   #end

    You can access a fields value using the getField("Field-Name") parameter as follows -

         ${rec.getField("Brand Dc No Rh")}

    Sample Velocity Template for use in the RecordEditor

    10:<table border="1">
    11:  <TR>
    12:    <TH ALIGN="LEFT" VALIGN="TOP" BGCOLOR="#DADADA">DC</TH>
    13:    <TH ALIGN="LEFT" VALIGN="TOP" BGCOLOR="#DADADA">Purchase Order</TH>
    14:    <TH ALIGN="LEFT" VALIGN="TOP" BGCOLOR="#DADADA">Supplier</TH>
    15:    <TH ALIGN="LEFT" VALIGN="TOP" BGCOLOR="#DADADA">Receipt Date</TH>
    16:    <TH ALIGN="LEFT" VALIGN="TOP" BGCOLOR="#DADADA">Receipt Time</TH>
    17:  </TR>
    18:
    19:#foreach( $rec in $records )
    20: #if ( ${rec.getField(0, 0)} == "RH" )
    21:  <tr>
    22:    <td>${rec.getField("Brand Dc No Rh")}</td>
    23:    <td>${rec.getField("Order No Rh")}</td>
    24:    <td>${rec.getField("Sup Id Rh")}</td>
    25:    <td>${rec.getField("Receipt Date Rh")}</td>
    26:    <td>${rec.getField("Receipt Time Rh")}</td>
    27:  </tr>
    28: #end
    29:#end
    30:</table>
    31:<p>&nbsp;<p>
    


    Exporting using a Velocity Template

    You can export all or the Selected texted in a file from the RecordEditor using the SaveAs function. After selecting the SaveAs dialog you need to

    1. Change the output format to Velocity

    2. Enter the Velocity Template to use. You can also use the Get Velocity Template button to select a template.


    Script Support


    Introduction to Scripting

    In the RecordEditor 0.88. Scripts can be used to:

    By default the RecordEditor will support EMCA Script (Javascript). Other Scripting languages like Jython, JRuby, NetRexx can be used. See JVM Languages for a list of JVM languages.

    If you want to do a lot of scripting, you should get the Latest Script/JavaDoc download for the RecordEditor (See RecordEditor Download)


    Adding another scripting Language

    To add another scripting language to the RecordEditor:

    Note: Adding a scripting language will slow down the RecordEditor start-up (Particularly Jython).


    Running Macro's (scripts)

    At program start-up, the RecordEditor builds a menu of all the Script in the defined script menu on the Utility Menu:

    You can also run scripts using the Run Script Dialog (via Utilities >>> Script Test Panel menu item):


    Variables / Functions available to scripts

    The most important variable supplied to scripts is RecordEditorData. It provides access to

    Variables available in velocity templates / scripts include
    Variable Command
    layout RecordEditor File Description (or layout).

    layout.getFileDesc()

    records List of RecordEditor Lines for single message files there will be one element, for delimited files multiple.

    treeRoot This Tree display root (A java MutableTreeNode). This will be File element with no data associated with it.

    treeNodes This is list of list of Tree Nodes. The example zXmlStyleSheet1.vm uses this variable, it reformats Xsl Transforms.

    RecordEditorData RecordEditor Data, Fields include:

    • RecordEditorData.view gets the current file view. This field implements Iterable, so you can loop through all lines.

    • RecordEditorData.view.getBaseFile() gets the current file. This field implements Iterable, so you can loop through all lines.

    • RecordEditorData.view.htmlCharsToVars(someString) This method will return a String with HTML control characters (<, > etc) replaced by the appropriate

    • RecordEditorData.currentTab Current tab being displayed. variables.

    Major methods include:

    • RecordEditorData.displayList Display a list of lines on the selected screen.

    • RecordEditorData.executeSavedTask Execute a saved action (Task) such as sort, sortTree, recordTree.


    Creating new display

    To create a new view the important Methods of RecordEditorData are:

    Following is a Jython macro to create a View containing only Record's where the Quantity is < 0 (Filter_DTAR020.py):

    10 print layout.getRecord(0).getRecordName()
    11 
    12 if layout.getRecord(0).getRecordName() == "DTAR020":
    13     list = RecordEditorData.getNewLineList()
    14 
    15     for line in file:
    16         if line.getFieldValue("QTY-SOLD").asLong() < 0:
    17             list.add(line)
    18 
    19 
    20     displayType = RecordEditorData.displayConstants.ST_LINES_AS_COLUMNS
    21     RecordEditorData.displayList(displayType, "Qty < 0, Column Display", list);
    22 else:
    23     RecordEditorData.showMessage("Script only works on DTAR020 files and not " + layout.getRecord(0).getRecordName())
    24 
    

    The following javascript macro will create seperate views for each Record-Type in the file (ViewForEachRecordType.js):

     9     if (layout.getRecordCount() < 2) {
    10         RecordEditorData.showMessage("This macro only makes sense when there are > 1 Record Type");
    11     } else if (RecordEditorData.view.getRowCount() < 2) {
    12         RecordEditorData.showMessage("This macro only makes sense when there are > 1 line in the View");
    13     } else{
    14         var recordArray = new Array();
    15         for (i = 0; i < layout.getRecordCount(); i++) {
    16             recordArray[i] = RecordEditorData.getNewLineList();
    17         }
    18 
    19         for (i = 0; i < RecordEditorData.view.getRowCount(); i++) {
    20             line = RecordEditorData.view.getLine(i);
    21             recordArray[line.getPreferredLayoutIdx()].add(line);
    22         }
    23 
    24         var displayType = RecordEditorData.displayConstants.ST_LIST_SCREEN;
    25         for (i = 0; i < layout.getRecordCount(); i++) {
    26             if (recordArray[i].size() > 0) {
    27                 var screen = RecordEditorData.displayList(displayType, layout.getRecord(i).getRecordName(), recordArray[i]);
    28             }
    29         }
    30     }
    


    Executing Saved Tasks

    You can execute save function (Sort, Sort-Tree, Record-Tree, Filter and Hide-Fields, see "Saving a Function in the RecordEditor") using the RecordEditorData.executeSavedTask method. There are two signatures for this method:

       1 
       2     /***
       3       *  Execute the saved Function on the tab that was active tab when the script started
       4       */
       5     public final AbstractFileDisplay executeSavedTask(
       6                                               String location,
       7                                               String name) {
       8 
       9    /***
      10       *  Execute the saved Function on the supplied display (Tab)
      11       */
      12     public final AbstractFileDisplay executeSavedTask(
      13                                               AbstractFileDisplay display,
      14                                               String location,
      15                                               String name)
      16 
    

    The parameters are:

    display

    Display/tab to execute the saved task against

    location

    Location of the xml file. Possible values include:

    • RecordEditorData.executeConstansts.scriptDir - Same directory as the scripts being executed resides in.
    • RecordEditorData.executeConstansts.sortDir - Standard directory where Sort/Sort-Tree tasks are saved.
    • RecordEditorData.executeConstansts.sortTreeDir - Standard directory where Sort/Sort-Tree tasks are saved.
    • RecordEditorData.executeConstansts.fieldDir - Standard directory where Field-Hide tasks are saved.
    • RecordEditorData.executeConstansts.filterDir - Standard directory where Filter tasks are saved.
    • RecordEditorData.executeConstansts.absolute - No directory, The name contains the directory information.

    name

    Name of the script to be executed

    The following extract from FilterSort_DTAR020.js, it creates a new display-tab, sort the data displayed on the tab using a saved sort, then hides the date column using saved Hide-Fields tasks.

    23     var screen = RecordEditorData.displayList(displayType, "Qty < 0", list); /* create new display from the list that has been createrd.*/
    24 
    25     RecordEditorData.executeSavedTask(screen,
    26                                       RecordEditorData.executeConstansts.sortDir /*"SortDir"*/,
    27                                       "Script_DTAR020_Sort_Sku_Store.xml"); /* sort the data on the newly created screen */
    28 
    29     RecordEditorData.executeSavedTask(screen,
    30                                       RecordEditorData.executeConstansts.fieldDir  /*"FieldDir"*/,
    31                                       "DTAR020_HideDate.xml");    /* Hide Date Column  */
    32 
    


    Update Scripts

    To update the file the important fields and methods are:

    File

    Represents the whole file being edited, main methods include getRowCount(), getLine(), insertLine(..), deleteLine(..), etc.

    View

    Represents Data in the current view, has the same methods as File.

    RecordEditorData

    Main interface to the RecordEditor. The most important method when updating data is RecordEditorData.fireScreenChanged(boolean)

    AbstractLine interface

    Represents one Record in the file. Some important methods are

    • getFieldValue(..) - Get a fields value, has methods like asString, asBigDefimal etc plus set (to update the field).

    • setField(..) - Updates a fields value.

    • setData(..) - parameter either a string or array of bytes.

    Note: getFieldValue and setField can take as parameters either a Field-Name or Record-Number,Field-Number or Field-Definition.

    In the following code was taken from InsertLines_DTAR020.js, 2 lines are created then updated using setField method of line and finally inserted back into the view.

    11         /* Setting up a line using field names */
    12     var line = RecordEditorData.newLine()
    13     line.setField("KEYCODE-NO", "00000000");
    14     line.setField("STORE-NO",   "0");  /* you are best using Strings         */
    15     line.setField("DATE",       "0");  /* and letting the RecordEditor       */
    16     line.setField("DEPT-NO",    "0");  /* do the Conversion                  */
    17     line.setField("QTY-SOLD",   "0");
    18     line.setField("SALE-PRICE", "0.0");
    19     RecordEditorData.view.addLine(0, line)
    20 
    21         /* You can also use Record-Number, Field-Number */
    22     var line = RecordEditorData.newLine()
    23     line.setField(0, 0, "33333333");
    24     line.setField(0, 1, "333");
    25     line.setField(0, 2, "330133");
    26     line.setField(0, 3, "333");
    27     line.setField(0, 4, "33");
    28     line.setField(0, 5, "33.33");
    29     RecordEditorData.view.addLine(3, line)
    30 
    

    In the following code was taken from EnsureCorrectNumberOfFieldSeporators.py, it updates existing lines using the setData method. You could use the setField method to update existing lines as well.

     9 ###   Function:
    10 ###   The program will loop through all lines in the file and make
    11 ###   sure each line has at least the correct number of field seperators.
    12 ###   note: The macro assumes there are no seperators embbeded in a line
    13 ###
    14 
    15 changed = 0
    16 sep = layout.getDelimiter()                     ### Get Field Delimiter 
    17 fieldCount = layout.getRecord(0).getFieldCount()
    18 for line in file:                               ### Loop through the lines in the file
    19         text = line.getFullLine()               ### Get the line as Unicode Text field
    20         pos = 0
    21         count = 1
    22 
    23         while unicode.find(text, sep, pos) > 0:
    24                 pos = unicode.find(text, sep, pos) + 1
    25                 count = count + 1
    26 
    27         if count < fieldCount:
    28                 while count < fieldCount:
    29                         text = text + sep
    30                         count = count + 1
    31                 line.setData(text)              ### Setting the data in the line,
    32                                                 ### This only works for Text files.
    33                 changed = 1
    34 
    35 RecordEditorData.fireScreenChanged(changed);    ### Update the display and set file
    36                                                 ### status to changed
    37 
    


    Other Example Scripts

    Following is a Jython Script to export the Current file as a Comma Delimited file:

     1 ###
     2 ###   This will loop through all the selected Records.
     3 ###   For protocol buffers / Avro Editors, child records will 
     4 ###   not be included
     5 ###
     6 
     7 print 'hello from python'
     8 print outputFile
     9 my_file = open(outputFile,'w')
    10 
    11 for line in records:
    12         idx = line.getPreferredLayoutIdx()
    13         count = layout.getRecord(idx).getFieldCount()
    14         i = 0
    15         sep = ''
    16 
    17         while i < count:
    18                 my_file.write(sep)
    19 
    20                 v = line.getField(idx, i)
    21                 if (v is None):
    22                         v = ""
    23 
    24                 my_file.write(str(v))
    25                 sep = ','
    26                 i = i + 1
    27         my_file.write('\n')
    28 
    29 my_file.close()
    30 
    


    Saving a Function in the RecordEditor

    Many of the functions (e.g. Filters, Record-Tree, Sort-Tree's etc) in the RecordEditor can be saved as Xml and either loaded back in later or run from Script macros (see "Executing Saved Tasks").

    The save Button at the bottom of the screen, will save the Sort definition as a Xml file, the load Button will reload previously saved sort definitions.


    Changing the Look and Feel or Icons

    You can change the look and feel or Icons used in the RecordEditor


    Looks and Feel Tab

    You can now choose from the Java builtin Look and Feels + several other Look and Feels (these require a seperate download). A word of warning, not all Look and Feels will work with the RecordEditor and even if they work they may slow down the editor (or at the very least slow down the startup), Also IU have not done thorough testing with any of Look and Feels. If you want an alternative Look and Feel, I would suggest looking at

    Note: OfficeLnFs and Substance only works on Windows and requires Java 1.5.


    Icon Tab

    You can now choose from a variety of different icon sets or create your own.

    Here are some of the icons:

    Tango 

    Eclipse 

    Gnome 


    Setting up for Linux

    The RecordEditor comes setup for Windows, but there are a number of changes that can be made to tailor it for Linux. The key is the Edit Properties program. This program will update startup properties.


    Screen Position

    The first step is to start the Edit Properties program and select the properties tag. On this screen you can set the space to be left at the top and bottom of the screen. For KDE probably 40 for Space at the bottom of the screen will do. For Gnome you may want set Space at Top of the Screen to around 20.


    Looks and Icons

    On this screen you can define the look and feel to use. For KDE users you could try Liquid Look and Feel

    On this screen you can specify icon set. You could choose Aqua, Gnome or Tango.

    Here are some of the icons:

    Tango 

    Gnome 


    Improving the running of RecordEditor HSQL

    There have been several changes for version 0.68 some of which you may want to change:


    Setting the Default DB

    If you are going to mainly use the embedded version of the DB, I suggest changing this to be the default.


    Embedded HSQL DB Definition

    There is one JDBC options (Auto Close DB) you may wish to change. When set to Y the RecordEditor will Open the DB connection, Access the DB and Close the DB connection. This has 2 main effects:

    1. Allows you to run multiple copies of the RecordEditor.
    2. Slows down some operations.

    To change the Auto Close DB property you need to


    Embedded DB options

    There are several options that may be useful when using an embedded DB with the record Editor:

    Read Only Source

    If the Database supports a Readonly Mode, you can enter the Readonly access string here. The RecordEditor will open the DB in Readonly mode and only open it for update when that is required.

    Exapand Variables (Y/N)

    When Y, the following variables (case sensitive):

    • <install> RecordEditor Install directory
    • <home> Users home Directory
    • <hsqlDB> on linux it is <install>/<Database> on windows it is in the user parameters directory.

    Auto Close Connection.

    Determines wether Database connection are left open after each DB access or left open (for server DB's it should be spaces / Y). When the value is

    • N, The RecordEditor will connect to the DB, Access the DB and close the connection. This will slow the program down a bit but allow you to run several copies of the RecordEditor at once (in embedded mode).
    • Space / Y the connection is kept open all the time block access to the DB.

    To get to the JDBC Properties screen you should


    Big Files

    Java Considerations

    By default, a Java program gets allocated a maximum of 256 megabytes. For big files you need to increase this. There should be sample shell script / bat files (runEditorBigFile.sh and RecordEditorBigFile.Bat) in the RecordEditor/<Version>/lib directory for this purpose. In case they are missing, there are samples in this Zip file.

    You will need to update the -Xmx parameter in the supplied shell script/bat file and use this shell script/bat file for editing large files


    Memory/OS Suggested Parameter
    1 GB -Xmx500m
    2 GB -Xmx1400m
    4 GB/32 bit java -Xmx1600m
    4 GB/64 bit java -Xmx3000m
    8 GB/64 bit java -Xmx6000m

    Large File Model

    I have introduced a new Large-File model to support editing big Files. This Large-File model supports editing veryu large files with reduced program functionality (Filters and Tree views). It will allow the editing of files that are much larger than the available memory (it uses GZip compression and overflow files). This Large-File model is used when file size is greater than 14% of available memory (% can be changed via start up parameters- "Parameters").

    Limitations of Large-File-Model

    Note: I plan to more work on the "Big File Models" so I if you have any comments, suggestions I would be interested in hearing them

    How it Works

    The Large-File-Model reduces memory usage in 4 ways

    1. Instead of storing lines as objects, the data is stored in one megabyte blocks. This saves the line overhead (about 40 bytes per line).
    2. Blocks are compressed (GZipped) when not in use. This should work well on a recent quad core PC (Compression is done in a background thread) but will slow down old single core PC's
    3. When memory is tight, data is written to a Overflow File.
    4. For Fixed-Width files, data is only read from the input file when it is being used.

    GZip

    If a file name ends in .gz, the RecordEditor treats it as being GZipped and will read and write it as a GZipped file. This create a problem of knowing how big the file is and when to use the Large-Memory-Model. I you edit GZipped files, you may need to decreased the Large File Model Percentage, see "Parameters".

    GZip files can take a lot longer to load because

    Parameters

    There are several parameters that affect the Large-Memory-Model (under the Edit >>>> Edit Startup Parameters ;;; Properties >>>> Big Model Options).

    Here are some suggestions for the parameters:

    Large Multi-User Server.

    Large heavily used Unix/Mainframe serves typically have fast Disks and heavy loads.

        Compress Option=N/S
        Use Large VB model=Y
    

    Small Server.

    Small Lightly used servers

        Compress Option=S/R
        Use Large VB model=Y
    

    Very Fast Multi core PC.

        Compress Option=F/Y
        Use Large VB model=N
    

    Slow PC.

        Compress Option=Read
        Use Large VB model=Y
    

    Following are the parameters that affect the Big-File-Mode. I use them for testing.

    Parameter

    Description

    Big File Percentage

    Percentage at which Big-File-Model is used. Default is 14%, used in testing to force Big-File-Models to be used for small files. You may need to lower it if you are editing big GZIP files with a very high compression ratio.

    Chunk Size

    Size of chunks used to store the file. Default is 1000, values between 500 to 4000 should produce the best results.

    Compress Option

    This option controls when compression is used.
    Option Description
    Yes Compress aggressively
    Space Compress when storage gets low. Space based compression.
    Read Use Space (option S) based compression when reading the file then compress aggressively (option Y).
    Read (Fast CPU) Like option R but will use compression a bit more aggressively.
    No Never compress a block.

    Big File Filter Limit

    Maximum number of records extracted via Filter (also affects Tree views).

    Store Chunks on Disk

    Force Storing chunks on Disk. This is only useful in testing.

    Use Fixed Model

    Use Fixed Length Model. There is a special model for fixed length files which rather than reading the file, it calculates the Disk position then reads blocks as they are requested. Leave as Selected, this option is for testing.

    Use Large VB model

    There is a special LargeVB-Model that while reading a file rather than compressing blocks it stores the disk address. This speeds up the reading in of the file on old slow PC (particularly for Cobol-VB files) but will slow down other operations (particularly saving the file).

    Load In Background

    Controls wether files are loaded on a background thread with progress display or not. Leave as selected.


    Define a New Field Type

    Jave code for US Date Type

    Following is the java code to implement a US Style MM/DD/YY date.

       1:package net.sf.RecordEditor.examples;
       2:
       3:import net.sf.JRecord.Types.TypeChar;;
       4:import net.sf.RecordEditor.record.types.TypeDateWrapper;
       5:
       6:/**
       7: * provide a US style date (mm/dd/yy)
       8: *
       9: * @author Bruce Martin
      10: *
      11: */
      12:public class USdate8 extends TypeDateWrapper {
      13:
      14:    /**
      15:     * provide a US style date (mm/dd/yy)
      16:     */
      17:    public USdate8() {
      18:        super(new TypeChar(true), "MM/dd/yy");
      19:    }
      20:}
    

    Following is the code to provide a special Date Editor

       1:package net.sf.RecordEditor.examples;
       2:
       3:import net.sf.RecordEditor.record.format.DateFormat;
       4:
       5:/**
       6: * US date cell format (MM/DD/YY)
       7: *
       8: * @author Bruce Martin
       9: *
      10: */
      11:public class USdateFormat8 extends DateFormat {
      12:
      13:    /**
      14:     * US date cell format (MM/DD/YY)
      15:     */
      16:    public USdateFormat8() {
      17:        super(true, "MM/dd/yy");
      18:    }
      19:}
      20:
    

    You now need to bundle this Type as a Java Jar file.

    Defining a Type to the RecordEditor

    Start the Edit RecordEditor Startup Properties and go to the User Types tag and entor the new Type as in the diagram below:

    The next step is to define where your type is found, so go to the User Jars tag an enter your new jar as below

    You can now use the new Type in both the RecordEditor and the LayoutEditor.