On 12/06/2018, at 13:44, Christopher Stone <listmeis...@suddenlink.net 
<mailto:listmeis...@suddenlink.net>> wrote:
> Here's an updated script that produces cleaner output.
> From here I would probably turn the output into tab-delimited single lines.


Hey Marco,

The newest incarnation of the script (appended) produces output like this:

1       130,00  ABCDEF12G34H567I        22-04-2017
2       100,00  ABCDEF12G34H567I        22-04-2017
3       260,00  LMNOPQ89R01S234T        22-04-2017
5       23,00   LMNOPQ89R01S234T        22-04-2017

I can write another script that will parse these into variables that can be 
inserted into your web page.

Each pass will show a line item as processed like so:

[✓] 1   130,00  ABCDEF12G34H567I        22-04-2017

If you set the windows of your web browser and BBEdit up just so, you can get 
realtime visual feedback on each pass.

--
Best Regards,
Chris

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/12/04 16:04
# dMod: 2018/12/07 02:43
# Appl: BBEdit
# Task: Extract Cash Register Info.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Extract, @Cash, @Register, @Info, 
@BBEdit-Talk
# Vers: 1.02
----------------------------------------------------------------

set AppleScript's text item delimiters to ""

tell application "BBEdit"
    tell front text window's text
        
        replace "^\\h+EURO\\h*\\n" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
        replace "^\\h+$" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
        replace "\\h+$" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
        replace "\\n{2,}" using "\\n" options {search mode:grep, case 
sensitive:false, starting at top:true}
        replace "^N\\.SCONTR\\.FISCALE.*" using "&\\n" options {search 
mode:grep, case sensitive:false, starting at top:true}
        replace "\\A\\s+|\\s+\\Z" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
        
        set docText to its text
        set AppleScript's text item delimiters to linefeed & linefeed
        set recordList to text items of docText
        
        repeat with i in recordList
            if contents of i does not contain "C.F." then
                set contents of i to missing value
            end if
        end repeat
        
        set recordList to (text of recordList) as text
        set its text to recordList
        
        replace "^(?>(?:(?!(?:t_fiscale|C\\.F\\.|\\d{2}-\\d{2}-\\d{4}|TOTALE 
EURO)).)*)$\\R?" using "" options {search mode:grep, case sensitive:false, 
starting at top:true}
        
        replace "^t_fiscale" using "\\n&" options {search mode:grep, case 
sensitive:false, starting at top:true}
        replace "\\A\\s+|\\s+\\Z" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
        
        replace "^t_fiscale \\d{8} \\d{4} *" using "" options {search 
mode:grep, case sensitive:false, starting at top:true}
        replace "^TOTALE EURO\\h+" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
        replace "C\\.F\\.\\h*" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
        replace "^(\\d{2}-\\d{2}-\\d{4})\\h+\\d{2}:\\d{2}" using "\\1" options 
{search mode:grep, case sensitive:false, starting at top:true}
        replace "(?<=\\w)\\R(?=\\w)" using "\\t" options {search mode:grep, 
case sensitive:false, starting at top:true}
        replace "^$\\R" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
        
        select insertion point before it
        
    end tell
end tell

----------------------------------------------------------------

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to