TextReplace plugin: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (→‎Unload plugin: formatting)
 
(5 intermediate revisions by 2 users not shown)
Line 23: Line 23:
=== Search in file ===
=== Search in file ===


${textreplace::FindInFile} "[InputFile]" "[FindIt]" "[Options]" $var
'''${textreplace::FindInFile} "[InputFile]" "[FindIt]" "[Options]" $var'''


"[InputFile]"  - Input file
:"[InputFile]"  - Input file


"[FindIt]"      - String to find or pointer to the buffer if used option /PI=1
:"[FindIt]"      - String to find or pointer to the buffer if used option /PI=1


"[Options]"    - Search options
:"[Options]"    - Search options
  /S=[0|1]
::  /S=[0|1]
    /S=0  - Case insensitive (default)
:::    /S=0  - Case insensitive (default)
    /S=1  - Case sensitive (faster)
:::    /S=1  - Case sensitive (faster)
  /PI=[0|1]
::  /PI=[0|1]
    /PI=0  - FindIt is a string (default)
:::    /PI=0  - FindIt is a string (default)
    /PI=1  - FindIt is a pointer to the text buffer
:::    /PI=1  - FindIt is a pointer to the text buffer
 
$var  number of founded strings
      -3  ReplaceIt string is empty
      -4  can't open input file for reading
      -5  can't get file size of the input file
      -6  can't allocate buffer for input file text
      -7  can't read input file
      -8  input file is binary or wide character Unicode file


:$var  number of founded strings
::      -3  ReplaceIt string is empty
::      -4  can't open input file for reading
::      -5  can't get file size of the input file
::      -6  can't allocate buffer for input file text
::      -7  can't read input file
::      -8  input file is binary or wide character Unicode file


=== Replace in file ===
=== Replace in file ===


${textreplace::ReplaceInFile} "[InputFile]" "[OuputFile]" "[ReplaceIt]" "[ReplaceWith]" "[Options]" $var
'''${textreplace::ReplaceInFile} "[InputFile]" "[OuputFile]" "[ReplaceIt]" "[ReplaceWith]" "[Options]" $var'''


"[InputFile]"  - Input file
:"[InputFile]"  - Input file


"[OutputFile]"  - Output file, can be equal to InputFile
:"[OutputFile]"  - Output file, can be equal to InputFile


"[ReplaceIt]"  - String to replace or pointer to the buffer if used option /PI=1
:"[ReplaceIt]"  - String to replace or pointer to the buffer if used option /PI=1


"[ReplaceWith]" - Replace with this string or pointer to the buffer if used option /PO=1
:"[ReplaceWith]" - Replace with this string or pointer to the buffer if used option /PO=1


"[Options]"    - Replace options
:"[Options]"    - Replace options
  /S=[0|1]
::  /S=[0|1]
    /S=0  - Case insensitive (default)
:::    /S=0  - Case insensitive (default)
    /S=1  - Case sensitive (faster)
:::    /S=1  - Case sensitive (faster)
  /C=[1|0]
::  /C=[1|0]
    /C=1  - Copy the file if no changes made (default)
:::    /C=1  - Copy the file if no changes made (default)
    /C=0  - Don't copy the file if no changes made
:::    /C=0  - Don't copy the file if no changes made
  /AI=[1|0]
::  /AI=[1|0]
    /AI=1  - Copy attributes from the InputFile to OutputFile (default)
:::    /AI=1  - Copy attributes from the InputFile to OutputFile (default)
    /AI=0  - Don't copy attributes
:::    /AI=0  - Don't copy attributes
  /AO=[0|1]
::  /AO=[0|1]
    /AO=0  - Don't change OutputFile attributes (error "-9" possible) (default)
:::    /AO=0  - Don't change OutputFile attributes (error "-9" possible) (default)
    /AO=1  - Change OutputFile attributes to normal before writting
:::    /AO=1  - Change OutputFile attributes to normal before writting
  /PI=[0|1]
::  /PI=[0|1]
    /PI=0  - ReplaceIt is a string (default)
:::    /PI=0  - ReplaceIt is a string (default)
    /PI=1  - ReplaceIt is a pointer to the text buffer
:::    /PI=1  - ReplaceIt is a pointer to the text buffer
  /PO=[0|1]
::  /PO=[0|1]
    /PO=0  - ReplaceWith is a string (default)
:::    /PO=0  - ReplaceWith is a string (default)
    /PO=1  - ReplaceWith is a pointer to the text buffer
:::    /PO=1  - ReplaceWith is a pointer to the text buffer


$var  number of replacements
:$var  number of replacements
      -1  ReplaceIt pointer is incorrect
::      -1  ReplaceIt pointer is incorrect
      -2  ReplaceWith pointer is incorrect
::      -2  ReplaceWith pointer is incorrect
      -3  ReplaceIt string is empty
::      -3  ReplaceIt string is empty
      -4  can't open input file for reading
::      -4  can't open input file for reading
      -5  can't get file size of the input file
::      -5  can't get file size of the input file
      -6  can't allocate buffer for input file text
::      -6  can't allocate buffer for input file text
      -7  can't read input file
::      -7  can't read input file
      -8  input file is binary or wide character Unicode file  
::      -8  input file is binary or wide character Unicode file  
      -9  can't open output file for writting
::      -9  can't open output file for writting
      -10  can't allocate buffer for output file text
::      -10  can't allocate buffer for output file text
      -11  can't write to the output file
