Q: What I would like to do is to find the word "SerialNr: " in the data stream and store the next seven characters into a TXT file. Like this:

L3AAE3C
L3AAE3Y
L3AAE3T

etc.

1. Solution (of 4):

[GLOBAL]

; Whatever you need

; Predefine your variable for the serial number, default value: NotFound

Variable=#MyVarFullSerialNumber#:NotFound

; This rule is processed while ELP reads the data stream..

[Get Serial Number from document]

Search_Binary=SerialNr:

StoreNextWordToVariable=#MyVarFullSerialNumber#

; speed up

ReadOnlySearchKeys=ON

; This rule is processed after the complete data stream is read..

[Generate Serial Number CSV database]

; Primary search trigger is always true as only the variable content is of interest

Trigger_Binary=1

; But store only if there was a serial number in the data stream

Trigger_Variable=#MyVarFullSerialNumber#!NotFound

; In the first database field ELP has to store only the first 7 characters of the serial number

Variable=#MyVarAccValue#:LEFT(#MyVarFullSerialNumber#,7)

; Start Accounting

ACCOUNTING=ON

; Into this file

ACC_FILE=#ELP_FORMS_PATH#SerialNo.csv

; only those variables

ACC_STOREVALUES=#MyVarAccValue#,#MyVarFullSerialNumber#,#USERNAME#

Hint: If you want to have a .dbf file then set the ACC_TYPE key and change the file name to dbf

2. Solution (of 4):

Additional information came in: Well, thank you, but my client has more then one serial number in the print job, what to do then:

Here is a first straight forward solution, based upon the first one, but as many sections as the maximum amount of serial numbers per print job might be necessary:

Based upon the request having more then one serial number in a file, this is a much shorter and nicer version as no changes need to be done. But the result string is not allowed to be longer then 1025 bytes. So maybe do not store the user name or the full license key

[GLOBAL]

; Whatever you need

Variable=#1MyVarFullSerialNumber#:NotFound
Variable=#2MyVarFullSerialNumber#:NotFound
Variable=#3MyVarFullSerialNumber#:NotFound

[Get 1st serial number from document]

Search_Binary=SerialNo:
StoreNextWordToVariable=#1MyVarFullSerialNumber#

; This rule is only executed for the first found number, the next serial number will be found by the next rule etc.

Search_Only_Once=ON
ReadOnlySearchkeys=ON

[Get 2nd serial number from document]

Search_Binary=SerialNo:
StoreNextWordToVariable=#2MyVarFullSerialNumber#
Search_only_once=ON
ReadOnlySearchkeys=ON

[Get 3rd serial number from document]

Search_Binary=SerialNo:
StoreNextWordToVariable=#3MyVarFullSerialNumber#
Search_only_once=ON
ReadOnlySearchkeys=ON

; The following rules are processed after the complete data stream is read.

[ok, now set the variables for writing]

Trigger_Binary=1; Set the variable MyVarAccValue to the first 7 chars as the client requested
Variable=#1MyVarAccValue#:LEFT(#1MyVarFullSerialNumber#,7)
Variable=#2MyVarAccValue#:LEFT(#2MyVarFullSerialNumber#,7
Variable=#3MyVarAccValue#:LEFT(#3MyVarFullSerialNumber#,7)

[3 Generate Serial Number CSV database]

Trigger_Binary=1
Trigger_Variable=#3MyVarFullSerialNumber#!NotFound
ACCOUNTING=ON
ACC_FILE=#ELP_FORMS_PATH#SerialNo.csv
ACC_STOREVALUES=#1MyVarAccValue#,#1MyVarFullSerialNumber#,#USERNAME#\x0D\x0A#2MyVarAccValue#,#2MyVarFullSerialNumber#,#USERNAME#\x0D\x0A#3MyVarAccValue#,#3MyVarFullSerialNumber#,#USERNAME#
Exit=ON

[2 Generate Serial Number CSV database]

Trigger_Binary=1
Trigger_Variable=#2MyVarFullSerialNumber#!NotFound
ACCOUNTING=ON
ACC_FILE=#ELP_FORMS_PATH#SerialNo.csv
ACC_STOREVALUES=#1MyVarAccValue#,#1MyVarFullSerialNumber#,#USERNAME#\x0D\x0A#2MyVarAccValue#,#2MyVarFullSerialNumber#,#USERNAME#
Exit=ON

[1 Generate Serial Number CSW database]

