The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

oEdtk - A module for industrial printing processing

DESCRIPTION

This is the main module of the oEdtk toolkit. It's intended for documentation purposes only. You will find general information about the diferents tools here.

LICENCE

    oEdtk Copyright (C) 2005-2024 G Chaillou Domingo, D Aunay, M Henrion, G Ballin

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

SYNOPSIS

SIMPLE USE (fixed records)

    use oEdtk::Main;
    use strict;

    sub main() {
        # File input and output opening
        oe_new_job($ARGV[0], $ARGV[1]);

        # Application initialisation (user defined)
        &initApp();

        # Reading the input line by line
        while (my $ligne=<IN>) {
            chomp ($ligne);
            # testing if $line maok, pas de soucitch pre declared records
            if (oe_process_ref_rec(0, 3, $ligne)) {
            } else {
                # If not, record is ignored
                warn "INFO IGNORE REC. line $.\n";
            }
        }

        # Closing input and output file
        oe_compo_link($ARGV[0], $ARGV[1]);
        return 1;
    }

    sub initApp() {
        # EXAMPLE : DECLARATION OF RECORD KEYED '016'
        # structure of record '016' for spliting/extraction
        # (could be delayed in 'pre_process' procedure)
        oe_rec_motif("016", "A67 A20 A*");

        # compuset output declaration (only if necessary)
        oe_rec_output("016", "<SK>%s<#DATE=%s><SK>%s");
        return 1;
    }

EXAMPLE 2 (fixed records)

    use oEdtk::Main;
    use strict;

    sub main() {
        # File input and output opening
        oe_new_job($ARGV[0], $ARGV[1]);

        # Application initialisation (user defined)
        &initApp();

        # Reading the input line by line
        while (my $ligne=<IN>) {
            chomp ($ligne);
            # Testing if $line match pre declared records
            if (oe_process_ref_rec(0, 3, $ligne)){
            } else {
                # If not, record is ignored
                warn "INFO IGNORE REC. line $.\n";
            }
        }

        # Closing input and output file
        oe_compo_link($ARGV[0], $ARGV[1]);
        return 1;
    }

    sub initApp() {
        # EXAMPLE : DECLARATION OF RECORD KEYED '016'
        # process '&initDoc' done when record '016' is found,
        # before to proceed the record
        # (mandatory only if no oe_rec_motif declared)
        oe_rec_pre_process("016", \&initDoc);

        # structure of record '016' for spliting/extraction
        # (could be delayed in 'pre_process' procedure)
        oe_rec_motif("016", "A67 A20 A*");

        # process '&format_date' after record is read
        # (only if necessary)
        oe_rec_process("016", \&format_date);

        # compuset output declaration (only if necessary)
        oe_rec_output("016", "<SK>%s<#DATE=%s><SK>%s");

        # process after building the output
        # (only if necessary)
        recEdtk_post_process("016", \&vars_prepared_for_next_Rec);
        return 1;
    }

CONVENTIONS

Scripts are developped in functional mode. We try to use the Perl conventions, we are listenning all your recommandations to make it better.

When a sub or a function comes from the user script it's written like this :

    &function_from_the_script();

Functions or 'methods' from perl modules are written like this :

    oe_rec_motif("016", "A67 A20 A*");

INTERFACE

oe_new_job

oe_new_job( input_file, output_file, [single_job_id] )

This function opens and shares the main filehandles IN and OUT. The parameter 'single_job_id' is optional. It is used to send the job id to the document builder application.

oe_compo_link( input_file, output_file )

This function closes the main filehandles IN and OUT. Filenames in parameters are used for information, but they are mandatory.

oe_process_ref_rec

oe_process_ref_rec( offset_Key, key_Length, Record_Line, [offset_of_Rec, Record_length] )

This function process the record line referenced in parameters as described with 'recEdtk_' tools (see below). It's made for fixed size records.

Mandatory parameters:

  • 'offset_key' is the starting point position of the record key

  • 'key_Length' is the the length of the record key you are looking for

  • 'Record_Line' is a reference to the record line you are working on (oe_process_ref_rec uses the reference of the line)

Optional parameters:

  • 'offset_of_Rec' is the starting point of the record from the beginning of the line (if you want to cut down the begging of the line)

  • 'Record_length' is the lenght of the record from the starting point of the record

The oe_process_ref_rec function works by ordered key size, from the left to the right. You should use it by working first with the biggest record to the smallest one.

