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

Re: Problems with clip and deleting between text

Expand Messages
  • Eb
    Michael, You didn t say HOW the clip doesn t work properly. So I can only suggest, that you add a ^!SetDebug 1 command at the point of your clip, where things
    Message 1 of 10 , Jan 3, 2011
    View Source
    • 0 Attachment
      Michael,

      You didn't say HOW the clip doesn't work properly. So I can only suggest, that you add a ^!SetDebug 1 command at the point of your clip, where things start to go wrong. Then single-step through your code, and see if there is a point at which it does go wrong.

      If the single stepping works, then you have a timing problem. That you could cure by inserting some delays at key points. ^!Delay 2
      for example (in tenths of seconds).


      Good luck,


      Eb

      --- In ntb-clips@yahoogroups.com, "mikeyboy351" <michael.linahan@...> wrote:
      >
      > 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
      >
    • mikeyboy351
      Eb, Thanks for the prompt response. The problem is that the selected text doesn t delete when it is fully automated but if I use the !^Continue, halt the code
      Message 2 of 10 , Jan 3, 2011
      View Source
      • 0 Attachment
        Eb,
        Thanks for the prompt response.

        The problem is that the selected text doesn't delete when it is fully automated but if I use the !^Continue, halt the code and then use the delete key it works fine but for one replace only. I thought that it might be something to do with loosing the position of the start and end places to select but I am not sure. When automated the first few times through the loop seem fine but after about 20 replaces it seems to stop working as it should and sometimes the between text is deleted and sometimes not and there is also some corruption with clip code being inserted into my text files. The test files i am working on are very large. I have solved the problem using Excel and writing some vba but I would like it to be done in notetab as some of the text lines have characters that excel recognises as equations.

        Regards

        Mike
      • Don
        ... I too suspect that a delay may be required. I see that you are replacing with empty instead of a keyboard command. If that is the point where it is not
        Message 3 of 10 , Jan 3, 2011
        View Source
        • 0 Attachment
          On 1/3/2011 6:32 AM, Eb wrote:
          > Michael,
          >
          > You didn't say HOW the clip doesn't work properly. So I can only suggest, that you add a ^!SetDebug 1 command at the point of your clip, where things start to go wrong. Then single-step through your code, and see if there is a point at which it does go wrong.
          >
          > If the single stepping works, then you have a timing problem. That you could cure by inserting some delays at key points. ^!Delay 2
          > for example (in tenths of seconds).
          >
          >
          > Good luck,
          >
          >
          > Eb
          >
          > --- In ntb-clips@yahoogroups.com, "mikeyboy351" <michael.linahan@...> wrote:
          >>
          >> 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.

          I too suspect that a delay may be required. I see that you are
          replacing with empty instead of a keyboard command. If that is the
          point where it is not going well, then try a minor delay there.

          I assume this may be the area?
          :DoFirst
          > ;^!Continue ^$GetParaRow$
          > ^!SelectTo 1:1
          >
          > ;delete the selected region
          > ^!SetCode %KeepText%=^$GetSelection$
          > ^!InsertText ^%EMPTY%


          I assume select to 1:1 may be taking a second.
        • Don
          I hate excel -- for just such reasons :-) You can format the excel document as text before starting and solve that problem -- which I do when working with
          Message 4 of 10 , Jan 3, 2011
          View Source
          • 0 Attachment
            I hate excel -- for just such reasons :-)
            You can format the excel document as text before starting and solve that
            problem -- which I do when working with times which it mistakes for dates.

            It sounds like you may have a memory issue -- try adding some clear
            variables in to clean up the memory as you go.

            Without testing it I'm kind of shooting in the dark here.

            On 1/3/2011 7:11 AM, mikeyboy351 wrote:
            > Eb,
            > Thanks for the prompt response.
            >
            > The problem is that the selected text doesn't delete when it is fully automated but if I use the !^Continue, halt the code and then use the delete key it works fine but for one replace only. I thought that it might be something to do with loosing the position of the start and end places to select but I am not sure. When automated the first few times through the loop seem fine but after about 20 replaces it seems to stop working as it should and sometimes the between text is deleted and sometimes not and there is also some corruption with clip code being inserted into my text files. The test files i am working on are very large. I have solved the problem using Excel and writing some vba but I would like it to be done in notetab as some of the text lines have characters that excel recognises as equations.
            >
            > Regards
            >
            > Mike
          • mikeyboy351
            Don, Eb, I tried adding a delay of up to 20 just before the text was selected, after it was deleted and after the jump to the previous position at the start of
            Message 5 of 10 , Jan 4, 2011
            View Source
            • 0 Attachment
              Don, Eb,
              I tried adding a delay of up to 20 just before the text was selected, after it was deleted and after the jump to the previous position at the start of the loop all to no avail. there was still clip text appearing in my loaded file and sometimes the text was not replaced. I even tried setting the debug option but with over 4000 lines of text it is not really an option. The files are 40M a piece and I have 4 of them to process.
              In the end I broke the 40M files into 3 (one for each month of takings) and retried and lo and behold even without the delay everything works fine. I am not sure why but I have solved the problem to some extent, the next thing to do is to automatically split the file... but that is for another day.
              The learning curve has been rather steep as this is my first foray into clip programming but I will persevere. Thanks for the help and suggestions.

              Regards

              Mike
            • Don
              ... I m guessing memory issues may be the thing. The set debug can go anywhere and it can be triggered on a counter if you want to. The learning curve is worth
              Message 6 of 10 , Jan 4, 2011
              View Source
              • 0 Attachment
                On 1/4/2011 7:47 AM, mikeyboy351 wrote:
                > Don, Eb,
                > I tried adding a delay of up to 20 just before the text was selected, after it was deleted and after the jump to the previous position at the start of the loop all to no avail. there was still clip text appearing in my loaded file and sometimes the text was not replaced. I even tried setting the debug option but with over 4000 lines of text it is not really an option. The files are 40M a piece and I have 4 of them to process.
                > In the end I broke the 40M files into 3 (one for each month of takings) and retried and lo and behold even without the delay everything works fine. I am not sure why but I have solved the problem to some extent, the next thing to do is to automatically split the file... but that is for another day.
                > The learning curve has been rather steep as this is my first foray into clip programming but I will persevere. Thanks for the help and suggestions.
                >
                > Regards
                >
                > Mike

                I'm guessing memory issues may be the thing.
                The set debug can go anywhere and it can be triggered on a counter if
                you want to.
                The learning curve is worth it so keep at it -- but it took me a while
                as well.
              • John Shotsky
                When debugging clips, I copy a small portion of a larger document and paste it into a new document, then run the clips on that. It doesn t need to be saved
                Message 7 of 10 , Jan 4, 2011
                View Source
                • 0 Attachment
                  When debugging clips, I copy a small portion of a larger document and paste it into a new document, then run the clips
                  on that. It doesn't need to be saved first. That way, you can have just the item(s) you are looking for, the clips run
                  fast, and you can undo your way back through it to see what was done, and when. You can also step back through it using
                  redo. This way, you gain an understanding of exactly what your clips are doing, and in what order. It is similar to
                  using debug, but is easier to manage, and you can reverse direction any time you need to.

                  I also have a 'scratchpad' clip where I try things out. Just paste one or a few lines of clipcode there, and run it on
                  your small document. As each bit of code is made to work right, give it its own home or add to an existing clip and then
                  build some more. Use ^!GoTo Exit in your main body of clips to halt execution where you want it, then use your
                  scratchpad clip to carry it from there on. That lets you run through your tested clips first, then stop exactly where
                  needed to test the next thing.

                  In this example, it would have run correctly, apparently, until the large file was attempted. That would tell you the
                  code is right, but there is another problem. A large file would have a large undo buffer also, so your main memory could
                  be exhausted, causing the swap file to become active. That's a much slower process, which could then introduce timing
                  errors. This can be tested for by stopping other programs, using Task manager to stop unneeded background processes, and
                  starting with a fresh copy of the large document, so there is no undo buffer in place. Depending on resources, that
                  could be enough to get it to run correctly.

                  Regards,
                  John
                  Recipe formatting tools:
                  <http://recipetools.gotdns.com/> http://recipetools.gotdns.com
                  Beaverton Weather:
                  <http://shotsky.gotdns.com/> http://shotsky.gotdns.com


                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of mikeyboy351
                  Sent: Tuesday, January 04, 2011 4:48 AM
                  To: ntb-clips@yahoogroups.com
                  Subject: [Clip] Re: Problems with clip and deleting between text


                  Don, Eb,
                  I tried adding a delay of up to 20 just before the text was selected, after it was deleted and after the jump to the
                  previous position at the start of the loop all to no avail. there was still clip text appearing in my loaded file and
                  sometimes the text was not replaced. I even tried setting the debug option but with over 4000 lines of text it is not
                  really an option. The files are 40M a piece and I have 4 of them to process.
                  In the end I broke the 40M files into 3 (one for each month of takings) and retried and lo and behold even without the
                  delay everything works fine. I am not sure why but I have solved the problem to some extent, the next thing to do is to
                  automatically split the file... but that is for another day.
                  The learning curve has been rather steep as this is my first foray into clip programming but I will persevere. Thanks
                  for the help and suggestions.

                  Regards

                  Mike



                  [Non-text portions of this message have been removed]
                • Don
                  You might also add a test to see what is selected (get size of selection). I wonder if there is a maximum selection size that is being violated or something?
                  Message 8 of 10 , Jan 4, 2011
                  View Source
                  • 0 Attachment
                    You might also add a test to see what is selected (get size of
                    selection). I wonder if there is a maximum selection size that is being
                    violated or something?
                    Under view>options>advanced there are some limits specified. I wonder
                    if the issue is on a particular part of the file -- however the fact
                    that it does parts of the file suggests that its some sort of limit
                    rather than some particular data.

                    On 1/4/2011 8:50 AM, John Shotsky wrote:
                    > When debugging clips, I copy a small portion of a larger document and paste it into a new document, then run the clips
                    > on that. It doesn't need to be saved first. That way, you can have just the item(s) you are looking for, the clips run
                  • Axel Berger
                    ... Nope. If that were the reason, splitting the file would not help. Axel
                    Message 9 of 10 , Jan 4, 2011
                    View Source
                    • 0 Attachment
                      Don wrote:
                      > I wonder if there is a maximum selection size that is being
                      > violated or something?

                      Nope. If that were the reason, splitting the file would not help.

                      Axel
                    Your message has been successfully submitted and would be delivered to recipients shortly.