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

value 2 one way versus someone else's way was Re: [Clip] StrPos how to find end of the line

Expand Messages
  • Alan C.
    Hello, As far as clip/script writing goes, isn t it great that we each get to share our way or the particular way that each of us as an individual has pursued.
    Message 1 of 25 , Jan 23, 2003
    • 0 Attachment
      Hello,

      As far as clip/script writing goes, isn't it great that we each get to share our way or the particular way that each of us as an individual has pursued.

      I congratulate those who wrote clips to extract a specified sub string from within a larger string that had first been put into a variable representing from a disk file.

      I've been impressed with the mastery of the clip language that's been displayed on this list recently.

      I've learned some things. And I hope it's been a learning environment for all.

      But I remain curious about something.

      That is, (not to mention calc (#2) very likely is CPU intensive) I find the clip code simpler and perhaps less of it too when using #1 of the next two methods. #1 is just to open a doc in Ntab and use the find and replace command --- as opposed to the alternate of #2 extracting a diskfile's entire content into a variable and then extracting a specified criteria substring from that larger string.

      Seems to me that memory consumption would be same irregardless of whether opting for #1 or #2. To compare, an open file in Ntab is just a memory buffer. And an Ntab clip variable is just something stored in memory (until discarded just like as when doc or buffer is closed). Also, since graphical display/refreshing has a cost it consumes lots of memory, using ^!SetScreenUpdate OFF very likely keeps memory consumption at an economical level.

      Once again, not at all to discount; Instead, I congratulate those with sufficient mastery of the clip language to write #2. And we each get to do it our own way with NoteTab. So, *please* do have fun doing it your way.

      (not that my way is any better because it's not--I just don't see the value to #2, not yet). So, my point is that I personally will continue to use the #1 of these two methods:

      ; #1
      ^!SetScreenUpdate OFF
      using clip code, open the file and use find and/or replace to do my work and not save the changes unless I want them saved--close the file if need be and output to another place if needed to do so.
      ; ---end of clip---

      On the other hand, were someone to prove 1 of the 2 methods as faster and/or while accomplishing task its useage of 'puters resources is significantly enough more economical than the other method---well then, I'd be the first to jump on it.

      --
      Alan.
    • Sheri
      Hi Alan ... For whatever its worth, I agree with you. I prefer to work in Notetab file buffer hidden by ^!SetScreenupdate off. That s what I did in the Perl
      Message 2 of 25 , Jan 23, 2003
      • 0 Attachment
        Hi Alan

        >On the other hand, were someone to prove 1 of the 2 methods as faster and/or while accomplishing task its useage of 'puters resources is significantly enough more economical than the other method---well then, I'd be the first to jump on it.

        For whatever its worth, I agree with you. I prefer to work in Notetab file buffer hidden by ^!SetScreenupdate off. That's what I did in the Perl Regexp Replace clip and also in the clip syntax clips. The syntax clips involve a lot of retrieval from a temporary file buffer.

        I don't know Manuel's reason, but he specifically didn't want to open the document in a Notetab file buffer. Maybe just to see how to go about it.

        I have no evidence as to one method being substantially less resource intensive than the other, but there may be some small savings using ^$GetFileText$ especially for someone who keeps dozens of document tabs open in Notetab. In addition to the file content, Notetab has to keep up with the "tab" if the document is in a buffer.

        Regards,
        Sheri
      • hugo_paulissen <h.paulissen@facburfdcw.u
        Alan, Sheri, I only write clips and know not much of the processing of the code behind it. It could be that I m responsible for that piece of code Manuel uses
        Message 3 of 25 , Jan 24, 2003
        • 0 Attachment
          Alan, Sheri,

          I only write clips and know not much of the processing of the code
          behind it. It could be that I'm responsible for that piece of code
          Manuel uses now. And, it could well be that there are much more
          economical ways to achieve the same thing, but what I do know is that
          string-functions are very fast, so I presume they are less processor-
          demanding.

          Loading a text in a variable allows you to find certain strings in
          the variable itself without actually 1. opening the file, 2. setting
          ScreenUpdate Off, 3. locating certain strings in the file and 4.
          storing it in a variable afterwards. You have to 5. keep track of the
          file-tab as well in order to close it;-)

          I don't think there is a big difference for smaller files/projects,
          so the benefit of either method is probably marginal. The nice thing
          about NoteTab is that everyone can do certain things in his/her own
          way.

          I'm not sure if it has to do with your question, but on the Basic
          list Jody wrote recently:

          "NoteTab needs twice as much RAM as the total amount of documents
          it has open, plus it needs some for itself, a number of other
          things like large favorite groups takes up more RAM."

          Regards,

          Hugo

          > Hi Alan
          >
          > >On the other hand, were someone to prove 1 of the 2 methods as
          faster and/or while accomplishing task its useage of 'puters
          resources is significantly enough more economical than the other
          method---well then, I'd be the first to jump on it.
          >
          > For whatever its worth, I agree with you. I prefer to work in
          Notetab file buffer hidden by ^!SetScreenupdate off. That's what I
          did in the Perl Regexp Replace clip and also in the clip syntax
          clips. The syntax clips involve a lot of retrieval from a temporary
          file buffer.
          >
          > I don't know Manuel's reason, but he specifically didn't want to
          open the document in a Notetab file buffer. Maybe just to see how to
          go about it.
          >
          > I have no evidence as to one method being substantially less
          resource intensive than the other, but there may be some small
          savings using ^$GetFileText$ especially for someone who keeps dozens
          of document tabs open in Notetab. In addition to the file content,
          Notetab has to keep up with the "tab" if the document is in a buffer.
          >
          > Regards,
          > Sheri
        • Alan C.
          Hi Hugo, ... Perhaps it is that we each have our own unique approach as individuals typically do vary somewhat in how they do things which is fine. Or, perhaps
          Message 4 of 25 , Jan 24, 2003
          • 0 Attachment
            Hi Hugo,

            >Loading a text in a variable allows you to find certain strings in
            >the variable itself without actually 1. opening the file, 2. setting
            >ScreenUpdate Off, 3. locating certain strings in the file and 4.
            >storing it in a variable afterwards. You have to 5. keep track of the
            >file-tab as well in order to close it;-)

            :-) I like to see what others do with NoteTab. Sometimes I can learn things.

            Perhaps it is that we each have our own unique approach as individuals typically do vary somewhat in how they do things which is fine.

            Or, perhaps you're ultimately doing more complex things with the substring data that I'm unaware of and than what I am thinking of. Maybe this is the primary advantage of the 1 technique over the other.

            I am thinking of merely viewing in a doc a desired portion of a file's content then when I'm done I just close that doc, no need to put into variable or keep track of the doc tab.

            For what I am doing or have in mind as my task, the majority of it seem is semantics and/or mute to me. In reference to your 5 above: 1. open file or set entire file content into variable: either way amounts, boils down to something put into memory 2. one line of code 3. var method need locate desired substring; file open method need locate desired substring 4. var method stored into a variable before so what the difference between either before or afterward (and maybe I didn't want it in a var as per next, #5) 5. maybe I just wanted to view a portion of that file's content then close the doc and I've no need to keep track of its doc tab.

            --
            Alan.
          • Manuel123
            I ve a question. I have in d: bd 01 serveral files txt and otl with the name of the folder but with _ Example folder word file _word.txt or _word.otl The clip
            Message 5 of 25 , Feb 14, 2003
            • 0 Attachment
              I've a question. I have in d:\bd\01\ serveral files txt and otl with
              the name of the folder but with _

              Example folder word file _word.txt or _word.otl
              The clip tell me wicht file I want to open. If exist otl open else
              open _word.txt

              But my question, How do I to make automatic list of folder in D:\bd\01
              for information goto variable select

              At this moment I have to write a name of the folder that is new in the
              clip in the line of select element

              Thanks in adavanced.


              ^!ClearVariables

              ^!Set %carpeta%="D:\bd\01\"
              ^!
              ^!Set %select%=^?[(H=14)Selecciona GuiaOtl==Access|asp]

              ;^!continue ^%carpeta%^%select%_^%select%.otl
              ^!IfFileExist "^%carpeta%^%select%\_^%select%.otl" abreOtl ELSE
              abreTxt


              :abreOtl
              ^!OPEN ^%carpeta%^%Select%\_^%select%.otl
              ^!Goto End

              :abreTxt
              ^!OPEN ^%carpeta%^%Select%\_^%select%.txt


              :End

              ---
              Cursos para ciegos
              Windows,Iexplorer,Outlook,Html,Word,Excel,Access
              ALTAS/BAJAS avisarte cursos en http://www.solotxt.com
            • Alan C.
              Hi Manuel123, ... ^!ChDir d: files ^!Set %cmnd%=^?{(T=M)Enter Dos command=tree} ^!Toolbar New Document ^!InsertText ^$GetDosOutput( ^%cmnd% )$ That captures
              Message 6 of 25 , Feb 14, 2003
              • 0 Attachment
                Hi Manuel123,

                >But my question, How do I to make automatic list of folder in D:\bd\01
                >for information goto variable select
                >
                >At this moment I have to write a name of the folder that is new in the
                >clip in the line of select element

                ^!ChDir d:\files\
                ^!Set %cmnd%=^?{(T=M)Enter Dos command=tree}
                ^!Toolbar New Document
                ^!InsertText ^$GetDosOutput("^%cmnd%")$

                That captures list of folders.

                Caution: ^!ChDir to a folder that does NOT have too too many sub folders under it. Otherwise, well, it's likely that your entire hard drive will output a mile long folder list.

                Folder PATH listing
                Volume serial number is 0006FE80 1DD8:2A2A
                D:.
                ÃÄÄÄunixtut
                ÃÄÄÄntbdocs
                ÃÄÄÄHTML-Format-1.23
                ³ ÃÄÄÄt
                ³ ÀÄÄÄlib
                ³ ÀÄÄÄHTML


                But the dos tree command draws nice lines/branches in console window. Now, how to deal with how it prefaces each line of captured output

                Jody's dirstuff library has a clip to make array from a list.

                Just one idea.

                The clip language has a browse (so as to select a folder).(I know, not all of your folders)
                --
                Alan.
              • Jody
                Hi Alan C. & Manuel123, I don t know what you might want it for, but the Clip will put the folder names and the subs into one array. I like the second one
                Message 7 of 25 , Feb 14, 2003
                • 0 Attachment
                  Hi Alan C. & Manuel123,

                  I don't know what you might want it for, but the Clip will put the folder
                  names and the subs into one array. I like the second one better. <g>

                  >>But my question, How do I to make automatic list of folder in D:\bd\01
                  >>for information goto variable select

                  <--- Copy below this line --->
                  H=All Folder Names Array...
                  ; eMailed on 02-14-2003, Jody@...
                  ; Unshamefully stole and rearranged dos stuff from:
                  ; Alan C. <acumming@...> :)
                  ; notetab.net, notetab.net/html/cd-info.htm

                  ^!Set %Dir%=^?{(T=D)Enter path to parent folder=C:\Documents and Settings\}
                  ^!ChDir ^%Dir%
                  ^!Set %cmnd%=tree
                  ^!SetScreenUpdate Off
                  ^!Toolbar New Document
                  ^!InsertText ^$GetDosOutput("^%cmnd%")$
                  ^!Replace " ³" >> "" WAS
                  ^!Replace "³ " >> "" WAS
                  ^!Replace "ÃÄÄÄ" >> "" WASIT
                  ^!Replace "ÀÄÄÄ" >> "" WASIT
                  ^!Replace " " >> "" WASIT
                  ^!Replace " " >> "" WASIT
                  ^!DeleteLine
                  ^!DeleteLine
                  ^!DeleteLine
                  ^!SetListDelimiter ^p
                  ^!SetArray %FolderList%=^$GetText$
                  ^!Close Discard
                  ^!Set %Count%=^%FolderList0%
                  ^!Set %Index%=0

                  ^!Inc %Index%
                  ^!Info ^%FolderList^%Index%%>>>>Ctrl+Alt and press OK to abort.
                  ^!If ^%Index% = ^%Count% Skip
                  ^!Goto Skip_-3

                  <--- Copy above this line --->
                  <--- Right click over a Library --->
                  <--- Choose: Add from Clipboard --->

                  <--- Copy below this line --->
                  H=All Folder Names...
                  ; eMailed on 02-14-2003, Jody@...
                  ; notetab.net, notetab.net/html/cd-info.htm

                  ^!Set %Dir%=^?{(T=D)Enter path to parent folder=^$GetPath$}
                  ^!ChDir ^%Dir%
                  ^!Set %cmnd%=tree
                  ^!Toolbar New Document
                  ^!InsertText ^$GetDosOutput("^%cmnd%")$
                  ^!Replace " ³" >> " " WAS
                  ^!Replace "³ " >> " " WAS
                  ^!Replace "ÃÄÄÄ" >> "· " WASIT
                  ^!Replace "ÀÄÄÄ" >> "· " WASIT

                  <--- Copy above this line --->
                  <--- Right click over a Library --->
                  <--- Choose: Add from Clipboard --->

                  Happy Clip'n!
                  Jody

                  http://www.notetab.net

                  Subscribe, UnSubscribe, Options
                  mailto:Ntb-Clips-Subscribe@yahoogroups.com
                  mailto:Ntb-Clips-UnSubscribe@yahoogroups.com
                  http://groups.yahoo.com/group/ntb-clips
                • Alan C.
                  Hi Manuel123, Jody, ÃÄÄÄntbdocs ÃÄÄÄHTML-Format-1.23 ³ ÃÄÄÄt ³ ÀÄÄÄlib ³ ÀÄÄÄHTML Well those characters, whatever they are (I
                  Message 8 of 25 , Feb 14, 2003
                  • 0 Attachment
                    Hi Manuel123, Jody,

                    ÃÄÄÄntbdocs
                    ÃÄÄÄHTML-Format-1.23
                    ³ ÃÄÄÄt
                    ³ ÀÄÄÄlib
                    ³ ÀÄÄÄHTML

                    Well those characters, whatever they are (I don't know what they are-does someone know?), work with NoteTab. Interesting.

                    >>But my question, How do I to make automatic list of folder in D:\bd\01
                    >>for information goto variable select

                    It just donned on me that earlier, I had overlooked the possibility of using the dir command. So, just to mention it; that's all.

                    And, on mine, the dir command does also, in addition to files, it lists the folders but does not list any sub folders like tree does.

                    ^!Set %cmnd%=^?{(T=M)Enter Dos command=dir}

                    07/16/2002 12:05a <DIR> ntbdocs
                    07/16/2002 12:05a <DIR> HTML-Format-1.23
                    11/01/2002 06:43p <DIR> data
                    11/07/2002 10:34p 130 infile2.txt
                    11/08/2002 12:21a 181 test_pl.bak

                    So, be easy to find <DIR> then select after the <DIR> up to end of line and then trim any leading space(s) as well as dump/ditch the . and the .. directory

                    But my motto is if it works don't fix it. Just thought I'd mention the dir, that's all.

                    --
                    Alan.
                  • Manuel123
                    Well, thanks Alan and Jody I m studing the idea. I have several folders and a document with info to links to other txt in the same folder. I needed a menu that
                    Message 9 of 25 , Feb 15, 2003
                    • 0 Attachment
                      Well, thanks Alan and Jody I'm studing the idea. I have several
                      folders and a document with info to links to other txt in the same
                      folder. I needed a menu that i select Which folder I want to open.
                      Then open for me a document in the same folder with _ underscore and
                      the same name of the folder

                      Now, thanks for your ideas I get it!!!!!

                      Here it's my solution

                      MenuFolder_doc

                      ;Example. I have a folder d:\bd\01\ideas
                      ;I have a document in folder _ideas.txt
                      ;The clip show me a list of folder
                      ;and open the doc _ideas.txt in folder ideas

                      ^!Set %folder%="d:\bd\01\"

                      ^!ChDir ^%folder%
                      ; /B no muestra encabezados
                      ; /B no show heads only name of folder or documents
                      ^!Set %list1%=^$GetDosOutput(dir ^%folder% /B)$

                      ;Replace ^P with pipe |
                      ^!Set %list2%=^$StrReplace("^P";"|";"^%list1%";True;True)$

                      ;Show Dialog to select folder
                      ^!Set %select%=^?{(H=14)Selecciona GuiaOtl==^%List2%}

                      ;Open in the folder a document with
                      ;the same name of the folder with _before
                      ^!OPEN ^%folder%^%Select%\_^%select%.txt

                      ---
                      Cursos para ciegos
                      Windows,Iexplorer,Outlook,Html,Word,Excel,Access
                      ALTAS/BAJAS avisarte cursos en http://www.solotxt.com
                    Your message has been successfully submitted and would be delivered to recipients shortly.