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

Need to open a new empty file and close it

Expand Messages
  • Don Passenger
    As part of my little project I need to create a file called %variable%.log I am currently opening it by using a template file: = DocTemplate ClipCode
    Message 1 of 10 , Dec 15, 2000
    • 0 Attachment
      As part of my little project I need to create a file called
      %variable%.log

      I am currently opening it by using a template file:

      = DocTemplate ClipCode "Home%0.3d.htm"
      ^!Set %SurveyName%=^$GetValue(SurveyName)$
      ^!Save AS d:\1h\1grba\bin\survey\^%SurveyName%.log
      ^!Close "d:\1h\1grba\bin\survey\^%SurveyName%.log"


      This is giving me an error message. I don't know if it is because I have
      two files open (this template is being called from another template file on
      the last line of that template file).

      I tried opening the file by just using fileappend, but that required that I
      put something in the file, and it is just an empty file that will later take
      information into it on the server.

      If I remove the last line it works fine except that I have an extra file
      open that I have to manually close.

      Thanks for your anticipated suggestions....

      ---
      Don Passenger
      Personal Page: http://www.iserv.net/~dpasseng
      Court Page: http://www.iserv.net/~dpasseng/grdc
    • Alan
      Hi Don, ... (For those who want a short read, jump down to **BTW** *key* paragraph below has condensed essence of what I discovered from my testing) Yes, as
      Message 2 of 10 , Dec 16, 2000
      • 0 Attachment
        Hi Don,

        >= DocTemplate ClipCode "Home%0.3d.htm"
        >^!Set %SurveyName%=^$GetValue(SurveyName)$
        >^!Save AS d:\1h\1grba\bin\survey\^%SurveyName%.log
        >^!Close "d:\1h\1grba\bin\survey\^%SurveyName%.log"

        >This is giving me an error message.

        (For those who want a short read, jump down to **BTW** *key* paragraph
        below has condensed essence of what I discovered from my testing) Yes, as
        you had stated, the culprit is the ^!Close line. On my Win 98SE NTP 4.83
        it would give an (access violation) error I would then close then reopen
        NoteTab.

        As a template, I first tried it with .log file extension then tried .txt
        file extension. Either way, I could not get it to work with the close line
        activated

        = DocTemplate ClipCode "log%0.3d.txt"
        ;^!Set %SurveyName%=^$GetValue(SurveyName)$
        ^!Set %SurveyName%=trialrun
        ^!Save AS c:\misc\^%SurveyName%.txt
        ;^!Close c:\misc\trialrun.txt

        (See **BTW** *key* below too) Just seems to not agree with attempting to
        close a file from within or as a part of a template. Maybe not supposed to
        close an Ntab doc from within a template???? Could query the NRN email
        list or Query to see if it is a bug

        The following clip's code (utilized from within a clip, not from within a
        template) will do it, creates then closes an empty .log file OK. Perhaps
        you could dub in wherever you had said that you found that appendtofile or
        whatever worked though you said it left unwanted content in the file. BTW
        either of the close lines work; I tried them both.

        H="trialrun"
        ^!Toolbar New Document
        ^!Set %SurveyName%=trialrun
        ^!Save AS c:\misc\^%SurveyName%.log
        ;^!Close c:\misc\trialrun.log
        ^!Close c:\misc\^%SurveyName%.log

        **BTW** *key* Something I found of interest:
        As follows, a template which creates two files. The following as a
        template works. It creates, saves, and closes an empty trialrun.log
        file. But it also creates (an empty) log001.log of which it leaves opened
        in NoteTab. This log001.log is the "using the tpl header to create the
        template created file" So, that right there tells me that the (error)
        problem arises only when I attempt to close a "using the tpl header to
        create the template created file" from within the template that had created
        it. IOW can close the toolbar new doc file OK but error occurs when close
        the DocTemplate ClipCode "log%0.3d.log" file.

        = DocTemplate ClipCode "log%0.3d.log"
        ^!Toolbar New Document
        ^!Set %SurveyName%=trialrun
        ^!Save AS c:\misc\^%SurveyName%.log
        ;^!Close c:\misc\trialrun.log
        ^!Close c:\misc\^%SurveyName%.log

        Larger chunks of code sequenced with other code as well as templates
        (retaining sequence mentally) tends on side of overwhelm for me. (I know
        ya got to break it down to chunks) (and I CAN whenever I take sufficient
        time) Nonetheless, I (quickly) looked your code on www site. Amount of
        potential for creativity using NoteTab and clips (templates too) never
        ceases to amaze me :-)

        Have fun :-) Regards. Alan.
      • Eric G.V. Fookes
        Hello Alan, ... That s correct. You cannot close a template that way. Here s what the Help file says under the Use Templates topic: Note that you cannot close
        Message 3 of 10 , Dec 16, 2000
        • 0 Attachment
          Hello Alan,

          >problem arises only when I attempt to close a "using the tpl header to
          >create the template created file" from within the template that had created
          >it. IOW can close the toolbar new doc file OK but error occurs when close
          >the DocTemplate ClipCode "log%0.3d.log" file.

          That's correct. You cannot close a template that way. Here's what the Help
          file says under the Use Templates topic:

          "Note that you cannot close a template document through its own embedded
          Clip code."


          Regards,
          Eric G.V. Fookes
          Author of NoteTab, Mailbag Assistant, and Album Express
          http://www.fookes.com/ and http://www.notetab.com/







          ...
        • Don Passenger
          Thank you Alan and Eric! I now have a third clip instead of the second template to complete that part of the clip projects goals: H= grbar survey create log
          Message 4 of 10 , Dec 16, 2000
          • 0 Attachment
            Thank you Alan and Eric!

            I now have a third clip instead of the second template to complete that part
            of the clip projects goals:

            H="grbar survey create log"
            ^!Set %SurveyName%=^$GetValue(SurveyName)$
            ^!Toolbar New Document
            ^!Save AS d:\1h\1grba\bin\survey\^%SurveyName%.log
            ^!Close d:\1h\1grba\bin\survey\^%SurveyName%.log

            ;create log kindly created by Alan acummings@...>
            ;and posted to <ntb-clips@egroups.com>


            This opens the file with nothing in it and turns around and closes it so it
            is available for ftp to server as empty receptical. Now I just need to get
            it into the chain of clips/templates and I will be all set. I will call it
            from the first template file (which is working on a file called
            %variable%.html) instead of calling a second template file at that point.

            See the whole project at http://www.bestfoot.com/notetab
            or take the notetab survey generated with this "clip project" at
            http://www.grbar.org/survey/notetabpro.html

            You can see the results of the Notetab survey without taking it with this
            link:
            http://www.grbar.org/cgi-bin/survey/survey.cgi?survey_name=notetabpro

            As to closing a template generated file from within the template, thanks for
            the help clarification Eric and practical findings Alan. I looked through
            the help files, but was looking under file control (doesn't say there that
            ^!close won't work from within a template...and didn't look under use
            template...though I had read it a day or so before when I didn't even know
            what a template was so missed the nuance. Seems to me that you might want to
            add a cross link in !close help or qualify there that it won't work from a
            template on the template created file).

            ---
            Don Passenger
            Personal Page: http://www.iserv.net/~dpasseng
            Court Page: http://www.iserv.net/~dpasseng/grdc
            ----- Original Message -----
            From: Alan <acummings@...>
            To: <ntb-clips@egroups.com>
            Sent: Saturday, December 16, 2000 6:10 AM
            Subject: Re: [Clip] Need to open a new empty file and close it


            > Hi Don,
            >
            > >= DocTemplate ClipCode "Home%0.3d.htm"
            > >^!Set %SurveyName%=^$GetValue(SurveyName)$
            > >^!Save AS d:\1h\1grba\bin\survey\^%SurveyName%.log
            > >^!Close "d:\1h\1grba\bin\survey\^%SurveyName%.log"
            >
            > >This is giving me an error message.
            >
            > (For those who want a short read, jump down to **BTW** *key* paragraph
            > below has condensed essence of what I discovered from my testing) Yes, as
            > you had stated, the culprit is the ^!Close line. On my Win 98SE NTP 4.83
            > it would give an (access violation) error I would then close then reopen
            > NoteTab.
            >
            > As a template, I first tried it with .log file extension then tried .txt
            > file extension. Either way, I could not get it to work with the close
            line
            > activated
            >
            > = DocTemplate ClipCode "log%0.3d.txt"
            > ;^!Set %SurveyName%=^$GetValue(SurveyName)$
            > ^!Set %SurveyName%=trialrun
            > ^!Save AS c:\misc\^%SurveyName%.txt
            > ;^!Close c:\misc\trialrun.txt
            >
            > (See **BTW** *key* below too) Just seems to not agree with attempting to
            > close a file from within or as a part of a template. Maybe not supposed
            to
            > close an Ntab doc from within a template???? Could query the NRN email
            > list or Query to see if it is a bug
            >
            > The following clip's code (utilized from within a clip, not from within a
            > template) will do it, creates then closes an empty .log file OK. Perhaps
            > you could dub in wherever you had said that you found that appendtofile or
            > whatever worked though you said it left unwanted content in the file. BTW
            > either of the close lines work; I tried them both.
            >
            > H="trialrun"
            > ^!Toolbar New Document
            > ^!Set %SurveyName%=trialrun
            > ^!Save AS c:\misc\^%SurveyName%.log
            > ;^!Close c:\misc\trialrun.log
            > ^!Close c:\misc\^%SurveyName%.log
            >
            > **BTW** *key* Something I found of interest:
            > As follows, a template which creates two files. The following as a
            > template works. It creates, saves, and closes an empty trialrun.log
            > file. But it also creates (an empty) log001.log of which it leaves opened
            > in NoteTab. This log001.log is the "using the tpl header to create the
            > template created file" So, that right there tells me that the (error)
            > problem arises only when I attempt to close a "using the tpl header to
            > create the template created file" from within the template that had
            created
            > it. IOW can close the toolbar new doc file OK but error occurs when close
            > the DocTemplate ClipCode "log%0.3d.log" file.
            >
            > = DocTemplate ClipCode "log%0.3d.log"
            > ^!Toolbar New Document
            > ^!Set %SurveyName%=trialrun
            > ^!Save AS c:\misc\^%SurveyName%.log
            > ;^!Close c:\misc\trialrun.log
            > ^!Close c:\misc\^%SurveyName%.log
            >
            > Larger chunks of code sequenced with other code as well as templates
            > (retaining sequence mentally) tends on side of overwhelm for me. (I know
            > ya got to break it down to chunks) (and I CAN whenever I take sufficient
            > time) Nonetheless, I (quickly) looked your code on www site. Amount of
            > potential for creativity using NoteTab and clips (templates too) never
            > ceases to amaze me :-)
            >
            > Have fun :-) Regards. Alan.
            >
            >
            >
            >
            >
          • Don Passenger
            Question: How do you control the preview in browser focus? I am getting closer with help, but have a new problem in my implementation. The complete project is
            Message 5 of 10 , Dec 17, 2000
            • 0 Attachment
              Question:
              How do you control the preview in browser focus?

              I am getting closer with help, but have a new problem in my implementation.
              The complete project is at http://www.bestfoot.com/notetab

              Because I cannot open and close a file from its own template, I used a
              "farclip" instead. The clip is called from my template file. I don't know
              how to do it but to explain a bit.

              I have a starting clip which takes a name for the project, then makes sure
              that there is not a .srv, .log or .html file under that name already. If
              there is, it prompts to see if you want to continue and if you do, it erases
              those three files so you are starting fresh. It then calls survey.tpl
              template file which creates "name_of_project.html" Within that template
              file I create "name_of_project.srv" by using the AppendToFile function.

              Last the template file calls a far clip to generate an empty file
              "name_of_project.log" and then close that file.

              Here is my problem:
              1. I am in some_other_file.txt when I double click on the first clip to
              begin.
              2. When the template file starts it generates the .html file and output goes
              into that file (except when I append to the .srv file -- which never
              actually appears on screen as an open file and then output goes to the .srv
              file).
              3. When the .log file is created, it opens, appears on screen, closes.
              4. The cursor is in .html file created by template, but if I click on the
              view in web browser to preview result, what loads into the browser is
              "some_other_file.txt" where I was when the clip started, even though the
              cursor is in "name_of_project.html" and the tab for "name_of_project.html"
              is highlighted.
              5. If I click on the "some_other_file.txt" tab and then the
              "name_of_project.html" tab, then I get the correct preview.

              Somehow I am not "updating" the which page to look at when you hit F8 so it
              matches the highlighted tab/file cursor is in.

              This is a very similiar process to how the new html page clip works in the
              stock html library. When that runs, it uses a template file and when it
              completes and you hit browser preview and the new file previews. The only
              thing I see which is significantly different is that I open and close the
              .log file with a far clip from the template file.

              Please help me solve the problem, I have tried a bunch of different things
              to get this done.

              ---
              Don Passenger
              Personal Page: http://www.iserv.net/~dpasseng
              Court Page: http://www.iserv.net/~dpasseng/grdc
            • Jim Hall
              Eric, Jody, et al, Per Eric s request (After far too much procrastination) The BASIC CIP BASICS tutorial is now available (in text and HTML) for download at:
              Message 6 of 10 , Dec 17, 2000
              • 0 Attachment
                Eric, Jody, et al,

                Per Eric's request (After far too much procrastination) The BASIC CIP
                BASICS tutorial is now available (in text and HTML) for download at:


                http://www.jimbow.com/


                Also available here is the REBOOT.COM utility which is handy for doing a
                RESTART in DOS/WIN95/WIN98 from a shortcut (or from within another file).
                Sorry, I could never get it to work in Win2k/NT4.

                I originally used this in DOS Batch files to do an Automatic
                Reconfiguration of my system by renaming different Autoexec and Config
                files to Autoexec.bat and Config.sys and rebooting the computer.

                I have never tried using it in a clip but it should be executable from
                there too.

                Per the instructions in the download file, I currently launch it from a
                shortcut on the desktop when I need to do a restart in Win98.

                Both of the downloads are zipped and just in case you don't have it yet,
                WinZip can also be found at the above site.

                Regards,

                Jim
              • Michiel van Minnen
                ... I haven t completely tested it, but could you use the ^!Shell function? something like ^!Shell ^$FileToUrl( P: ath to project name_of_project.html )$ or
                Message 7 of 10 , Dec 18, 2000
                • 0 Attachment
                  On 17 Dec 2000, at 10:07, Don Passenger wrote:

                  >4. The cursor is in .html file
                  > created by template, but if I click on the view in web browser to
                  > preview result, what loads into the browser is "some_other_file.txt"
                  > where I was when the clip started, even though the cursor is in
                  > "name_of_project.html" and the tab for "name_of_project.html" is
                  > highlighted.

                  I haven't completely tested it, but could you use the ^!Shell
                  function?
                  something like

                  ^!Shell ^$FileToUrl("P:\ath\to\project\name_of_project.html")$

                  or

                  ^!Shell "P:\ath\to\project\name_of_project.html"

                  I can't figure out how to get the current filename, but it looks like
                  you already solved that.
                  The Shell function opens a 'document' with the default application,
                  so a .htm file will probably be opened with your default (default for
                  Windows, not for Notetab) browser.
                • Don Passenger
                  http://www.egroups.com/message/ntb-clips/3687 http://www.egroups.com/message/ntb-clips/4603 http://www.egroups.com/message/ntb-clips/4598 I guess I didn t
                  Message 8 of 10 , Dec 24, 2000
                  • 0 Attachment
                    http://www.egroups.com/message/ntb-clips/3687
                    http://www.egroups.com/message/ntb-clips/4603
                    http://www.egroups.com/message/ntb-clips/4598

                    I guess I didn't think to notice which notetab group it was....
                    it was on the clips list. The above are three of the best found by
                    searching "wayne greedy" under that groups message archive.

                    ---
                    Don Passenger
                    Personal Page: http://www.iserv.net/~dpasseng
                    Court Page: http://www.iserv.net/~dpasseng/grdc
                    ----- Original Message -----
                    From: Michiel van Minnen <michielm@...>
                    To: <ntb-clips@egroups.com>
                    Sent: Monday, December 18, 2000 1:43 PM
                    Subject: Re: [Clip] Need to open a new empty file and close it


                    > On 17 Dec 2000, at 10:07, Don Passenger wrote:
                    >
                    > >4. The cursor is in .html file
                    > > created by template, but if I click on the view in web browser to
                    > > preview result, what loads into the browser is "some_other_file.txt"
                    > > where I was when the clip started, even though the cursor is in
                    > > "name_of_project.html" and the tab for "name_of_project.html" is
                    > > highlighted.
                    >
                    > I haven't completely tested it, but could you use the ^!Shell
                    > function?
                    > something like
                    >
                    > ^!Shell ^$FileToUrl("P:\ath\to\project\name_of_project.html")$
                    >
                    > or
                    >
                    > ^!Shell "P:\ath\to\project\name_of_project.html"
                    >
                    > I can't figure out how to get the current filename, but it looks like
                    > you already solved that.
                    > The Shell function opens a 'document' with the default application,
                    > so a .htm file will probably be opened with your default (default for
                    > Windows, not for Notetab) browser.
                    >
                    >
                    >
                    >
                  • Don Passenger
                    I need some help building a clip! I have a series of text files. I want to make a backup of the file, open the file, and modify content as follows: The file
                    Message 9 of 10 , Jan 1, 2001
                    • 0 Attachment
                      I need some help building a clip!
                      I have a series of text files.
                      I want to make a backup of the file, open the file, and modify content as
                      follows:

                      The file contains something like this:
                      64|76.24|0|0|0|0
                      65|56.79|73.5|87.92|91.48|132.2
                      66|58.71|75.87|90.75|94.5|136.04
                      67|61.26|78.97|94.68|98.51|140.88


                      The first number before the pipe on each line is to be unaffected. The rest
                      of the numbers on each page (unless they are zero's) need to be increased by
                      6.4% and then save the file again.

                      There are maybe 20 lines per file and 20 files I need to do it to. Any
                      suggestions welcome.
                    • Jody
                      Hi Don, ... You will need to build an array and add another outer loop if you want the whole folder done looping through the files with this. See my DirStuff
                      Message 10 of 10 , Jan 2, 2001
                      • 0 Attachment
                        Hi Don,

                        >I have a series of text files.

                        You will need to build an array and add another outer loop if you
                        want the whole folder done looping through the files with this.
                        See my DirStuff for that - search for ^$GetFiles - there are a
                        number of examples. (If you see a plus sign before the path in
                        it, that means to get the files in the sub-folders too, so be
                        careful about that. :) See my sigline for the link - go to the
                        Libraries page.

                        >64|76.24|0|0|0|0
                        >65|56.79|73.5|87.92|91.48|132.2
                        >66|58.71|75.87|90.75|94.5|136.04
                        >67|61.26|78.97|94.68|98.51|140.88
                        >
                        >The first number before the pipe on each line is to be
                        >unaffected. The rest of the numbers on each page (unless they
                        >are zero's) need to be increased by 6.4% and then save the file
                        >again.

                        If, my math is right, Lotta, this will work on a single file :)

                        <--- Copy below this line --->
                        H=Inc 6.4%
                        ; Last Updated 01-02-2001, Sojourner@..., jody
                        ; Should increment vertical bar delimited fields (x6) by
                        ; 6.4% skipping the first field and all the fields
                        ; containing zero. Change both Save:As paths below.

                        ^!SetHintInfo Increasing...
                        ^!SetScreenUpdate Off
                        ^!Jump 1
                        ^!Save:As "E:\DeleteThis.bak"
                        ^!ClearVariable %1Pass%

                        :Reset
                        ^!IfFalse ^%1Pass% Skip
                        ^!Jump +1
                        ^!If ^$GetRow$ = ^$GetLineCount$ Save else Next
                        ^!Set %Field%=2
                        ^!Set %FieldCount%=1

                        :Loop
                        ^!Set %1Pass%=1
                        ^!SetDelimiter ^%VBar%
                        ^!Set %Amount%=^$Calc(^$GetField(-1;^%Field%)$*.064;2)$
                        ^!Set %Amount%=^$Calc(^$GetField(-1;^%Field%)$+^%Amount%;2)$
                        ^!If ^$GetChar$ = 0 Skip
                        ^!Replace "^$GetField(-1:^%Field%)$" >> "^%Amount%" S
                        ^!If ^%FieldCount% = 5 Reset
                        ^!Inc %Field%
                        ^!Inc %FieldCount%
                        ^!Goto Loop

                        :Save
                        ^!Save:As "E:\DeleteThis.txt"

                        <--- Copy above this line, right --->
                        <--- click over a Library, and --->
                        <--- choose "Add from Clipboard" --->

                        Here's an example of ^$GetFiles(...)$ This one will open or close all favorites - I think. <g> I "lost" a logical drive so my drives were re-lettered. <g>

                        H=Open-Close Favorites... Opens or closes a Category of Favorites.
                        ; Last updated on 07-22-2000, Sojourner@..., jody
                        ; Requires NoteTab v4.82 and above
                        ; http://www.notetab.net/html/dirstuff.zip
                        ^!Continue Opens or closes all files in a Favorites Category of choice in the order they appear in the list. Continue?

                        ^!SetHintInfo Opening Files...
                        ; you want this line and edit it of course
                        ^!Set %Favorite%=^$GetFiles("^$GetFavoritePath$";*.fvr;;UnSorted)$
                        ^!Set %Favorite%=^$StrReplace("" "";"|";"^%Favorite%";0;0)$
                        ^!Set %Action%=^?{Open or Close?==_Open|Close}; %Favorite%=^?{(H=20)==^%Favorite%}
                        ^!Set %Favorite%=^$GetFileText("^%Favorite%")$

                        ; you want this set
                        ^!SetListDelimiter ^p
                        ^!SetArray %FileList%=^%Favorite%
                        ^!Set %Count%=^%FileList0%
                        ^!Set %Index%=0

                        ; you want to make this say loop1 and the one above perhaps say loop2
                        :Loop
                        ^!SetScreenUpdate Off
                        ^!Inc %Index%
                        ^!If ^%Index% > ^%Count% End
                        ^!IfTrue ^$IsEmpty("^$GetName("^%FileList^%Index%%")$")$ Skip
                        ; this is where you insert the Clip above, but you need to change
                        ; the Skip above, hmm, methinks just comment it out, and then delete.
                        ; I think that checks for directories in favorites and if it is one,
                        ; it skips it. I suppose I could make it to open the directories
                        ; too... someday... ;)
                        ^!^%Action% "^%FileList^%Index%%"
                        ^!Goto Loop


                        Happy Clip'n!
                        Jody

                        http://www.notetab.net

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