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

Re: [ppro-b] An epilogistic question

Expand Messages
  • Sheri
    Some observations. On Windows 7 you should be using the windows plugin version of keys and the {sinp} type. You have excessively long waits. 50 should be
    Message 1 of 6 , Apr 1 11:16 AM
    View Source
    • 0 Attachment
      Some observations. On Windows 7 you should be using the windows plugin
      version of keys and the {sinp} type. You have excessively long waits. 50
      should be sufficient. Maybe 100 max. Rather than Clip.copy, you can use
      the win.keys equivalent ^c

      You can test the size of the clipboard. After clearing it should be
      zero. After copying it should not. I have at least one script where it
      is sometimes still zero after the first ^c. If I find it to be zero, my
      script repeats its win.keys("{sinp}^c"} and the second use is usually a
      charm. You have a backslash in a string. Unless your powerpro
      configuration uses a non-stand escape character, to preserve a
      backslash, you need to use a Powerpro literal string, i.e., ?"\40" but I
      don't know what you're trying to do there. The variable is being used as
      a regex. A "4" doesn't need escaping. \40 (if the backslash is
      preserved) is an octal in a regular expression.

      I think you should take this to the main powerpro list, where there are
      more Windows 7 users.

      Regards,
      Sheri

      On 4/1/2011 2:24 AM, antojuna wrote:
      > Here it is a modification of a previous script. It doesn't work well. The most surprising is the result. You can see in the win.debug box that all the text is selected but the result is "8". No more. Why?. It seems a cabalistic message but I can't understand the meaning, maybe "8" announces "infinite". I must say that I have tested "\s+" and "\s" also and the result is "8" again. What a mistery here. The "wait.for" are longer because the file is longer. This is the script:
      >
      > local var1 = "\40+"
      > local var2 = "\40"
      > Do("C:/Programs/metapad35/metapad.exe", "M:query.txt")
      > Wait.for(1500,activewindow("*query*"))
      > Clip Clearclipboard
      > wait.for(1250)
      > keys {Ctrl}a
      > wait.for(2000)
      > Clip Copy
      > wait.for(2000)
      > local allthetext = clip.get
      > wait.for(1000)
      > win.debug("before replaceg" ++ allthetext)
      > wait.for(10000)
      > allthetext = regex.replaceg(allthetext, var1, var2)
      > wait.for(10000)
      > win.debug("after replaceg" ++ allthetext)
      > wait.for(250)
      > clip.setpaste(allthetext)
      > Window.Show("*query*")
      > keys {Ctrl}a
      > Clip Paste
      > wait.for(050)
      >
      >
    • antojuna
      I am long happy user of Windows 2000 SP4 but Microsoft changes and I have to do it. I would rather not to do it but it s time. In spite of all I am not in
      Message 2 of 6 , Apr 1 10:57 PM
      View Source
      • 0 Attachment
        I am long happy user of Windows 2000 SP4 but Microsoft changes and I have to do it. I would rather not to do it but it's time. In spite of all I am not in hurry. I just want to use some basic features in Windows 7, I am get used to them. I hate to discover another thing that I can't use in Windows 7 and they are many. I don't love Windows 7 because I can't take profit of PowerPro. I'm suscribed to the other list but it is another league, I have a lot of digests to read but I don't understand what you do. I won't be there, I will stand beginner forever.

        On my script, I must say that "8" appears in the section of "Regular Expressions" in the Help File. Its enigmatic meaning is there. Besides I got what I wanted: to use Regular Expressions inside Metapad, after renouncing to the variables. This is my last version of the script:

        Do("C:/Programs/metapad35/metapad.exe", "M:query.txt")
        Wait.for(1500,activewindow("*query*"))
        Clip Clearclipboard
        wait.for(050)
        keys ^a
        wait.for(050)
        Clip Copy
        wait.for(050)
        local allthetext = clip.get
        wait.for(050)
        win.debug("before replace" ++ allthetext)
        wait.for(050)
        local alpha=(allthetext)
        win.debug("inside replace" ++ alpha)
        alpha[?"\40+"] = " "
        wait.for(050)
        win.debug("after replace" ++ alpha)
        wait.for(050)
        clip.setpaste(alpha)
        wait.for(050)
        Window.Show("*query*")
        keys ^a
        Clip Paste
        wait.for(050)

        It works although {alpha[?"\40+"] = " "} admits "\40" on the left side but it doesn't on the right side. It erases all the unnecessary spaces in a file. But I don't like it. I want to use "regex.replaceg" but I don't know how. I tried

        allthetext = regex.replaceg(allthetext, ?"\40+", ?"\40")
        allthetext = regex.replaceg(allthetext, "'40+", "'40")

        according to the "Regex.chm" but they don't work. I don't know why. I get "1" o "2" or none in the debug window but no result. The script selects all the text and it erases all.

        Your words are inspiring but I have to study every sentence because almost every idea is new for me. Thanks for your help.


        --- In powerpro-beginners@yahoogroups.com, Sheri <silvermoonwoman@...> wrote:
        >
        > Some observations. On Windows 7 you should be using the windows plugin
        > version of keys and the {sinp} type. You have excessively long waits. 50
        > should be sufficient. Maybe 100 max. Rather than Clip.copy, you can use
        > the win.keys equivalent ^c
        >
        > You can test the size of the clipboard. After clearing it should be
        > zero. After copying it should not. I have at least one script where it
        > is sometimes still zero after the first ^c. If I find it to be zero, my
        > script repeats its win.keys("{sinp}^c"} and the second use is usually a
        > charm. You have a backslash in a string. Unless your powerpro
        > configuration uses a non-stand escape character, to preserve a
        > backslash, you need to use a Powerpro literal string, i.e., ?"\40" but I
        > don't know what you're trying to do there. The variable is being used as
        > a regex. A "4" doesn't need escaping. \40 (if the backslash is
        > preserved) is an octal in a regular expression.
        >
        > I think you should take this to the main powerpro list, where there are
        > more Windows 7 users.
        >
        > Regards,
        > Sheri
        >
        > On 4/1/2011 2:24 AM, antojuna wrote:
        > > Here it is a modification of a previous script. It doesn't work well. The most surprising is the result. You can see in the win.debug box that all the text is selected but the result is "8". No more. Why?. It seems a cabalistic message but I can't understand the meaning, maybe "8" announces "infinite". I must say that I have tested "\s+" and "\s" also and the result is "8" again. What a mistery here. The "wait.for" are longer because the file is longer. This is the script:
        > >
        > > local var1 = "\40+"
        > > local var2 = "\40"
        > > Do("C:/Programs/metapad35/metapad.exe", "M:query.txt")
        > > Wait.for(1500,activewindow("*query*"))
        > > Clip Clearclipboard
        > > wait.for(1250)
        > > keys {Ctrl}a
        > > wait.for(2000)
        > > Clip Copy
        > > wait.for(2000)
        > > local allthetext = clip.get
        > > wait.for(1000)
        > > win.debug("before replaceg" ++ allthetext)
        > > wait.for(10000)
        > > allthetext = regex.replaceg(allthetext, var1, var2)
        > > wait.for(10000)
        > > win.debug("after replaceg" ++ allthetext)
        > > wait.for(250)
        > > clip.setpaste(allthetext)
        > > Window.Show("*query*")
        > > keys {Ctrl}a
        > > Clip Paste
        > > wait.for(050)
        > >
        > >
        >
      • Sheri
        ... I would suggest to use hex representation for space x20 because it is more obvious what it means in a regex pattern than 40 and hex is recognized in
        Message 3 of 6 , Apr 2 7:06 AM
        View Source
        • 0 Attachment
          --- In powerpro-beginners@yahoogroups.com, "antojuna" <h0dy2s.shotynt@...> wrote:
          >
          > I am long happy user of Windows 2000 SP4 but Microsoft changes and I have to do it. I would rather not to do it but it's time. In spite of all I am not in hurry. I just want to use some basic features in Windows 7, I am get used to them. I hate to discover another thing that I can't use in Windows 7 and they are many. I don't love Windows 7 because I can't take profit of PowerPro. I'm suscribed to the other list but it is another league, I have a lot of digests to read but I don't understand what you do. I won't be there, I will stand beginner forever.
          >
          > On my script, I must say that "8" appears in the section of "Regular Expressions" in the Help File. Its enigmatic meaning is there. Besides I got what I wanted: to use Regular Expressions inside Metapad, after renouncing to the variables. This is my last version of the script:
          >
          > Do("C:/Programs/metapad35/metapad.exe", "M:query.txt")
          > Wait.for(1500,activewindow("*query*"))
          > Clip Clearclipboard
          > wait.for(050)
          > keys ^a
          > wait.for(050)
          > Clip Copy
          > wait.for(050)
          > local allthetext = clip.get
          > wait.for(050)
          > win.debug("before replace" ++ allthetext)
          > wait.for(050)
          > local alpha=(allthetext)
          > win.debug("inside replace" ++ alpha)
          > alpha[?"\40+"] = " "
          > wait.for(050)
          > win.debug("after replace" ++ alpha)
          > wait.for(050)
          > clip.setpaste(alpha)
          > wait.for(050)
          > Window.Show("*query*")
          > keys ^a
          > Clip Paste
          > wait.for(050)
          >
          > It works although {alpha[?"\40+"] = " "} admits "\40" on the left side but it doesn't on the right side. It erases all the unnecessary spaces in a file. But I don't like it. I want to use "regex.replaceg" but I don't know how. I tried
          >
          > allthetext = regex.replaceg(allthetext, ?"\40+", ?"\40")
          > allthetext = regex.replaceg(allthetext, "'40+", "'40")

          I would suggest to use hex representation for space \x20 because it is more obvious what it means in a regex pattern than \40 and hex is recognized in replacement text (at least for the regex.pcreReplace function).

          allthetext = regex.pcreReplace(?"\x20+", allthetext, ?"\x20")

          Note that the pattern rather than the subject is the first argument for pcreReplace.

          You could successfully use regex.replaceg instead if you wish provided you use an actual space in the replacement text. E.g., you could allow Powerpro itself (rather than the regex plugin) to interpret the replacement text:

          allthetext = regex.replaceg(allthetext, ?"\x20+", "\x20")

          At the time the paste is made, you want to ensure that focus is on your editor. You can try this: before the keys to select all, use win.getfocus:

          pastewin=win.getfocus

          Then before the paste:

          win.setfocus(pastewin)

          Regards,
          Sheri
        • antojuna
          ... I come back to give the last result of my previou question. I m very happy with this script, it s useful for me but I m not the mind behind it. I would
          Message 4 of 6 , Apr 3 10:51 PM
          View Source
          • 0 Attachment
            --- In powerpro-beginners@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:

            > I would suggest to use hex representation for space \x20 because it is more obvious what it means in a regex pattern than \40 and hex is recognized in replacement text (at least for the regex.pcreReplace function).
            >
            > allthetext = regex.pcreReplace(?"\x20+", allthetext, ?"\x20")
            >
            > Note that the pattern rather than the subject is the first argument for pcreReplace.
            >
            > You could successfully use regex.replaceg instead if you wish provided you use an actual space in the replacement text. E.g., you could allow Powerpro itself (rather than the regex plugin) to interpret the replacement text:
            >
            > allthetext = regex.replaceg(allthetext, ?"\x20+", "\x20")
            >
            > At the time the paste is made, you want to ensure that focus is on your editor. You can try this: before the keys to select all, use win.getfocus:
            >
            > pastewin=win.getfocus
            >
            > Then before the paste:
            >
            > win.setfocus(pastewin)
            >
            > Regards,
            > Sheri
            >

            I come back to give the last result of my previou question. I'm very happy with this script, it's useful for me but I'm not the mind behind it. I would never have done without help. Thanks, Sheri, and thanks, brother Gabriel.

            Do("C:/Programs/metapad35/metapad.exe", "m:/query.txt")
            Wait.for(1500,activewindow("*query*"))
            Clip Clearclipboard
            lclip = clip.length
            wait.for(1050)
            pastewin=win.getfocus
            win.debug("before copy" ++ lclip)
            keys ^a
            wait.for(050)
            keys ^c
            wait.for(050)
            lclip = clip.length
            wait.for(050)
            ;if (lclip < 1) do
            if (lclip == 0) do
            keys ^c
            wait.for(050)
            lclip = clip.length
            endif
            win.debug("after copy" ++ lclip)
            local allthetext = clip.get
            wait.for(050)
            win.debug("before replace" ++ allthetext)
            wait.for(1050)
            allthetext = regex.pcreReplace(?"\x20+", allthetext, ?"\x20")
            wait.for(050)
            allthetext = regex.pcreReplace(?"(\x0d\x0a){4}", allthetext, ?"\x0d\x0a")
            wait.for(050)
            allthetext = regex.pcreReplace(?"\x0d\x0a\x2d", allthetext, ?"\x0d\x0a\x09\x97\x20")
            wait.for(050)
            allthetext = regex.pcreReplace(?"\x0d\x0aA\x2d", allthetext, ?"\x0d\x0a\x09\AUX\x20\x97\x20")
            wait.for(050)
            win.debug("after replace" ++ allthetext)
            wait.for(050)
            clip.setpaste(allthetext)
            wait.for(050)
            win.setfocus(pastewin)
            clip.paste
            wait.for(050)

            This script allows to use Regular Expressions with Metapad for a specific purpose. It changes tabs, spaces, new lines and some alphabetic characters as I want. There is a script named "AscCodesInClipbrd.powerpro" in the Files of the PowerPro Group. I used it for obtaining the hex numbers. There are two points to remark. I don't know the answers but I don't mind because I could find some solution.

            1.- The sequence "\x09\AUX" requires \ before A. This syntax seems to join \x09A in a single character. The symbol \ allows to get a simple "A" in "AUX"

            2.- allthetext = regex.replaceg(allthetext, ?"\x20+", "\x20") doesn't work on my computer. But allthetext = regex.pcreReplace(?"\x20+", allthetext, ?"\x20") does. "pcreReplace" is enough for me.
          • Sheri
            ... I m not experiencing that, but no harm in using a backslash in front of the A as you have in the replacement text. ... OK, I rarely use the older functions
            Message 5 of 6 , Apr 4 6:38 AM
            View Source
            • 0 Attachment
              > There are two points to remark. I don't know the answers but
              > I don't mind because I could find some solution.
              >
              > 1.- The sequence "\x09\AUX" requires \ before A. This syntax
              > seems to join \x09A in a single character. The symbol \
              > allows to get a simple "A" in "AUX"
              >

              I'm not experiencing that, but no harm in using a backslash in front of the A as you have in the replacement text.

              > 2.- allthetext = regex.replaceg(allthetext, ?"\x20+",
              > "\x20") doesn't work on my computer. But allthetext =
              > regex.pcreReplace(?"\x20+", allthetext, ?"\x20") does.
              > "pcreReplace" is enough for me.

              OK, I rarely use the older functions especially because they lack pattern diagnostics. Just looked up replaceg in regex.chm (and sorry I didn't sooner).

              regex.rg returns the string with replacements.

              regex.replaceg returns a return code. You need a fourth argument in regex.replaceg which is the variable name in double quotes. The variable subsequently has the string with replacements.

              So I think either of these would have worked:

              allthetext=regex.rg(allthetext, ?"\x20+", "\x20")
              rc = regex.replaceg(allthetext, ?"\x20+", "\x20", "allthetext")

              Regards,
              Sheri
            Your message has been successfully submitted and would be delivered to recipients shortly.