Trigger_Binary=1
Trigger_Variable=#1MyVarFullSerialNumber#!NotFound
Variable=#MyVarAccValue#:LEFT(#1MyVarFullSerialNumber#,7)
ACCOUNTING=ON
ACC_FILE=#ELP_FORMS_PATH#SerialNo.csv
ACC_STOREVALUES=#MyVarAccValue#,#1MyVarFullSerialNumber#,#USERNAME#

3. Solution (of 4):

Same as 2 but even a little shorter and has the benefit that up to 2550 Bytes can be stored in the account file per job. You need a version newer then 12 Feb 2009!

[GLOBAL]

; Whatever you need
; Predefine your variables for the serial number

Variable=#MyVarOut#:NotFound
Variable=#1MyVarFullSerialNumber#:NotFound
Variable=#2MyVarFullSerialNumber#:NotFound
Variable=#3MyVarFullSerialNumber#:NotFound

[1 Get Serial Number from document]

Search_Binary=SerialNo:
StoreNextWordToVariable=#1MyVarFullSerialNumber#
Search_only_once=ON
Variable=#MyVarOut#:#1MyVarAccValue#,#1MyVarFullSerialNumber#,#USERNAME#

[2 Get Serial Number from document]

Search_Binary=SerialNo:
StoreNextWordToVariable=#2MyVarFullSerialNumber#
Search_only_once=ON
Variable=#MyVarOut#:#MyVarOut#\x0D\x0A#2MyVarAccValue#,#2MyVarFullSerialNumber#,#USERNAME#

[3 Get Serial Number from document]

Search_Binary=SerialNo:
StoreNextWordToVariable=#3MyVarFullSerialNumber#
Search_only_once=ON
Variable=#MyVarOut#:#MyVarOut#\x0D\x0A#3MyVarAccValue#,#3MyVarFullSerialNumber#,#USERNAME#

; Those rules are processed after the complete data stream is read.

[ok, now set the variables for writing]

; Trigger rule always performed:

Trigger_Binary=1

; minimum one serial number found?

Trigger_Variable=#MyVarOut#!NotFound
Variable=#1MyVarAccValue#:LEFT(#1MyVarFullSerialNumber#,7)
Variable=#2MyVarAccValue#:LEFT(#2MyVarFullSerialNumber#,7)
Variable=#3MyVarAccValue#:LEFT(#3MyVarFullSerialNumber#,7)

; store the stuff

ACCOUNTING=ON
ACC_FILE=#ELP_FORMS_PATH#SerialNo.csv
ACC_STOREVALUES=#MyVarOut#

4. Solution (of 4):

The shortest and fully flexible one, but again, only up to 1025 bytes length per job writing in the account file, so maybe remove some unneeded variables, like for example #USERNAME#.

[GLOBAL]

; Whatever you need
; Predefine your variable for the serial number

Variable=#MyVarOut#:NotFound
Variable=#MyVarFullSerialNumber#:NotFound

[Get serial number from document]

; Only one search for all numbers

Search_Binary=SerialNo:
StoreNextWordToVariable=#MyVarFullSerialNumber#

; but after each number found call rule: IF Add Serial Number

TriggerSectionAfterStore=IF Add Serial Number

[ok, now set the variables for writing]

; needs to be first triggered rule as a variable is found while reading the data stream, the process will end here!

Trigger_Binary=1
Trigger_Variable=#MyVarOut#!NotFound
ACCOUNTING=ON
ACC_FILE=#ELP_FORMS_PATH#SerialNo.csv
ACC_STOREVALUES=#MyVarOut#
Exit=ON

[IF Add Serial Number]

; this rule is called whenever a serial number was read into the variable #MyVarFullSerialNumber#

Trigger_Binary=1
Trigger_Variable=#MyVarOut#:NotFound

; The first found serial number

Variable=#MyVarAccValue#:LEFT(#MyVarFullSerialNumber#,7)
Variable=#MyVarOut#:#MyVarAccValue#,#MyVarFullSerialNumber#,#USERNAME#

; as the rule is only executed after the first number is found, the else path ...

ElseTriggerActivateSection=ELSE Append data

[ELSE Append data]

; has to add the found variable to the existing ones

Variable=#MyVarAccValue#:LEFT(#MyVarFullSerialNumber#,7)
Variable=#MyVarOut#:#MyVarOut\x0D\x0AMyVarAccValue#,#MyVarFullSerialNumber#,#USERNAME#

 

Related articles: Rules theory, Rule assistant, Add key to rule