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

self-modifying clip

Expand Messages
  • graham.lawrence
    Suppose I create a variable whose content is a sequence of clip instructions. Suppose also that I recreate this variable many times in the course of this
    Message 1 of 10 , Apr 24, 2010
      Suppose I create a variable whose content is a sequence of clip instructions. Suppose also that I recreate this variable many times in the course of this clip, each time with a different sequence of instructions.

      Is there any way of executing these instruction sequences directly? Right now what I do is write the variable content out as a clip, execute it and then delete it, but it seems kind of kludgy.

      Thank you for your help,

      Graham Lawrence
    • loro
      ... Maybe I misunderstand, but I think you are asking for a way to reuse code. True? If so there are two ways, but I don t know if they fit your situation.
      Message 2 of 10 , Apr 24, 2010
        graham.lawrence wrote:
        >Suppose I create a variable whose content is a sequence of clip
        >instructions. Suppose also that I recreate this variable many times
        >in the course of this clip, each time with a different sequence of
        >instructions.
        >
        >Is there any way of executing these instruction sequences
        >directly? Right now what I do is write the variable content out as
        >a clip, execute it and then delete it, but it seems kind of kludgy.

        Maybe I misunderstand, but I think you are asking for a way to reuse
        code. True? If so there are two ways, but I don't know if they fit
        your situation. Look up ^!Clip, ^!FarClip and Custom Functions. The
        last has its own topic in Clip Help.

        Hope that was what you were asking for. :-)
        Lotta
      • Sheri
        ... If you only need to evaluate clip functions on the fly, then you can use variables. For commands, yes, it is necessary to store them in a file before you
        Message 3 of 10 , Apr 25, 2010
          --- In ntb-clips@yahoogroups.com, "graham.lawrence" <graham.lawrence@...> wrote:
          >
          > Suppose I create a variable whose content is a sequence of clip
          > instructions. Suppose also that I recreate this variable many
          > times in the course of this clip, each time with a different
          > sequence of instructions.
          >
          > Is there any way of executing these instruction sequences
          > directly? Right now what I do is write the variable content out
          > as a clip, execute it and then delete it, but it seems kind of
          > kludgy.

          If you only need to evaluate clip functions on the fly, then you can use variables. For commands, yes, it is necessary to store them in a file before you can run it. But you can run the new clip immediately afterwards under the control of the creating clip. And no need to delete it, you can reuse it next time.

          You might want to look at my "Instant Clip" clips. Eric included them with recent versions of NoteTab.

          They are stored in Cliphelp.clh (same dir as the NoteTab or NotePro exe file) and can be accessed from Clipcode Syntax.clb.

          Regards,
          Sheri
        • ebbtidalflats
          Graham, My understanding is, that you have complete clip commands in a variable, say: ^!If ^%index%=2 LABEL_2 else END The way to do what I think you want to
          Message 4 of 10 , Apr 26, 2010
            Graham,

            My understanding is, that you have complete clip commands in a variable, say:

            ^!If ^%index%=2 LABEL_2 else END

            The way to do what I think you want to do is to set the variable
            WITHOUT the leading caret and bank. As long as the rest of the line is a legitimat clip command, it should work:

            ^!Set %var%=If ^%index%=2 END else SOMETHING

            THEN you can execute the variable content with

            ^!^%var%


            WEASEL Clause: this has always worked for me, but there may be some exception that escapes me. I would test any such command with debug on, so I could see if the variable is being parsed correctly.


            Cheers,


            Eb


            --- In ntb-clips@yahoogroups.com, "graham.lawrence" <graham.lawrence@...> wrote:
            >
            > Suppose I create a variable whose content is a sequence of clip instructions. Suppose also that I recreate this variable many times in the course of this clip, each time with a different sequence of instructions.
            >
            > Is there any way of executing these instruction sequences directly? Right now what I do is write the variable content out as a clip, execute it and then delete it, but it seems kind of kludgy.
            >
            > Thank you for your help,
            >
            > Graham Lawrence
            >
          • Alec Burgess
            ... Brilliant Eb (though probably old hat to some of the other guru s). I haven t tested myself but I ll be on the lookout for some excuse to use it in the
            Message 5 of 10 , Apr 26, 2010
              On 2010-04-26 10:16, ebbtidalflats wrote:
              > Graham,
              >
              > My understanding is, that you have complete clip commands in a variable, say:
              >
              > ^!If ^%index%=2 LABEL_2 else END
              >
              > The way to do what I think you want to do is to set the variable
              > WITHOUT the leading caret and bank. As long as the rest of the line is a legitimat clip command, it should work:
              >
              > ^!Set %var%=If ^%index%=2 END else SOMETHING
              >
              > THEN you can execute the variable content with
              >
              > ^!^%var%
              >
              Brilliant Eb (though probably old hat to some of the other guru's). I
              haven't tested myself but I'll be on the lookout for some excuse to use
              it in the near future.

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


              >
              > WEASEL Clause: this has always worked for me, but there may be some exception that escapes me. I would test any such command with debug on, so I could see if the variable is being parsed correctly.
              >
              >
              > Cheers,
              >
              >
              > Eb
              >
              >
              > --- In ntb-clips@yahoogroups.com, "graham.lawrence"<graham.lawrence@...> wrote:
              >
              >> Suppose I create a variable whose content is a sequence of clip instructions. Suppose also that I recreate this variable many times in the course of this clip, each time with a different sequence of instructions.
              >>
              >> Is there any way of executing these instruction sequences directly? Right now what I do is write the variable content out as a clip, execute it and then delete it, but it seems kind of kludgy.
              >>
              >> Thank you for your help,
              >>
              >> Graham Lawrence
              >>
              >>
              >
              >
              >
            • graham lawrence
              Thank you for your help, Lotta and Sheri.  I gather that what I m doing is the only way to do it.  So be it. [Non-text portions of this message have been
              Message 6 of 10 , Apr 26, 2010
                Thank you for your help, Lotta and Sheri.  I gather that what I'm doing is the only way to do it.  So be it.




                [Non-text portions of this message have been removed]
              • loro
                ... I always forget about that. I have feeling it s documented somewhere, but I don t find it. Do you know where? Lotta
                Message 7 of 10 , Apr 26, 2010
                  ebbtidalflats wrote:
                  >^!Set %var%=If ^%index%=2 END else SOMETHING
                  >
                  >THEN you can execute the variable content with
                  >
                  >^!^%var%

                  I always forget about that. I have feeling it's documented somewhere,
                  but I don't find it. Do you know where?

                  Lotta
                • Sheri
                  ... I had problems doing that with an older versions, where there were functions in use as command parameters for the variable command. Even reported it at the
                  Message 8 of 10 , Apr 26, 2010
                    --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@...> wrote:
                    >
                    > Graham,
                    >
                    > My understanding is, that you have complete clip commands in a variable, say:
                    >
                    > ^!If ^%index%=2 LABEL_2 else END
                    >
                    > The way to do what I think you want to do is to set the variable
                    > WITHOUT the leading caret and bank. As long as the rest of the line is a legitimat clip command, it should work:
                    >
                    > ^!Set %var%=If ^%index%=2 END else SOMETHING
                    >
                    > THEN you can execute the variable content with
                    >
                    > ^!^%var%
                    >
                    >
                    > WEASEL Clause: this has always worked for me, but there may be
                    > some exception that escapes me. I would test any such command
                    > with debug on, so I could see if the variable is being parsed
                    > correctly.

                    I had problems doing that with an older versions, where there were functions in use as command parameters for the variable command. Even reported it at the time. But it does seem to be working now in a few simple tests. Maybe something has changed :D

                    Regards,
                    Sheri
                  • ebbtidalflats
                    As far as I know, this is only documented indirectly (by inference): Clip Script Help -- Executing Programs -- ^!CommandLine ... unless it represents a Clip
                    Message 9 of 10 , Apr 27, 2010
                      As far as I know, this is only documented indirectly (by inference):

                      Clip Script Help --> Executing Programs --> ^!CommandLine
                      "... unless it represents a Clip command ..."


                      Eb


                      --- In ntb-clips@yahoogroups.com, loro <tabbie@...> wrote:
                      >
                      > ebbtidalflats wrote:
                      > >^!Set %var%=If ^%index%=2 END else SOMETHING
                      > >
                      > >THEN you can execute the variable content with
                      > >
                      > >^!^%var%
                      >
                      > I always forget about that. I have feeling it's documented somewhere,
                      > but I don't find it. Do you know where?
                      >
                      > Lotta
                      >
                    • ebbtidalflats
                      Sheri, Using variable containing function names does NOT work - directly. A workaround exists, undocumented, where you assign the function name to a variable,
                      Message 10 of 10 , Apr 27, 2010
                        Sheri,

                        Using variable containing function names does NOT work - directly.
                        A workaround exists, undocumented, where you assign the function name to a variable, and pass it to a translator function.
                        I would not rely on the workaround too much, as future versions of NoteTab may break it.

                        Here is a SIMPLE example (2 clips):

                        H="_UDF_Translator"
                        ;UDF = User-defined function
                        ^!Result ^$^&$

                        H="DynamicFunctionNameCall"
                        ;assign an (unknown-at-design-time function) to a variable
                        ^!Set %var%=GetRow
                        ;evaluate the unknown function (GetRow in this example)
                        ^!Set %out%=^$UDF_Translator(GetRow)$
                        ^!Info ^%out%


                        This technique can of course be combined with the commandline variable technique. Now if NoteTab would only support _recursive_ clip calls <g>! Oh, and a Get and Set function for each and every configuration option NoteTab offers. Hey Eric ...


                        Cheers,


                        Eb


                        --- In ntb-clips@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
                        >
                        > --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@> wrote:
                        > > ...
                        >
                        > I had problems doing that with an older versions, where there were functions in use as command parameters for the variable command. Even reported it at the time. But it does seem to be working now in a few simple tests. Maybe something has changed :D
                        >
                        > Regards,
                        > Sheri
                        >
                      Your message has been successfully submitted and would be delivered to recipients shortly.