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

RE: [Clip] Array Question

Expand Messages
  • Andy Young
    Hi, Wayne, Thanks, your answer about arrays was exactly what I needed! Andy ... From: Wayne VanWeerthuizen [mailto:wayne@myhome.net] Sent: Monday, February 26,
    Message 1 of 10 , Feb 27, 2001
    View Source
    • 0 Attachment
      Hi, Wayne,
      Thanks, your answer about arrays was exactly what I needed!
      Andy

      -----Original Message-----
      From: Wayne VanWeerthuizen [mailto:wayne@...]
      Sent: Monday, February 26, 2001 11:13 PM
      To: ntb-clips@yahoogroups.com
      Subject: Re: [Clip] Array Question


      On Mon, 26 Feb 2001 21:32:22 -0600, "Andy Young"
      <ajyoung@...> wrote:

      >Hi, All,
      >Let's suppose you have an array which hold over 50 data items (each
      >data item would be no more than three text strings separated by a
      >space). Would it be better to load that array from a file or just
      >define it in the clip. I'm concerned about memory load. The array
      >data will not change but the clip will refer to or use the
      >information in the array as it loops. If it is better to use a
      file,
      >How is an easy way to define or to get the information?
      >Andy

      It really depends on how you use the data, and how much data you
      have.

      With only 50 items, each less than 100 characters, we are talking
      about less than 5 kilobytes, an insignificant amount of memory these
      days. Of course, NoteTab probably requires some additional
      memory overhead for each array item, but the total memory
      usage should be close to (within a couple doublings) the above
      estimate.

      When you have tens of thousands of items, or very large
      individual items, then memory is more significant. And to my
      knowledge, NoteTab allows a large amount of data to be stored in
      a variable - I suspect its at least as big as NoteTab's paragraph
      size limit, but I've not tested it.

      The real question is how the data is used. Will it be read
      sequentially each item in turn, and each item only being read
      once? Then use a file, load it into a document, and read it
      line by line. This is also the better approach when the number
      of items is very large, such as in the tens of thousands.
      (In fact for files with millions of lines, loading it into
      a document may not be possible. Then I suggest using a Perl
      script to read the data line by line as needed. NoteTab
      lacks a ^$GetFileNextLine$ function to read the next line
      from a file without loading the whole file into memory; nor
      is NoteTab fast enough to read such a large file efficiently.)

      Arrays are best when you must have random access to the data,
      reading items out of order, or reading items more than once.
      Arrays (at least in NoteTab) do work better when the number
      of items is low, as in fewer than a couple thousand. (There
      are pro's and con's to any approach.)

      The clip below shows how to use a _separate_ NoteTab clip
      to store the data, and read the data from the main clip.
      There are other shortcuts that could be taken. I
      intentionally did not use the shortest approach, but one
      that demonstrates more of the available clip functions.

      Note: by substituting the following for the similar
      line in the clip below, each data item can be multiple
      lines, with items separated by a blank line.

      ^!Set %Temp%="^$StrReplace("^P^P";"|";"^%Temp%";False;False)$"





      H="Data"
      January Alpha
      February Beta
      March Gamma
      April Delta
      May Epsilon
      June Zeta
      July Eta
      August Theta
      September Iota
      October Kappa
      November Lambda
      December Mu


      H="Demo Data Reading Clip"

      ; Reads data into a temporary variable, each data item on its
      ; own line. Then makes sure the list delimiter is set
      ; correctly, and puts the data into an array.
      ; The temporay variable can be avoided by combining these
      ; into one long line, but I try to avoid using long lines
      ; in clips sent to the list.
      ^!Set %Temp%="^$GetClipText("Data")$"
      ^!Set %Temp%="^$StrReplace("^P";"|";"^%Temp%";False;False)$"

      ; Make sure list delimiter is set to what we want the array to
      ; use. Also, it must match the 2nd parameter in StrReplace above.
      ^!SetListDelimiter |

      ; Build the actual array
      ^!SetArray %Array%="^%Temp%"

      ; Clear temporary variable to preserve resources.
      ^!ClearVariable %Temp%

      ; Just for show, loop through and display each array item.
      ^!Set %Index%=0
      :LoopStart
      ^!Inc %Index%
      ^!If ^%Index% > ^%Array0% LoopEnd
      ^!StatusShow ^%Array^%Index%%
      ^!Delay 5
      ^!Goto LoopStart
      :LoopEnd
      ^!StatusClose
      ^!ClearVariable ^%Array%



      By the way... regarding concerns about memory load

      RAM prices are failing again. www.crucial.com has
      256MB PC133 CAS2 SDRAM for $90 with free shipping in the USA.
      Or 128MB PC133 CAS2 SDRAM for $50, also with free shipping.
      I have a 256MB stick in my system. Great value. Generic
      memory is even cheaper, but I question the reliability.
      Crucial memory is high quality, and I believe, worth it.

      I am not associated with Crucial in any way. I'm just
      a happy customer.

      --
      Wayne M. VanWeerthuizen
      Homepage: http://landru.myhome.net/wayne



      Your use of Yahoo! Groups is subject to
      http://docs.yahoo.com/info/terms/
    • Jody
      Hi Wayne and Andy, Thanks for the information Wayne! ... Perl would be quicker and better on large files if one has Perl and they know the code, but NoteTab is
      Message 2 of 10 , Feb 27, 2001
      View Source
      • 0 Attachment
        Hi Wayne and Andy,

        Thanks for the information Wayne!

        >Then I suggest using a Perl script to read the data line by
        >line as needed. NoteTab lacks a ^$GetFileNextLine$ function to
        >read the next line from a file without loading the whole file
        >into memory; nor is NoteTab fast enough to read such a large
        >file efficiently.

        Perl would be quicker and better on large files if one has Perl
        and they know the code, but NoteTab is faster on smaller files.
        There is not a single function to get a line from a closed file,
        but it is not impossible with NoteTab:

        H=Line by Line
        ; jody 02-27-2001
        ^!SetListDelimiter ^p
        ^!SetArray %Line%=^$GetFileText(^$GetAppPath$ReadMe.txt)$
        ^!Set %Index%=0
        ^!Set %Count%=^%Line0%
        ^!Inc %Index%
        ; long line
        ^!SetWizardTitle ~^$StrFill(" ";66)$ http://www.notetab.net ^$StrFill(" ";66)$~
        ^!Info [L]Line ^%Index%: ^%Line^%Index%%^p^pCtrl+Alt and OK to abort
        ^!If ^%Index% > ^%Count% End else Skip_-3

        Happy Clip'n!
        Jody

        http://www.notetab.net

        Subscribe, UnSubscribe, Options
        mailto:Ntb-Clips-Subscribe@yahoogroups.com
        mailto:Ntb-Clips-UnSubscribe@yahoogroups.com
        http://www.egroups.com/group/ntb-clips
      • Wayne VanWeerthuizen
        On Tue, 27 Feb 2001 11:19:40 -0600, ... Your clip won t work unless the entire file fits into memory, because GetFileText gets the entire file at once. The
        Message 3 of 10 , Feb 27, 2001
        View Source
        • 0 Attachment
          On Tue, 27 Feb 2001 11:19:40 -0600,
          Jody <av1611@...> wrote:

          >Perl would be quicker and better on large files if one has Perl
          >and they know the code, but NoteTab is faster on smaller files.
          >There is not a single function to get a line from a closed file,
          >but it is not impossible with NoteTab:

          > ^!SetArray %Line%=^$GetFileText(^$GetAppPath$ReadMe.txt)$

          Your clip won't work unless the entire file fits into memory,
          because GetFileText gets the entire file at once. The point
          of reading line by line is to avoid this.


          --
          Wayne M. VanWeerthuizen
          Homepage: http://landru.myhome.net/wayne
        • Jody
          Hi Wayne and Eric, ... Correct, but it is still very fast with smaller files. One does not notice any delay or memory problems with ReadMe.txt. ;) I do
          Message 4 of 10 , Feb 28, 2001
          View Source
          • 0 Attachment
            Hi Wayne and Eric,

            >> Perl would be quicker and better on large files if one has Perl
            >> and they know the code, but NoteTab is faster on smaller files.
            >> There is not a single function to get a line from a closed
            >> file, but it is not impossible with NoteTab:
            >
            >> ^!SetArray %Line%=^$GetFileText(^$GetAppPath$ReadMe.txt)$
            >
            >Your clip won't work unless the entire file fits into memory,
            >because GetFileText gets the entire file at once. The point of
            >reading line by line is to avoid this.

            Correct, but it is still very fast with smaller files. One does
            not notice any delay or memory problems with ReadMe.txt. ;) I do
            understand your point which was well made in your original post.
            I'm sure you understood mine as well that we could retrieve a
            single line from a file without actually opening it in NoteTab.
            Perhaps we will get a read line by line function in version five.

            Happy Clip'n!
            Jody

            http://www.notetab.net

            Subscribe, UnSubscribe, Options
            mailto:Ntb-Clips-Subscribe@yahoogroups.com
            mailto:Ntb-Clips-UnSubscribe@yahoogroups.com
            http://www.egroups.com/group/ntb-clips
          • Ray Shapp
            Jody Your help in creating a glossary with table of contents from a large outline file worked extremely well. Thank you! I played with the two short clips you
            Message 5 of 10 , Mar 1, 2001
            View Source
            • 0 Attachment
              Jody

              Your help in creating a glossary with table of contents from a large outline
              file worked extremely well. Thank you!

              I played with the two short clips you wrote for me then I followed your
              suggestion about doing the whole thing using Regular Expression within the
              Replace function and that worked too. Am I content? Of course not.

              This worked so well, I want to make on-going updates to this online
              glossary. For example, I already have about 60 new entries and I'm sure
              club members will be suggesting more additions every few days. This could
              be a simple process (just add to the original outline, use the outline sort
              feature, then regenerate the web page).

              The task is complicated by the fact that I added hyperlinks and bookmarks so
              users can easily hop among related entries. I also added 26 hyperlinks for
              the letters of the alphabet, and the 26 matching bookmarks within the
              glossary. I have some paragraphs of text at top and bottom of the glossary
              and a few hyperlinks at the bottom that take the user out of the glossary
              and into other parts of the website.

              Can you suggest an efficient way to convert the web page back into an NT
              outline that I can update and use to re-generate the web page while
              maintaining all the embellishments I've made to the existing web page?

              In this same context, I'm wondering whether I can combine the Template and
              Outline features to produce the glossary as an HTML page with all
              embellishments intact. When I played around with this idea, Mailbag grabbed
              any .tpl file I tried to create. Under My Computer | View | Folder Options
              on the File Types tab, TPL files are associated with both NOTEPRO and
              Mailbag, but mailbag gets to them first! Is that because "Mailbag Template"
              comes alphabetically before "TPL Files"?

              I'm not asking for a solution (yet). I sure could use some direction,
              though.

              Thanks again,

              Ray Shapp
              Watchung, NJ
            • Jody
              Hi Ray, ... If your hyperlinks are standard simple ones, such as [Link] going to headings, then my Outline Library will handle that. I do not know of an easy
              Message 6 of 10 , Mar 1, 2001
              View Source
              • 0 Attachment
                Hi Ray,

                >Can you suggest an efficient way to convert the web page back
                >into an NT outline that I can update and use to re-generate the
                >web page while maintaining all the embellishments I've made to
                >the existing web page?

                If your hyperlinks are standard simple ones, such as [Link] going
                to headings, then my Outline Library will handle that. I do not
                know of an easy way to convert an HTML file to Outline off the
                top of my head other than to strip the HTML preserving the URLs
                and then do some sort of Clip to convert the HTML links to
                Outline. I don't think it will be an easy task though depending
                on the size of the Outline. The script may not be that hard to
                write, but each heading would need a prompt to see if it is
                indeed a heading, that is if you stripped HTML first. I don't
                have the time for it now, sorry.

                I tried at one time to make my Outline to Pages and
                Outline to Frames Clips do complicated [Links] like line numbers,
                documents, etc. and it just got to be a mess, so I aborted. I'm
                sure it could be done, but there are so many different
                possibilities, that I do not want the headache myself. ;)
                Perhaps that is why Eric has never added it to the regular
                Document to HTML. <g> I'm most sure he could do it though;
                perhaps v5. ;)

                >Under My Computer | View | Folder Options on the File Types tab,
                >TPL files are associated with both NOTEPRO and Mailbag, but
                >mailbag gets to them first! Is that because "Mailbag Template"
                >comes alphabetically before "TPL Files"?

                Yes, that would be my guess. I'm surprised it did both of them.
                You will need to rename the extensions in one of the programs and
                associate that extension with whichever one you changed it under.

                Happy Clip'n!
                Jody

                http://www.notetab.net

                Subscribe, UnSubscribe, Options
                mailto:Ntb-Clips-Subscribe@yahoogroups.com
                mailto:Ntb-Clips-UnSubscribe@yahoogroups.com
                http://www.egroups.com/group/ntb-clips
              Your message has been successfully submitted and would be delivered to recipients shortly.