Loading ...
Sorry, an error occurred while loading the content.

21375Problems with clip and deleting between text

Expand Messages
  • mikeyboy351
    Jan 3, 2011
    • 0 Attachment
      Hi Oh knowledgeable ones,
      I have been writing a clip to automatically process the output from our point of sale machine. The clip is below and should remove the control chars, search for some text, mark the position and then search for the next part, mark this select the text between the marks and then delete it. I am obviously doing something wrong as it doesn't work properly. However, if I use the !^Continue and stop the clip, the correct text is highlighted and the delete key works. I have spend 3 days on this and am pulling my hair out at the moment so i hope that someone can prevent me from going completely bald!

      Regards

      Mike
      P.S. I can send a test file if anyone wants it.

      ^!Jump TEXT_START
      ; Use this to remove the troublesome control characters
      ;now replace characters that are NOT (^) a-z, A-Z, 0-9, Alpha chars [:alpha;]
      ; % ( ) spaces {\s} newlines {\n} Tabs {\t}
      ;characters betwee the \Q and \E : = - $ / ^ . ' [ ]

      ^!Replace [^a-zA-Z0-9[:alpha:]%()\s\n\t\Q:=-$/^.'[]\E] >> "" SAWRTI
      ^!StatusShow Replacing control characters

      ^!Jump TEXT_START
      ;find the text below and delete up to it
      ;The wordWrap might take some tome to do

      ^!StatusShow Setting Wordwrap OFF
      ^!Set %ww%=^$IsWordWrap$
      ^!If ^%ww%=0 ^!SetWordWrap OFF

      ^!Find "END OF DAY SUMMARY" SAI
      ^!IfError EXIT
      ^!If ^$GetParaRow$=1 DoRest ELSE DoFirst
      :DoFirst
      ;^!Continue ^$GetParaRow$
      ^!SelectTo 1:1

      ;delete the selected region
      ^!SetCode %KeepText%=^$GetSelection$
      ^!InsertText ^%EMPTY%

      ;Use the next line to halt
      ^!Continue "Do you want to continue processing the file ?"

      :Loop
      ^!SetScreenUpdate Off

      :DoRest

      ^!Find "End of Report" SAI
      ^!IfError EXIT
      ^!Jump +1
      ^!Set %FromLine%=^$GetParaRow$

      ^!Find "END OF DAY SUMMARY" SAI
      ^!IfError EXIT
      ^!Jump -1
      ^!Set %ToLine%=^$GetParaRow$

      ^!Set %Test%=^$Calc((^%ToLine%-1);0)$
      ^!Set %PercentDone%=^$Calc(100*(^%FromLine%/^$GetLineCount$);0)$

      ^!StatusShow ^%PercentDone% "%"

      ^!If ^%FromLine% >= ^%Test% Loop

      ;^!SetScreenUpdate On
      ^!SelectTo ^%FromLine%:1

      ^!Continue ^%FromLine% ^%Test%

      ;I have tried both methods
      ;^!Keyboard DELETE
      ^!SetCode %KeepText%=^$GetSelection$
      ^!InsertText ^%EMPTY%

      ^!Set %Test%=^$Calc((^%FromLine%-2);0)$
      ^!Jump ^%Test%
      ^;!Jump TEXT_START
      ^!ClearVariables
      ^!Goto Loop

      :EXIT
      ^!SetScreenUpdate On
      ^!Select ALL
      ^!Keyboard SHIFT+CTRL+I
    • Show all 10 messages in this topic