Examples :

        record 'abc'  : abcvalue_1 value_2 value_3
        record 'zzza' : zzza**value_1 value_2 value_3
        record 'ywba' : ywba**value_AAAAAAAAA value_B
        record '016'  : ***016-value_A1 value_B2 value_C3
        record '600'  : ***600-value_A4 value_B5 value_C6

        record definitions (in fact, the order is not important here) :
                oe_rec_motif    ("zzza","A4 A2 A8  A8 A7 A*");
                oe_rec_motif    ("ywba","A4 A2 A16 A7 A*");
                oe_rec_motif    ("abc", "A3 A8 A8  A7 A*");
                oe_rec_motif    ("016", "A3 A3 A1  A9 A9 A7 A*");
                oe_rec_motif    ("600", "A3 A1 A9  A9 A7 A*");

        you will process from left to right, from bigest to smallest :
                if (oe_process_ref_rec(0, 4, $ligne)) {
                        # this will process both records 'zzza' and 'ywba' .

                } elsif (oe_process_ref_rec(0, 3, $ligne, 3)) {
                        # this will process records 'abc'
                        # (and cut away first 3 caracters of the record line).

                } elsif (oe_process_ref_rec(3, 3, $ligne, 6)) {
                        # this will process both records '016' and '600'
                        # (and cut away first 6 caracters of the record line).

                } else {
                        # if not, record is ignored
                        warn "INFO IGNORE REC. line $.\n";
                }

The oe_process_ref_rec function returns 1 when it recognizes and processes the record (including the output if oe_rec_output is defined). Values extracted from the record are split into the @DATATAB oEdtk global array. oe_process_ref_rec returns 0 when it could not recognize the record.

The oe_process_ref_rec function makes these differents steps :

  1. look if there is a record key corresponding

  2. run the pre-process function if defined (see "oe_rec_pre_process")

  3. unpack the record according to oe_rec_motif definition into @DATATAB

  4. run the process function if defined (see "oe_rec_process")

  5. build output if oe_rec_output is defined

  6. run the post-process function if defined (see "recEdtk_post_process")

oe_rec_motif

oe_rec_motif( Record_Key_ID, Record_Template )

Create a record with the 'Record_Key_ID' identifier or type. This key identifier should be in the record. This function defines the 'Record_Template' used to expand / extract the record (see unpack for template description). This function is mandatory, but cannot be defined after oe_rec_pre_process.

Example :

    oe_rec_motif("016", "A2 A10 A15 A10 A15 A*");

It is recommended to add 'A*' at the end of the template to cut away any unexpected data that will remain at the end of the record.

oe_rec_process

oe_rec_process( Record_Key_ID, \&user_sub_reference )

This function links the record 'Record_Key_ID' with a process sub. This sub is called after the extraction / expanding of the record. When this process is defined, it's called before the building of the output (if defined, see "oe_rec_output"). You can access the expanded data by reading/writing global tab @DATATAB. This function is optional.

oe_rec_output

oe_rec_output( Record_Key_ID, Output_Template )

This function defines an 'Output_Template' for the record 'Record_Key_ID'. This template is used to build the output file (see sprintf for the template description). The output is built after the record process ("oe_rec_process" if this one is defined). You can access the expanded data by reading/writing global tab @DATATAB. This function is optional. If no oe_rec_output is defined for the 'Record_Key_ID', the record would be erased at the next record process.

Example :

    oe_rec_output("016", "<SK>%s<#DATE=%s><SK>%s");

recEdtk_post_process

recEdtk_post_process( Record_Key_ID, \&user_sub_reference )

This function links the record 'Record_Key_ID' with a process sub. This sub is called after the building of the output. When this process is defined, it's called before the next record read. You can access the expanded data by reading/writing global tab @DATATAB. This function is optional.

recEdtk_erase

recEdtk_erase( Record_Key_ID )

This function will erase all the descriptions made for the record 'Record_Key_ID'. This is useful when you want to ignore a record (this will cause a message 'Record Unknown' as if it has never been declared before) or when you want to redefine a record during the process.

recEdtk_redefine

recEdtk_redefine( Record_Key_ID, Record_Template )

This function will erase (as above) AND redefine the record 'Record_Key_ID' and its template 'Record_Template'. With this function, you define the necessary to start processing the record. It's the less you can do.

Example :

    recEdtk_redefine("016", "A2 A10 A15 A10 A15 A*");

AUTHORS

oEdtk by D Aunay, GJ Chaillou Domingo, M Henrion, G Ballin.

This pod text by GJ Chaillou Domingo, M Henrion and others. Perl by Larry Wall and the perl5-porters.

COPYRIGHT

The oEdtk module is Copyright (c) . All rights reserved.

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.

SUPPORT / WARRANTY

The oEdtk is free Open Source software. IT COMES WITHOUT WARRANTY OF ANY KIND.