Hi All
I get the following output from a serial port of an LDK-100 PABX System Version LGE/GS90P-2.2Dh DEC/03
The output is intended for a dot matrix printer and prints about 50 lines and then outputs a LF/FF
to top of form and prints the page header as shown.
The lines containing data are all 95 characters long and if there is no data then the lines are padded out
to 95 characters with spaces. The 96th character is a cr/lf pair. Lines with less than 95 characters have no data
and must be discarded, including the page header and printer control characters like LF and FF. Valid strings
need to be parsed and split into fields to be written to a database for a call costing and reporting application.
The data is output one line at a time as each call in completed.
All the data is in columns. Assuming the first character is col 1, the data needs to be parsed as follows:
Col 1-4 Call Sequence Number
Col 5 Space
Col 6-10 PABX Ext Number
Col 11 Space
Col 12-14 Call Circuit Number
Col 15 Space
Col 16-23 Call Duration (hh:mm:ss)
Col 24 Space
Col 25-32 Call Date (dd/mm/yy)
Col 33 Space
Col 34-38 Call Time (hh:mm)
Col 39 Space
Col 40 I=Inbound/O=Outbound/t=Tra
nsferred (I/O/t) if O and number dialed is prefixed with 0 the call is long distance
or if the number is prefixed with 08 or 07 the a mobile phone is being called. Anything else (1,2,3,4,5,6,7,8,9) is a local call
Col 41-58 Called Ext/Number Dialed
Col 59 Space
Col 60-62 Accounting Code
Col 63 Space
Col 64-68 Control Code
Col 69 Space
Col 70- 80 Call Cost
Col 81 Space
Col 82-93 Account Code
Col 94 Space
Col 95 Asterisk/Space
The code for capturing the serial data has been done and works flawlessly as can be seen. Writing each record to the database is also complete.
There are obviously many ways to parse the lines into fields as described, but I am looking for the "Delphi Best Practice" way
to do this and any suggestions are welcome. Sorry for the verbosity, rather too much detail than too little.
---- Site Name : --------------------------
----------
----------
----------
-------
NO STA CO TIME START DIALED ACT CNT COST ACCOUNT CODE
---- ----- --- -------- -------------- ------------------- --- ----- ----------- ------------
9171 1600 020 00:00:08 03/11/04 08:26 I1600 RING 00:05 *
9171 1630 020 00:00:24 03/11/04 08:26 t
9172 1600 019 00:00:21 03/11/04 08:27 I1600 RING 00:05
9167 1615 021 00:04:47 03/11/04 08:23 T092634885447 ** 0 0
9173 1600 004 00:00:12 03/11/04 08:27 I RING 00:08 *
9173 1631 004 00:00:56 03/11/04 08:28 t
9176 1600 005 00:00:11 03/11/04 08:32 I RING 00:07 *
9177 1600 008 00:00:10 03/11/04 08:33 I RING 00:19 *
9178 1629 017 00:00:44 03/11/04 08:33 O0216836654 ** 0 0
9176 1631 005 00:02:11 03/11/04 08:32 t *
9174 1600 018 00:04:42 03/11/04 08:31 O4217111 ** 0 0
9177 1606 008 00:02:29 03/11/04 08:33 t
9176 1630 005 00:01:40 03/11/04 08:35 t
9179 1602 016 00:00:33 03/11/04 08:37 O0215524660 ** 0 0
9181 1631 015 00:00:00 03/11/04 08:39 O01 ** 0 0
9180 1603 016 00:01:09 03/11/04 08:38 I1603 RING 00:01
9182 1631 014 00:00:25 03/11/04 08:39 O0315791884 ** 0 0
9183 1606 013 00:00:17 03/11/04 08:40 O0217975582 ** 0 0
9185 1606 011 00:00:18 03/11/04 08:41 O0825567634 ** 0 0
9184 1631 012 00:02:14 03/11/04 08:41 O0800116771 ** 0 0
9186 1600 012 00:00:06 03/11/04 08:43 I RING 00:02
9187 1600 011 00:00:08 03/11/04 08:45 I1600 RING 00:02 *
9188 1631 010 00:00:00 03/11/04 08:45 O4944250 ** 0 0
9189 1600 010 00:00:14 03/11/04 08:45 I RING 00:07 *
9189 1628 010 00:00:25 03/11/04 08:46 t
9190 1600 013 00:00:14 03/11/04 08:47 I1600 RING 00:04 *
9191 1600 014 00:00:11 03/11/04 08:47 I RING 00:20
9190 1630 013 00:01:06 03/11/04 08:47 t
9187 1614 011 00:03:49 03/11/04 08:45 t
9192 1603 015 00:02:19 03/11/04 08:47 I1603 RING 00:02
9194 1626 008 00:00:00 03/11/04 08:50 O083600 ** 0 0
9195 1626 007 00:00:00 03/11/04 08:50 O083400 ** 0 0
9193 1602 009 00:00:31 03/11/04 08:50 O0833792813 ** 0 0
9197 1600 007 00:00:06 03/11/04 08:50 I1600 RING 00:04 *
9196 1626 006 00:00:26 03/11/04 08:50 O0834050008 ** 0 0
9197 1603 007 00:00:22 03/11/04 08:50 t
9198 1626 005 00:01:21 03/11/04 08:51 O0215524660 ** 0 0
9199 1603 004 00:02:15 03/11/04 08:51 O0861111333 ** 0 0
9201 1614 002 00:00:24 03/11/04 08:53 O4918007 ** 0 0
9200 1629 003 00:00:44 03/11/04 08:53 O0126652223 ** 0 0
9202 1630 001 00:00:10 03/11/04 08:54 O0825792122 ** 0 0
9203 1603 030 00:00:00 03/11/04 08:54 O5485005 ** 0 0
9204 1603 029 00:00:28 03/11/04 08:55 O7196323 ** 0 0
9205 1628 028 00:01:45 03/11/04 08:55 O0826559918 ** 0 0
9206 1606 027 00:00:00 03/11/04 08:57 O01 ** 0 0
9207 1603 026 00:00:22 03/11/04 08:57 O0824427645 ** 0 0
9209 1626 025 00:00:45 03/11/04 08:57 O0836270929 ** 0 0
9210 1630 024 00:00:38 03/11/04 08:58 O0825792122 ** 0 0
9211 1603 023 00:00:59 03/11/04 08:58 O7196323 ** 0 0
9212 1600 023 00:00:09 03/11/04 09:00 I1600 RING 00:02 *
9212 1602 023 00:01:25 03/11/04 09:00 t
9213 1602 022 00:00:10 03/11/04 09:02 O4852387 ** 0 0
9214 1600 022 00:00:14 03/11/04 09:03 I1600 RING 00:03 *
9214 1631 022 00:01:55 03/11/04 09:03 t
Thank you
PC