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

Re: [Clip] Writing Subroutines in Notetab.

Expand Messages
  • 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 1 of 12 , Mar 8, 2006
      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
      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.