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

[Clip] Writing Subroutines in Notetab.

Expand Messages
  • Charles M. Raine
    Hi All: It was suggested in a recent post, that writing subroutines in Notetab was awkward and difficult, which it is NOT! Below is a routine I wrote to create
    Message 1 of 12 , Dec 26, 2005
    • 0 Attachment
      Hi All:

      It was suggested in a recent post, that writing subroutines in Notetab was
      awkward and difficult, which it is NOT! Below is a routine I wrote to
      create passwords of various types and lengths, which can be called by one
      instruction: ^!Clip "Create Password"
      The following instruction displays the password and format
      created: ^!Info ^%Password%^p^%format%

      The subroutine name contains an added underscore as the first character.
      This causes the Subroutine Name to be greyed out in the clip library and
      can only be executed by a clip call, (as above).

      H="_Create Password"
      ; Long line.
      ^!Set %lng%=^?{How long should the password be?=10}; %chr%=^?{(T=A,H=8)What
      type of characters can it have? (Select ONLY 1)=Alphanumerical (mixed
      case)^=A..Za..z0..9|Alphanumerical (uppercase)^=A..Z0..9|Alphanumerical
      (lowercase)^=a..z0..9|Alphabetical (mixed case)^=A..Za..z|Alphabetical
      (uppercase)^=A..Z|Alphabetical
      (lowercase)^=a..z|Hexadecimal^=A..F0..9|Numerical^=0..9}
      ; End long line.
      ^!Set %Password%=^$StrRandom(^%lng%;^%chr%)$
      ; Determine Format Information.
      ^!Set %format%=^%EMPTY%
      ^!Set %format%=^%format%^%lng%/
      ; Long line.
      ^!If "^%chr%" = "A..Za..z0..9" ^!Set %format%=^%format%Alphanumerical
      (mixed case)
      ; End long line.
      ; Long line.
      ^!If "^%chr%" = "A..Z0..9" ^!Set %format%=^%format%Alphanumerical
      (uppercase)
      ; End long line.
      ; Long line.
      ^!If "^%chr%" = "a..z0..9" ^!Set %format%=^%format%Alphanumerical
      (lowercase)
      ; End long line.
      ; Long line.
      ^!If "^%chr%" = "A..Za..z" ^!Set %format%=^%format%Alphabetical (mixed
      case)
      ; End long line.
      ^!If "^%chr%" = "A..Z" ^!Set %format%=^%format%Alphabetical (uppercase)
      ^!If "^%chr%" = "a..z" ^!Set %format%=^%format%Alphabetical (lowercase)
      ^!If "^%chr%" = "A..F0..9" ^!Set %format%=^%format%Hexadecimal
      ^!If "^%chr%" = "0..9" ^!Set %format%=^%format%Numerical
      ; Return to calling Clip.

      Enjoy!
      Charles M. Raine,
      Winnipeg. MB R3P 0W3
    • Don - htmlfixit.com
      ... Thanks for the thoughts. I started what may be a bad rumor :-) I guess that external subroutines (as the example you give shows) may be easier than what
      Message 2 of 12 , Dec 26, 2005
      • 0 Attachment
        Charles M. Raine wrote:
        > Hi All:
        >
        > It was suggested in a recent post, that writing subroutines in Notetab was
        > awkward and difficult, which it is NOT!

        Thanks for the thoughts. I started what may be a "bad" rumor :-)

        I guess that external subroutines (as the example you give shows) may be
        easier than what I think. I was talking about internal subroutines ...
        in most stuctured programming languages, you can do subroutines, pass
        variables, execute the subroutine and return including variables. Often
        you can work on variables in the subroutine without affecting the main
        variable values or with affecting the main variables, depending on how
        you do it. I have never tried to pass back and forth to subroutines as
        I found it more difficult than what I am used to.

        Questions:
        1. so long as you are in the same library, you can use any variables
        from the main clip running in any other subroutine clip?
        2. if you set a variable in the subroutine, is it changed in / available
        in the main clip when you return?
        3. return happens automatically when the subroutine clip finishes running?

        Thank Charles.

        Don
      • rpdooling
        Charles, Love the clip, but I m with Don I took subroutines to mean: for, while, for each, sub etc. Not one clip calling another. We shall have to see how/if
        Message 3 of 12 , Dec 26, 2005
        • 0 Attachment
          Charles,

          Love the clip, but I'm with Don I took subroutines to mean: for,
          while, for each, sub etc. Not one clip calling another.

          We shall have to see how/if Clip Programming changes in 5.0. I love
          programming clips, but I'd rather see advances made in the editing
          bells and whistles (syntax highlighting for programming language etc
          and maybe multi-level outlines) rather than in clip programming advances.

          If I want a real subroutine, I just use Perl or Python. I bet Ruby is
          even doable, though haven't tried it.

          Thanks again for the clip.

          rpd

          --- In ntb-clips@yahoogroups.com, "Charles M. Raine" <rainec@m...> wrote:
          >
          > Hi All:
          >
          > It was suggested in a recent post, that writing subroutines in
          Notetab was
          > awkward and difficult, which it is NOT! Below is a routine I wrote to
          > create passwords of various types and lengths, which can be called
          by one
          > instruction: ^!Clip "Create Password"
          > The following instruction displays the password and format
          > created: ^!Info ^%Password%^p^%format%
          >
          > The subroutine name contains an added underscore as the first
          character.
          > This causes the Subroutine Name to be greyed out in the clip library
          and
          > can only be executed by a clip call, (as above).
          >
          > H="_Create Password"
          > ; Long line.
          > ^!Set %lng%=^?{How long should the password be?=10};
          %chr%=^?{(T=A,H=8)What
          > type of characters can it have? (Select ONLY 1)=Alphanumerical (mixed
          > case)^=A..Za..z0..9|Alphanumerical (uppercase)^=A..Z0..9|Alphanumerical
          > (lowercase)^=a..z0..9|Alphabetical (mixed case)^=A..Za..z|Alphabetical
          > (uppercase)^=A..Z|Alphabetical
          > (lowercase)^=a..z|Hexadecimal^=A..F0..9|Numerical^=0..9}
          > ; End long line.
          > ^!Set %Password%=^$StrRandom(^%lng%;^%chr%)$
          > ; Determine Format Information.
          > ^!Set %format%=^%EMPTY%
          > ^!Set %format%=^%format%^%lng%/
          > ; Long line.
          > ^!If "^%chr%" = "A..Za..z0..9" ^!Set %format%=^%format%Alphanumerical
          > (mixed case)
          > ; End long line.
          > ; Long line.
          > ^!If "^%chr%" = "A..Z0..9" ^!Set %format%=^%format%Alphanumerical
          > (uppercase)
          > ; End long line.
          > ; Long line.
          > ^!If "^%chr%" = "a..z0..9" ^!Set %format%=^%format%Alphanumerical
          > (lowercase)
          > ; End long line.
          > ; Long line.
          > ^!If "^%chr%" = "A..Za..z" ^!Set %format%=^%format%Alphabetical (mixed
          > case)
          > ; End long line.
          > ^!If "^%chr%" = "A..Z" ^!Set %format%=^%format%Alphabetical (uppercase)
          > ^!If "^%chr%" = "a..z" ^!Set %format%=^%format%Alphabetical (lowercase)
          > ^!If "^%chr%" = "A..F0..9" ^!Set %format%=^%format%Hexadecimal
          > ^!If "^%chr%" = "0..9" ^!Set %format%=^%format%Numerical
          > ; Return to calling Clip.
          >
          > Enjoy!
          > Charles M. Raine,
          > Winnipeg. MB R3P 0W3
          >
        • Charles M. Raine
          Hi Don: ... YES that is correct. ... YES that is correct. ... YES that is correct. Charlie Charles M. Raine, Winnipeg. MB R3P 0W3
          Message 4 of 12 , Dec 27, 2005
          • 0 Attachment
            Hi Don:

            On Mon, 26 Dec 2005 19:31:36 -0500, Don - htmlfixit.com wrote:
            > Questions:
            > 1. so long as you are in the same library, you can use any variables
            > from the main clip running in any other subroutine clip?

            YES that is correct.

            > 2. if you set a variable in the subroutine, is it changed in / available
            > in the main clip when you return?

            YES that is correct.

            > 3. return happens automatically when the subroutine clip finishes
            > running?

            YES that is correct.

            Charlie
            Charles M. Raine,
            Winnipeg. MB R3P 0W3
          • Don - htmlfixit.com
            Interesting... I guess when I said subroutine, as RP said, I was using it in a different way, but I need to examine some things and see if I can use such
            Message 5 of 12 , Dec 27, 2005
            • 0 Attachment
              Interesting... I guess when I said subroutine, as RP said, I was using
              it in a different way, but I need to examine some things and see if I
              can use such things more efficiently. I have numerous clips for example
              that find matching html tags for this reason or another, but I could
              save adding that to each subclip if I just made find matching html tag a
              "sub-routine" clip.

              Hmmmm....
              Thanks for pushing me here ... this might be a good thing. I guess
              instead of saying subroutines are difficult perhaps I should have said
              different than I am used to.

              Don
              > YES that is correct.
              >
              > Charlie
            • Charles M. Raine
              Hi rpd: By the way, that clip is a small extraction from a application I wrote to keep a record of all my passwords and program registration codes for all my
              Message 6 of 12 , Dec 27, 2005
              • 0 Attachment
                Hi rpd:

                By the way, that clip is a small extraction from a application I wrote to
                keep a record of all my passwords and program registration codes for all my
                applications in ONE place in a Notetab Outline File. This program also
                contains a file encryption procedure, backup and restore procedure to any
                external media. All this is done using Notetab in a series of subroutines.

                If anyone has a serious interest in this application, I can be persuaded to
                post it on my web site at:
                http://www.mts.net/~rainec/notetab.html


                Charlie
                Charles M. Raine,
                Winnipeg. MB R3P 0W3

                On Tue, 27 Dec 2005 07:10:07 -0000, rpdooling wrote:
                > Love the clip, but I'm with Don I took subroutines to mean: for, while,
                > for each, sub etc. Not one clip calling another.
                >
                > We shall have to see how/if Clip Programming changes in 5.0. I love
                > programming clips, but I'd rather see advances made in the editing bells
                > and whistles (syntax highlighting for programming language etc and maybe
                > multi-level outlines) rather than in clip programming advances.
                >
                > If I want a real subroutine, I just use Perl or Python. I bet Ruby is
                > even doable, though haven't tried it.
              • John Wallace
                I would be interested in it. Great site. John Wallace Pontiac Power RULES !!! www.wallaceracing.com Subject: Re: [Clip] Writing Subroutines in Notetab. Hi rpd:
                Message 7 of 12 , Dec 27, 2005
                • 0 Attachment
                  I would be interested in it.
                  Great site.

                  John Wallace
                  Pontiac Power RULES !!!
                  www.wallaceracing.com

                  Subject: Re: [Clip] Writing Subroutines in Notetab.

                  Hi rpd:

                  By the way, that clip is a small extraction from a application I wrote to keep a record of all my passwords and program registration
                  codes for all my applications in ONE place in a Notetab Outline File. This program also contains a file encryption procedure, backup
                  and restore procedure to any external media. All this is done using Notetab in a series of subroutines.

                  If anyone has a serious interest in this application, I can be persuaded to post it on my web site at:
                  http://www.mts.net/~rainec/notetab.html


                  Charlie
                  Charles M. Raine,
                  Winnipeg. MB R3P 0W3
                • thefrank
                  Hello Don, Charles, et.al. I believe the ^!Farclip function handles the job of internal subroutines. I use it, thanks to a suggestion from Jody years ago. It
                  Message 8 of 12 , Dec 27, 2005
                  • 0 Attachment
                    Hello Don, Charles, et.al.

                    I believe the ^!Farclip function handles the job of internal
                    subroutines. I use it, thanks to a suggestion from Jody years ago.

                    It seems to me that the trick is to distill the internal subroutine
                    clip into one reuseable modular function that contains common
                    variables. Then knit these together menu-style for what you need.

                    I have found that naming the Farclip variables should follow a
                    convention and be reserved from other clip use to avoid hiccups. It
                    may be handy to make a short clip library of these. You may prefer an
                    Outline file instead. It just helps keep track and thus makes your
                    clip code more consistent.

                    I have found it helpful sometimes to insert a short ^!Delay between
                    Farclip executions, especially on my old AMD:K62:350 machine. My
                    newer platforms run without ^!Delays just fine.

                    If you have not tried using ^!Farclip yet, its easy: Take apart one
                    of your clips and save it as three sections. Name each something like
                    Test1 Test2 and Test3. Now make a clip like this:

                    ^!FarClip ClipLibraryName:Test1
                    ^!Delay 30
                    ^!FarClip ClipLibraryName:Test2
                    ^!Delay 30
                    ^!FarClip ClipLibraryName:Test3

                    Name it something like TestFarclip. Save, Close, and click on it to
                    watch it run! Now you can easily build the modular reuseable internal
                    subroutines you want. Big time saver in the long run.

                    [page 2]

                    Yes I still get requests for the ColorPalate clip. Available here:

                    http://www.thefrank.com/ntp

                    This was an exercise to demonstrate creative uses for the Clipbar. It
                    does work thought, and quite well I might add. Feel free to modify
                    any of my clipcode for your own projects.

                    Happy New year to all, and Thank You all for your continued help and
                    welcome participation. New Years Resolution: Poke Eric once a day
                    with the *V5* stick... ;)

                    Warm Regards

                    tf

                    http://www.thefrank.com
                  • acummingsus
                    Hi, http://www.google.com/search?hs=r6m&hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=site%3Anotetab.com+pad+xml&btnG=Search
                    Message 9 of 12 , Dec 27, 2005
                    • 0 Attachment
                      Hi,

                      http://www.google.com/search?hs=r6m&hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=site%3Anotetab.com+pad+xml&btnG=Search

                      http://www.notetab.com/pad/index.htm

                      http://www.notetab.com/pad/pad_file.xml

                      the last url is to a pad file (xml).

                      The first urls are to a pad clip library written by Fookes Software (I
                      think).

                      That library somehow involves with xml.

                      And, uses extensively child (sub routine given if we may call it that)
                      clips (called clips using: ^!Clip).

                      I found such style as that (though not that large of a scale) help me
                      make parts at a time and then integrate all of the parts into a whole.

                      But I kept extensively getting lost when I looked too long at that pad
                      library clips. I wondered "how does Eric (or whoever wrote that) keep
                      track or chart/map_out" all of that?

                      Any program, once gets bigger, how to chart it (know what each portion
                      does and how such portion contributes to the whole). I guess document
                      it, for one.

                      But I'm so so visual. I need to be able to see the whole and the
                      pieces and how they all fit together. Probably I could draw a map as
                      visual representation labeling map with segment numbers then put
                      corresponding segment number in relevant piece/section of program code.

                      I've been busy with Perl and Linux lately. Perl is structured: one
                      way in and one way out.

                      Hi clippers!

                      Bye. Alan C.
                    • dave
                      Hi don t you think the links on the left side of your page are a bit dark ? THANKYOU DAVE M happy holidays hot in au ... From: thefrank
                      Message 10 of 12 , Dec 27, 2005
                      • 0 Attachment
                        Hi
                        don't you think the links on the left side of your page are a bit dark ?
                        THANKYOU DAVE M
                        happy holidays hot in au
                        ----- Original Message -----
                        From: "thefrank" <tf@...>
                        To: <ntb-clips@yahoogroups.com>
                        Sent: Wednesday, December 28, 2005 7:04 AM
                        Subject: Re: [Clip] Writing Subroutines in Notetab.


                        > Hello Don, Charles, et.al.
                        >
                        > I believe the ^!Farclip function handles the job of internal
                        > subroutines. I use it, thanks to a suggestion from Jody years ago.
                        >
                        > It seems to me that the trick is to distill the internal subroutine
                        > clip into one reuseable modular function that contains common
                        > variables. Then knit these together menu-style for what you need.
                        >
                        > I have found that naming the Farclip variables should follow a
                        > convention and be reserved from other clip use to avoid hiccups. It
                        > may be handy to make a short clip library of these. You may prefer an
                        > Outline file instead. It just helps keep track and thus makes your
                        > clip code more consistent.
                        >
                        > I have found it helpful sometimes to insert a short ^!Delay between
                        > Farclip executions, especially on my old AMD:K62:350 machine. My
                        > newer platforms run without ^!Delays just fine.
                        >
                        > If you have not tried using ^!Farclip yet, its easy: Take apart one
                        > of your clips and save it as three sections. Name each something like
                        > Test1 Test2 and Test3. Now make a clip like this:
                        >
                        > ^!FarClip ClipLibraryName:Test1
                        > ^!Delay 30
                        > ^!FarClip ClipLibraryName:Test2
                        > ^!Delay 30
                        > ^!FarClip ClipLibraryName:Test3
                        >
                        > Name it something like TestFarclip. Save, Close, and click on it to
                        > watch it run! Now you can easily build the modular reuseable internal
                        > subroutines you want. Big time saver in the long run.
                        >
                        > [page 2]
                        >
                        > Yes I still get requests for the ColorPalate clip. Available here:
                        >
                        > http://www.thefrank.com/ntp
                        >
                        > This was an exercise to demonstrate creative uses for the Clipbar. It
                        > does work thought, and quite well I might add. Feel free to modify
                        > any of my clipcode for your own projects.
                        >
                        > Happy New year to all, and Thank You all for your continued help and
                        > welcome participation. New Years Resolution: Poke Eric once a day
                        > with the *V5* stick... ;)
                        >
                        > Warm Regards
                        >
                        > tf
                        >
                        > http://www.thefrank.com
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        > Fookes Software: http://www.fookes.us, http://www.fookes.com
                        > Fookes Software Mailing Lists: http://www.fookes.us/maillist.htm
                        >
                        > Yahoo! Groups Links
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                      • thefrank
                        Hi Dave, ... Just hit your browser *refresh* until you see one you like. tf
                        Message 11 of 12 , Dec 28, 2005
                        • 0 Attachment
                          Hi Dave,

                          >> don't you think...?

                          Just hit your browser *refresh* until you see one you like.

                          tf
                        • Don - htmlfixit.com
                          ... Dear Charles, This is a thread from a while back. I wanted to thank you again for the advice. I recently had occaision to write a clip for a client who
                          Message 12 of 12 , Mar 8, 2006
                          • 0 Attachment
                            Charles M. Raine wrote:
                            > Hi All:
                            >
                            > It was suggested in a recent post, that writing subroutines in Notetab was
                            > awkward and difficult, which it is NOT! Below is a routine I wrote to
                            > create passwords of various types and lengths, which can be called by one
                            > instruction: ^!Clip "Create Password"
                            > The following instruction displays the password and format
                            > created: ^!Info ^%Password%^p^%format%
                            Dear Charles,

                            This is a thread from a while back. I wanted to thank you again for the
                            advice. I recently had occaision to write a clip for a client who
                            desired a custom clip. I decided to give subroutines a try because the
                            functions in this particular clip were essentially modular and could be
                            broken down into four or five main parts, and one routine/function had
                            to be called at a half dozen different points in the clip. In days of
                            yore, I would have simply included the snippet in all of those places,
                            and if I later found a typo or wanted to change it, I would have had to
                            make that change each place it occured.

                            I still maintain that I cannot truly write a subroutine in notetab in
                            the truest of senses. I say this because in a typical language, say
                            perl, you can call a subroutine, pass variables, return program flow
                            back to where you left. That subroutine CAN BE CONTAINED in the same
                            program file and you are returned on completion. Having said that, I
                            must now agree with you ... you can achieve a subroutine for all
                            practical purposes by using a second clip.

                            For those who come after me (including myself as I use these things to
                            keep myself refreshed as well):
                            1. the way to do it is in the clip from whence you are departing to the
                            "subroutine" you do the following:
                            a. set any variables necessary to pass information -- the subroutine
                            clip will have those variables set in the main program avaliable to
                            them. Maybe an example. If you want to have a subroutine look at a
                            number and truncate it (rounded or not) to an integer. The number you
                            are passing from the main program at various points my be a particular
                            variable, but not alway the same. For example the amount in the main
                            clip might be a total of one thing or another. If you use: ^!Set
                            %subroutineNumber%="^%mainclipNumber%"
                            each time and replace mainclipNumber with the name of the variable you
                            currently want to check, then the subroutine will always have a variable
                            called %subroutineNumber% to work with. Not as efficient as data
                            passing in other languages, but functional.
                            b. you need not set variables that are already available in the main
                            clip, but understand that if you do change them in the subroutine they
                            will be changed in the main clip when you come back to it.
                            2. never having done it before I was suprised that I got an audible beep
                            every time my subroutine clip was called. Later I figured out that was
                            because I had a typo in the call to the subroutine clip and so that was
                            the program telling me that the clip being called wasn't available.
                            Because all of my data was proper form before sending it to the clip, I
                            didn't realize it was never getting to the clip.
                            3. you can use any clip but I created my subroutine clips as greyed out
                            clips _clipname. I called the subroutine clip thus: ^!Clip "_clipname"
                            after setting the variable(s) that _clipname would need to work with.
                            4. when the subroutine clips ends, any data contained in it (variables
                            set in it might be a better way to say it) will be avialable to the main
                            clip and the main clip picks up where it left off before the subclip runs.

                            It worked especially well for me as the client later decided not to do
                            one of the functions ... so I just commented out the call to that
                            function in the main clip and the clip kept on chugging. Later if the
                            client decides hey I wanted that in s/he can just uncomment that line
                            and have the function back. In fact if I really wanted to get fancy I
                            bet I could run options like that via an ini file ... hmmm

                            Again Charles, thanks for the inspiration.
                          Your message has been successfully submitted and would be delivered to recipients shortly.