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

syntax error parsing name and renaming file

Expand Messages
  • Jeffery Scism
    Purpose of Clip: Select the contents of the tag in a HTML document and (it is a person s name) parse it to last, first, Initial (or middle), and
    Message 1 of 7 , Jul 9, 2012
      Purpose of Clip: Select the contents of the <TITLE> tag in a HTML
      document and (it is a person's name) parse it to last, first, Initial
      (or middle), and rename the file as "last-first-middle.htm" in the
      "settable" default directory I can browse to. I then want it to have the
      option of running on all docs that are in the temporary saved directory
      in sequence.

      CLIP with COMMENTS FOLLOWS It hangs up on line 57 which says:
      ^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0) as a
      syntax error.

      ^!Insert HTML
      <hr><H2>
      ; Note: this clip begins by highlighting a person's name "John A. Doe"
      The following line inserts the
      ; selected text in a snippit of HTML code to make it aheader, and copy
      it to the TITLE field in the Head.

      ^&

      </H2><hr>
      ^!REPLACE "<TITLE>" >> "<title>^&" BI

      ; Start at the top - this portion is to select the Title contents for
      parsing

      ^!Jump TEXT_START
      ; Find lines conforming to the pattern and restructure
      ; # long line starts;This Clip will select all the text between the type
      of tag specified by the user. The search starts from the cursor position
      or the beginning of the text
      *
      ; THIS POINT - The wizard pops up with an empty field. (I want it to
      pre-fill with TITLE and run without escaping)* if I type TITLE it
      continues...


      ^!Find "<title" WISB
      ;End procedure if the searched tag is not found
      ^!IfError End
      ;Place cursor at end of selection and remove highlight
      ^!Jump Select_End
      ;Find end of opening tag
      ^!Find ">" S
      ^!IfError End

      :SetStartPosition
      ;Ensure input focus is in the document
      ^!FocusDoc
      ;Place cursor at end of selection and remove highlight
      ^!Jump Select_End
      ;Store cursor position in a variable
      ^!Set %Start%=^$GetRow$:^$GetCol$
      ;Search for the closing tag
      ^!Find "</^?[Tag]>" IS
      ;End the procedure if it is not found
      ^!IfError End

      ;Place cursor at start of selection and remove highlight
      ^!Jump Select_Start
      ;Store cursor position in a variable
      ^!Set %End%=^$GetRow$:^$GetCol$
      ;Move the cursor back to the first saved position (after the opening tag)
      ^!SetCursor ^%Start%
      ;Extend the selection to the second saved position (in front of the
      closing tag)
      ^!SelectTo ^%End%
      *
      ; THIS IS THE END OF THE SELECTION CLIP IT leaves the TITLE contents
      selected*

      *
      ;Work on selected NAME PARSING the CONTENTS of the <TITLE> Tag Field, IT
      DOESN'T Finish.*

      ^!SetListDelimiter " "
      ^!SetArray %full_name%=^$GetSelection$
      ^!Set %indexed_name%="^%full_name^%full_name0%%"
      ^!Set %name_counter%=1

      :CreateName
      ^!If ^%name_counter% = ^%full_name0% NameDone
      ^!Set %indexed_name%="^%indexed_name%-^%full_name^%name_counter%%"
      ^!Inc %name_counter%
      ^!Goto CreateName

      :NameDone
      ;strip periods*
      ;Here is where it HANGS
      ^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0)*

      ^!Set %indexed_name%=^$StrLower("^%indexed_name%")$
      ;(Syntax error this line)
      ^!Set %indexed_name%=^$FileName$.htm

      ;END OF CLIP


      [Non-text portions of this message have been removed]
    • Axel Berger
      ... I haven t tested your clip, but are you sure NT accepts 0 where FALSE is expected? Axel
      Message 2 of 7 , Jul 9, 2012
        Jeffery Scism wrote:
        > It hangs up on line 57 which says:
        > ^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0)
        > as a syntax error.

        I haven't tested your clip, but are you sure NT accepts "0" where
        "FALSE" is expected?

        Axel
      • Jeffery Scism
        ... No, I am not. (This is based on a clip you wrote for me several years ago for NTB STD 4.95. I am NOW running it in Pro 7. I assume the clip parameters
        Message 3 of 7 , Jul 9, 2012
          On 7/9/2012 11:14 AM, Axel Berger wrote:
          > I haven't tested your clip, but are you sure NT accepts "0" where
          > "FALSE" is expected?
          >
          > Axel


          No, I am not.

          (This is based on a clip you wrote for me several years ago for NTB STD
          4.95. I am NOW running it in Pro 7.

          I assume the clip parameters have changed.

          I ran it with SETDEBUG ON.

          The INCREMENT was continuously running

          So I dropped that part (Does it NEED to have an INCREMENT counter?) It
          ran well past the "3" it was supposed to stop at - over a half million
          when I stopped it. It was running in the background.
        • Art Kocsis
          ... As it should. If you replace the * at the end of the statement with a $ I think you will find it runs quite well. When you get a syntax error it is
          Message 4 of 7 , Jul 9, 2012
            At 7/9/2012 11:04 AM, you wrote:
            >CLIP with COMMENTS FOLLOWS It hangs up on line 57 which says:
            >^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0) as a
            >syntax error.
            >
            >:NameDone
            >;strip periods*
            >;Here is where it HANGS
            >^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0)*

            As it should. If you replace the "*" at the end of the statement with a "$"
            I think you will find it runs quite well.

            When you get a "syntax error" it is usually just that. Go to ClipHelp, copy
            the relevant command/function/whatever and paste it right below a copy of
            the offending statement. Line up the corresponding parts and the answer
            should pop right out (Remember, syntax is format, not content):

            ^$StrReplace(". ";" ";"^%indexed_name%";
            0; 0)*
            ^$StrReplace("SubStr";"ReplaceStr";"Str
            ";CaseSensitive;WholeWord)$

            BTW, I didn't analyze the rest of your code but if you got into an infinite
            loop you have
            some bad code somewhere. If you are relying on a test for equality to exit,
            change it
            to test for an inequality, "<= " or "<=". If you are relying on an error
            exit for Find, make
            sure you are progressing thru your document and not re-searching the same
            text. If in
            doubt, add a loop counter and panic exit.


            And Alex, if you go to the ClipHelp file and search for True or False, you
            will find:

            [a True] IValue is equal to 1, TRUE, YES, Y, or ON (case insensitive)
            [a False] Value is an empty string or equal to 0, FALSE, NO, N, or OFF
            (case insensitive)

            Zero has been used for false in many examples posted here.

            Art
          • Axel Berger
            ... That s it of course, why didn t I see it? Am I going blind in old age or just losing my wits? ... When search as I might I just could not find an error I
            Message 5 of 7 , Jul 9, 2012
              Art Kocsis wrote:
              > If you replace the "*" at the end of the statement with a "$"

              That's it of course, why didn't I see it? Am I going blind in old age or
              just losing my wits?

              > [False] Value is an empty string or equal to 0, FALSE, NO, N, or OFF

              When search as I might I just could not find an error I bagan clutching
              at straws.

              Thanks for clearing it up

              Axel
            • Jeffery Scism
              ... I must be stuck on Stoopid , because I still get the syntax error. This is not acting like I expected. I replaced the * with a $ , and I compared the
              Message 6 of 7 , Jul 9, 2012
                On 7/9/2012 5:52 PM, Art Kocsis wrote:
                > ^$StrReplace(". ";" ";"^%indexed_name%";
                > 0; 0)*
                > ^$StrReplace("SubStr";"ReplaceStr";"Str
                > ";CaseSensitive;WholeWord)$

                I must be "stuck on Stoopid", because I still get the syntax error.

                This is not acting like I expected.

                I replaced the "*" with a "$", and I compared the Help syntax with
                the code syntax, and can not figure out what should be "popping" out
                at me.

                This line is supposed to be eliminating left over "." from the old
                name which followed the middle initial and the result would be a parsed
                from 1:2:3 to a "3-1-2.htm" parsed name in lower case. and that should
                be the resulting field name.

                After beating my head against this all day I am going to bed.

                Jeff
              • Art Kocsis
                ... Sometimes (usually!) sleep helps. Make sure your syntax error is coming from the place you think it is. Isolate the code from the rest of the clip and
                Message 7 of 7 , Jul 10, 2012
                  At 7/9/2012 10:28 PM, you wrote:
                  >On 7/9/2012 5:52 PM, Art Kocsis wrote:
                  > > ^$StrReplace(". ";" ";"^%indexed_name%";
                  > > 0; 0)*
                  > > ^$StrReplace("SubStr";"ReplaceStr";"Str
                  > > ";CaseSensitive;WholeWord)$
                  >
                  >I must be "stuck on Stoopid", because I still get the syntax error.
                  >
                  >This is not acting like I expected.
                  >
                  >I replaced the "*" with a "$", and I compared the Help syntax with
                  >the code syntax, and can not figure out what should be "popping" out
                  >at me.

                  Sometimes (usually!) sleep helps.

                  Make sure your "syntax error is coming from the place you think it is.

                  Isolate the code from the rest of the clip and work with the snippet.

                  The code below uses your line with the "*" replaced and it works fine:

                  =====================================
                  ^!SetDebug On
                  ^!Set %indexed_name%=lkjlkul..hgokj
                  ^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0)$
                  =====================================

                  Copy the last code line to your clip just below your line and compare.
                  A trick I use is to sort the two lines with "Remove dup lines" enabled.
                  If one line disappears, then they are identical. If not, something is
                  different.
                  If you can't spot the difference, split the lines in half and check each half.

                  Let us know how this works.

                  Alex, I have to admit that I didn't notice the "*" at first. That's why I
                  rely on
                  comparing to templates and/or sorting. Or in desperation - "Throw bird"


                  Namaste', Art
                Your message has been successfully submitted and would be delivered to recipients shortly.