::      -11  can't write to the output file


=== Put text file contents to the buffer ===


=== Put text file contents to the buffer ===
'''${textreplace::FillReadBuffer} "[File]" $var'''


${textreplace::FillReadBuffer} "[File]" $var
:"[File]"   - Input file


"[File]"   - Input file
:$var   pointer to the buffer
::      -4  can't open input file for reading
::      -5  can't get file size of the input file
::      -6  can't allocate buffer for input file text
::      -7  can't read input file
::      -8  input file is binary or wide character Unicode file


$var  pointer to the buffer
=== Free buffer ===
      -4  can't open input file for reading
      -5  can't get file size of the input file
      -6  can't allocate buffer for input file text
      -7  can't read input file
      -8  input file is binary or wide character Unicode file


'''${textreplace::FreeReadBuffer} "[Pointer]"'''


Zoho Writer is great for students that may work in a self-paced scohol or less fortunate scohol because it is a free program. Zoho Writer works similar to Microsoft office, except for the fact, that it does not have all the  bells and whistles.  Also, this program allows people to collaborate at the same time, even if they are in different places. The great thing about using the internet to run this program is that anyone can use it where there is access. This program allows all kinds of documents to be able to be uploaded, and they can be revised or submitted to other websites by using Zoho Writer first. This application would be helpful in a classroom if students were absent, or if they were working on a group project. This application puts a new spin on the term group project. Students in the group could upload or revise any part of the document they wanted to and other group members would be able to see it. This allows for group members to still communicate and participate but without having to meet up in person. Teachers love group projects, so this would be a great tool for teachers to people able to use. Zoho Writer is there as a tool to help other documents, so even though it does not have all the special features that Microsoft word does, that is ok because you pay for those special features; whereas Zoho is free
:"[Pointer]"  - Pointer to the buffer


=== Unload plugin ===
=== Unload plugin ===


${textreplace::Unload}
'''${textreplace::Unload}'''




[[Category:Plugins]]
[[Category:Plugins]]

Latest revision as of 15:59, 8 January 2016

Author: Instructor (talk, contrib)


Links

Download v1.5:
Textreplace.zip (33 KB)

Discussion:
Forum thread

Description

Features:

  • Fast search/replacement in text file
  • Case sensitive/insensitive replacement
  • Supports strings and pointers to the buffer
  • If no changes possible, output file will be untouched
  • Checks if input file is a binary file

Docs

Taken from the Readme.txt (TextReplace NSIS plugin v1.5)

Search in file

${textreplace::FindInFile} "[InputFile]" "[FindIt]" "[Options]" $var

"[InputFile]" - Input file
"[FindIt]" - String to find or pointer to the buffer if used option /PI=1
"[Options]" - Search options
/S=[0|1]
/S=0 - Case insensitive (default)
/S=1 - Case sensitive (faster)
/PI=[0|1]
/PI=0 - FindIt is a string (default)
/PI=1 - FindIt is a pointer to the text buffer
$var number of founded strings
-3 ReplaceIt string is empty
-4 can't open input file for reading
-5 can't get file size of the input file
-6 can't allocate buffer for input file text
-7 can't read input file
-8 input file is binary or wide character Unicode file

Replace in file

${textreplace::ReplaceInFile} "[InputFile]" "[OuputFile]" "[ReplaceIt]" "[ReplaceWith]" "[Options]" $var

"[InputFile]" - Input file
"[OutputFile]" - Output file, can be equal to InputFile
"[ReplaceIt]" - String to replace or pointer to the buffer if used option /PI=1
"[ReplaceWith]" - Replace with this string or pointer to the buffer if used option /PO=1
"[Options]" - Replace options
/S=[0|1]
/S=0 - Case insensitive (default)
/S=1 - Case sensitive (faster)
/C=[1|0]
/C=1 - Copy the file if no changes made (default)
/C=0 - Don't copy the file if no changes made
/AI=[1|0]
/AI=1 - Copy attributes from the InputFile to OutputFile (default)
/AI=0 - Don't copy attributes
/AO=[0|1]
/AO=0 - Don't change OutputFile attributes (error "-9" possible) (default)
/AO=1 - Change OutputFile attributes to normal before writting
/PI=[0|1]
/PI=0 - ReplaceIt is a string (default)
/PI=1 - ReplaceIt is a pointer to the text buffer
/PO=[0|1]
/PO=0 - ReplaceWith is a string (default)
/PO=1 - ReplaceWith is a pointer to the text buffer
$var number of replacements
-1 ReplaceIt pointer is incorrect
-2 ReplaceWith pointer is incorrect
-3 ReplaceIt string is empty
-4 can't open input file for reading
-5 can't get file size of the input file
-6 can't allocate buffer for input file text
-7 can't read input file
-8 input file is binary or wide character Unicode file
-9 can't open output file for writting
-10 can't allocate buffer for output file text
-11 can't write to the output file

Put text file contents to the buffer

${textreplace::FillReadBuffer} "[File]" $var

"[File]" - Input file
$var pointer to the buffer
-4 can't open input file for reading
-5 can't get file size of the input file
-6 can't allocate buffer for input file text
-7 can't read input file
-8 input file is binary or wide character Unicode file

Free buffer

${textreplace::FreeReadBuffer} "[Pointer]"

"[Pointer]" - Pointer to the buffer

Unload plugin

${textreplace::Unload}