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

Re: [Clip] Problems with Labels...

Expand Messages
  • Alec Burgess
    Steve: I won t comment on the accuracy of your clip logic or John s ... YES they are but the problem is you are thinking of a Label as being a sub-routine or
    Message 1 of 3 , May 11, 2010
    • 0 Attachment
      Steve: I won't comment on the accuracy of your clip logic or John's
      suggested clip but in answer to your primary question:
      >Instead, I get "SNN17°13'16"E" as if both labels have run.
      > Are labels run without being told to run?

      YES they are but the problem is you are thinking of a Label as being a
      sub-routine or function.
      ie. your suggested clip contains these lines:
      > ^!IfSame "N" "^%S1%" ^!Goto IFNORTH
      > :IFNORTH
      > ^$StrReplace("^%S1%";"S";^%S1%;FALSE;FALSE)$
      Regardless of the contents of "^%S1%" execution is going to fall through
      to execute the line after :IFNORTH either by being jumped to it or by
      falling through to it.

      This is*NOT* the best way to do it but hopefully following (clip not
      tested) shows how GOTO's and IF statements are handled:

      H="Reverse Bearing"
      ^!Set %S1%=^$GetChar$
      :TESTNORTH
      ^!IfSame "N" "^%S1%" ^!Goto IFNORTH
      ^!GOTO TESTSOUTH
      :IFNORTH
      ^$StrReplace("^%S1%";"S";^%S1%;FALSE;FALSE)$
      :TESTSOUTH
      ^!IfSame "S" "^%S1%" ^!Goto IFSOUTH
      ^!GOTO N_S_TESTS_DONE
      :IFSOUTH
      ^$StrReplace("^%S1%";"N";^%S1%;FALSE;FALSE)$
      :N_S_TESTS_DONE

      Note - following is NOT recommended practice and is not documented (I
      discovered it accidentally a while ago):
      If you put a ":" in front of a target label, though not required it is
      accepted by the clip parser. I just find it easier to spot the labels in
      clip code when they have a colon in front of them. YMMV :-\

      So instead of writing:
      ^!If Integer1 <>= Integer2 GoToLabelTrue ELSE GoToLabelFalse
      you could instead write:
      ^!If Integer1 <>= Integer2 :GoToLabelTrue ELSE :GoToLabelFalse
      ; in this case any code before label can NEVER be executed
      :GoToLabelTrue
      ... do true stuff
      END
      :GoToLabelFalse
      ... do false stuff
      END

      One other thing ... you've used the construction
      ^!IF expression ^!GOTO <space> IFNORTH
      while this works I want to make sure you understand its exactly the same as:
      ^!IF expression IFNORTH
      or the way I like to write it:
      ^!IF expression :IFNORTH

      When I started learning clips following examples in CLIP HELP, I found
      the use of labels like "GoToLabelTrue" confusing and wonder if that's
      why you were using the unnecessary:
      ^!IF expr ^!GOTO somelabel
      instead of
      ^!IF expr somelabel

      One last thing ... at least while you are starting *DO* use ^!SETDEBUG
      ON so you can step through your code. It won't show the labels
      themselves but will show that you are getting to lines you didn't think
      you should.

      Hope some of this helps ... Alec


      On 2010-05-11 01:10, John Shotsky wrote:
      >
      > This really depends on what your entire data strings look like. If you
      > have lines like:
      > "N17°13'16"E"
      > With nothing else on the lines, it is a simple matter of writing a few
      > replace statements.
      > Something along the lines of this, for the above example:
      > ^!Replace "^N(\d+°.+)E" >> "S$1W" ARSTW
      > Will produce this:
      > "S17°13'16"W"
      >
      > Regards,
      > John
      >
      > From: ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com>
      > [mailto:ntb-clips@yahoogroups.com
      > <mailto:ntb-clips%40yahoogroups.com>] On Behalf Of Steve
      > Sent: 10 May, 2010 09:30 PM
      > To: ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com>
      > Subject: [Clip] Problems with Labels...
      >
      >
      > Hi Everyone,
      >
      > I am trying to reverse (as in north to south, south to north)the
      > direction of the first letter of a
      > string, such as "N17°13'16"E" to make it "S17°13'16"E".
      >
      > I put the cursor at the beginning of the string in the editor and run
      > my clip:
      >
      > H="Reverse Bearing"
      > ^!Set %S1%=^$GetChar$
      > ^!IfSame "N" "^%S1%" ^!Goto IFNORTH
      > :IFNORTH
      > ^$StrReplace("^%S1%";"S";^%S1%;FALSE;FALSE)$
      > ^!IfSame "S" "^%S1%" ^!Goto IFSOUTH
      > :IFSOUTH
      > ^$StrReplace("^%S1%";"N";^%S1%;FALSE;FALSE)$
      >
      > H=";"
      >
      > Instead, I get "SNN17°13'16"E" as if both labels have run. Are labels
      > run without being told to run?
      >
      > Any suggestions will be appreciated, as I have more than 600 of these
      > to change.
      >
      > PS: I also want to reverse the last letter, but figure once I learn
      > how to reverse the first I will
      > be able to do the second..)
      >
      > Thanks,
      >
      > Steve
      >
      > [Non-text portions of this message have been removed]
      >
      >

      --
      Regards ... Alec (buralex@gmail& WinLiveMess - alec.m.burgess@skype)



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.