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

find and replace again

Expand Messages
  • ::Andrew::
    Hello ntb-clips, Couple of questions. I ve written a simple clip that looks for the title of an html document and adds text to the end of it. ^!Replace
    Message 1 of 3 , Nov 4, 2001
      Hello ntb-clips,

      Couple of questions.

      I've written a simple clip that looks for the title of an html
      document and adds text to the end of it.

      ^!Replace "</TITLE>" >> " - Power Tools Software Discussion List</TITLE>" GIWRSA

      this works really well but it begs two questions:-
      a) can i run a command that says if </title> follows List, don't
      replace? I wondered about an IF and skip command here.
      b) I think someone once said I could run a clip without opening the
      files each time. I've set screen update currently to off which speed
      things up but I don't really need the files to open to run this
      script. How does that work?

      Finally I'll like to add keywords and descriptions to each page

      ^!Replace "<meta name="generator" content="MindManager v4.0.81">"
      >> "%NL%<meta name="Keyword" content="Power tools">" GIWSA

      but this which is all on one line doesn't work. You'll notice I
      haven't set this one to regular expressions. I'm not really sure
      what I'm doing here. I want the metatags on new lines and might
      follow ht intitial keywords one with a description tag which would
      be on another new line. How would that work?

      Thanks in advance ;)

      Andrew



      --
      Best regards,
      ::Andrew:: mailto:notetab@...

      Join the Power Tools Discussion:
      - --------------------------------
      Recommended software: http://at.omic.co.uk/powertools.htm
      Subscribe: powertoolssoftware-subscribe@yahoogroups.com
    • Hugo
      Andrew, If you want to use the preset variable %NL%, you have to write it as ^%NL%. Hugo
      Message 2 of 3 , Nov 5, 2001
        Andrew,

        If you want to use the preset variable %NL%, you have to write it as
        ^%NL%.

        Hugo

        >
        > Finally I'll like to add keywords and descriptions to each page
        >
        > ^!Replace "<meta name="generator" content="MindManager v4.0.81">"
        > >> "%NL%<meta name="Keyword" content="Power tools">" GIWSA
        >
        > but this which is all on one line doesn't work. You'll notice I
        > haven't set this one to regular expressions. I'm not really sure
        > what I'm doing here. I want the metatags on new lines and might
        > follow ht intitial keywords one with a description tag which would
        > be on another new line. How would that work?
        >
      • Hugo
        Andrew, Why do you use a regular expression here? You re only changing plain text... ... List GIWRSA ... You can use conditional statements, there are
        Message 3 of 3 , Nov 5, 2001
          Andrew,

          Why do you use a regular expression here? You're only changing plain
          text...

          >
          > ^!Replace "</TITLE>" >> " - Power Tools Software Discussion
          List</TITLE>" GIWRSA
          >
          > this works really well but it begs two questions:-
          > a) can i run a command that says if </title> follows List, don't
          > replace? I wondered about an IF and skip command here.

          You can use conditional statements, there are many ways to construct
          them; here is a very simple example:

          ^!Find "</title> followed by List" [options]
          ^!IfError LABEL1 Else LABEL2
          :LABEL1
          ; if "</title> followed by List" is NOT FOUND...
          ^!Replace "text1" >> "text2" [options]
          :LABEL2
          ; executed in these cases:
          ; 1. "</title> followed by List" is FOUND (LABEL1 is skipped)
          ; 2. after the replacement in LABEL1
          ; ("</title> followed by List" NOT FOUND)
          ^!NEXT INSTRUCTION

          > b) I think someone once said I could run a clip without opening
          the
          > files each time. I've set screen update currently to off which
          speed
          > things up but I don't really need the files to open to run this
          > script. How does that work?

          As far as I know, there is no way to use SearchDisk in a clip by now.
          You could try fiddling with ^!Keyboard CTRL+D and inserting texts in
          the fields using #...#

          From Help Clip Language - Find / Replace text

          "Use the following commands and functions to search or replace text
          in the active document..."

          Or else you could investigate a function such as StrReplace... You
          would have to find a way to find/identify the textstrings you want to
          have written to file. Use Clip Language Document Management or Clip
          Language - Disk Files for additional information.

          ^$StrReplace("SubStr";"ReplaceStr";"Str";CaseSensitive;WholeWord)$
          Returns a new string with all occurrences of SubStr replaced with
          ReplaceStr according to the settings of the CaseSensitive and
          WholeWord parameters. Tab and line-break tokens are automatically
          converted to their real characters since version 4.6. Example:
          ^$StrReplace("o";"?";"NoteTab Pro";True;False)$ -> N?teTab Pr?



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