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

Re: [Clip] Need to open a new empty file and close it

Expand Messages
  • 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 1 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 2 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.