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

[Clip] Modified Install Libraries and Remove Libraries clip

Expand Messages
  • Norma Armstrong
    I went ahead and modified the libraries to move all libraries to a backup folder in Notetab instead of the Recycle bin and to install them back from there.
    Message 1 of 1 , Mar 22 1:57 PM
    • 0 Attachment
      I went ahead and modified the libraries to move all libraries to a backup
      folder in Notetab instead of the Recycle bin and to install them back from
      there. Here's the resulting code. Enjoy!

      Norma

      H="Install Libraries"
      ;Clear variable in case it has been used previously
      ^!ClearVariable %LibraryList%
      ;Get value of last install directory from INI file, if available
      ^!Set %LibraryInstallPath%=^$GetValue(LibraryInstallPath)$
      ;Initialize variable for library search directory if it is empty
      ^!IfTrue ^$IsEmpty(^%LibraryInstallPath%)$ Next ELSE Skip
      ^!Set %LibraryInstallPath%=^$GetAppPath$ + "Backup\"

      ;Get library names to install
      ^!SetArray %LibraryNames%=^?{(T=O;S=M;F="Clipbook libraries
      (*.clb)|*.clb")Select libraries to install (no
      wildcards)=^%LibraryInstallPath%}
      ;Copy the value representing the number of items into the Count variable.
      The variable at index 0 indicates the number of items in the array
      ^!Set %Count%=^%LibraryNames0%
      ;If no files were chose, leave the loop
      ^!If ^%Count% = 0 Exit
      ;Get path of libraries to install
      ^!Set %LibraryInstallPath%=^$GetPath("^%LibraryNames1%")$
      ;If path is same as libraries directory, then they are already installed so
      end Clip
      ^!IfSame "^%LibraryInstallPath%" "^$GetLibraryPath$" Exit
      ;Save install directory to INI file for eventual reuse
      ^!SaveValue LibraryInstallPath=^%LibraryInstallPath%

      ;Initialize the Index variable to 0
      ^!Set %Index%=0

      ;Beginning of loop
      :StartLoop
      ;Add one to the value contained in the variable Index
      ^!Inc %Index%
      ;End the Clip if the Index number is greater than the Count number
      ^!If ^%Index% > ^%Count% EndLoop
      ;Copy the library file name corresponding to the current index value to a
      variable. The content of the array's indexed variable is used here
      ^!Set %LibraryName%=^%LibraryNames^%Index%%
      ;Check if chosen library really exists
      ^!IfFileExist "^%LibraryName%" Next ELSE NotFound
      ;Check if library already exists in Libraries directory
      ^!IfFileExist "^$GetLibraryPath$^$GetFileName("^%LibraryName%")$" Next ELSE
      CopyLibrary
      ;Prompt user if library already exists and is going to be overwritten
      ^!Skip "^$GetFileName("^%LibraryName%")$" is already installed. Overwrite
      it?
      ;Jump back to the start of the loop if user answers no
      ^!Goto StartLoop

      :CopyLibrary
      ;Copy library into Libraries directory
      ^!CopyFile "^%LibraryName%" "^$GetLibraryPath$"
      ^!Info ^%LibraryName% "^$GetLibraryPath$"
      ;Append library name without path and extension to variable. Name is
      preceded with a space in case it starts with a special character. This space
      will have to be removed later
      ^!Skip "Do you want to leave the backup file?"
      ^!DeleteFile ^%LibraryName%
      ^!Info ^%LibraryName%
      ^!Append %LibraryList%= ^$GetName("^%LibraryName%")$|
      ;Jump back to the start of the loop
      ^!Goto StartLoop

      :NotFound
      ^!Prompt Error: "^%LibraryName%" not found
      ^!Goto StartLoop

      :EndLoop
      ^!Refresh

      ;Get size of library list
      ^!Set %SizeList%=^$StrSize("^%LibraryList%")$
      ;Substract one from the SizeList value
      ^!Dec %SizeList%
      ;Format list so it can be used in Clip wizard
      ^!Set %LibraryList%=^$StrCopy("^%LibraryList%";1;^%SizeList%)$

      ;Show Clip wizard
      ^!Set %LibraryName%=^?{(H=5)Open new library?==^%LibraryList%};
      %ShowClipbook%=^?{(T=C)Show Clipbook window?==_Yes|No}
      ;Show or hide Clipbook window based on user's choice
      ^!ShowClipbook ^%ShowClipbook%
      ;Remove first space character added by the Append instruction
      ^!Set %LibraryName%=^$StrDelete("^%LibraryName%";1;1)$
      ;Open chosen library
      ^!LoadLibrary ^%LibraryName%
      ^!IfError Next ELSE Skip
      ^!Prompt Error: could not open "^%LibraryName%"


      H="Remove Libraries"
      ;Store list of library names in the variable LibraryList
      ^!Clip FillLibraryList
      ^!IfPathExist ^$GetAppPath$Backup Start
      ^!MkDir "^$GetAppPath$Backup"

      ;Show Clip wizard
      :Start
      ^!SetArray %LibraryNames%=^?{(H=10;T=A))Choose libraries to
      remove=^%LibraryList%}
      ;Copy the value representing the number of items into the Count variable.
      The variable at index 0 indicates the number of items in the array
      ^!Set %Count%=^%LibraryNames0%
      ;If no files were chose, leave the loop
      ^!If ^%Count% = 0 Exit

      ;Initialize the Index variable to 0
      ^!Set %Index%=0

      ;Beginning of loop
      :StartLoop
      ;Add one to the value contained in the variable Index
      ^!Inc %Index%
      ;End the Clip if the Index number is greater than the Count number
      ^!If ^%Index% > ^%Count% EndLoop
      ;Copy the library file name corresponding to the current index value to a
      variable. The content of the array's indexed variable is used here. Remove
      first space character added by FillLibraryList Clip
      ^!Set %LibraryName%=^$StrDelete("^%LibraryNames^%Index%%";1;1)$
      ;Remove the library by sending it to the Windows recycle bin
      ;^!RecycleFile "^$GetLibraryPath$^%LibraryName%.clb"
      ^!MoveFile "^$GetLibraryPath$^%LibraryName%.clb"
      "^$GetAppPath$Backup\^%LibraryName%.clb"
      ;Jump back to the start of the loop
      ^!Goto StartLoop

      :EndLoop
      ^!Refresh
      ^!Prompt ^%Count% libraries removed


      ------------------------------------------------------------------------
      eGroup home: http://www.eGroups.com/list/ntb-clips
      Free Web-based e-mail groups by eGroups.com
    Your message has been successfully submitted and would be delivered to recipients shortly.