PortableApps.com - Your Digital Life, Anywhere

[FileWriteN]

For writing data to files. The values which must be set depend on the Type specified below.

Type

Values: ConfigWrite, INI, Replace, XML attribute, XML text
Mandatory.

Specify the type of file writing which is to be used:

  • ConfigWrite: write arbitrary data to a file, the line on which to write being selected as one starting with the Entry.
  • INI: write a string to an INI file.
  • Replace: search for a string and replace it with another string in a file. This is particularly useful for updating drive letters and configuration paths (using %PAL:Drive% and %PAL:LastDrive%)
  • XML attribute: write an attribute to an XML file. Only available when [Activate]:XML=true.
  • XML text: write a text node to an XML file. Only available when [Activate]:XML=true.

File


Specify the file in which the modification will be made. This file must exist before any writing will be done. If it does not exist, the [FileWriteN] section will be skipped.

Entry

Mandatory for Type=ConfigWrite.

The Value will be written to a line starting with this value, or if it is not found, at the end of the file. This should be set to the text to search for at the start of a line. In an INI-style file, this would be key=, and in an XML file it might be '     <config id="something">'; note that you must include any leading whitespace which will be in the file, and if there is any leading or trailing whitespace you must quote the string with single (') or double (") quotes.

Section

Mandatory for Type=INI.

The INI section to write the value to.

Key

Mandatory for Type=INI.

The INI key to write the value to.

Value

Mandatory for Type=ConfigWrite, INI, XML attribute, XML text.

The value which will be written to the file. If dealing with Type=ConfigWrite, you should remember with things like XML files that you will normally need to close the tag, for example %PAL:DataDir%\settings</config>. In such cases you can also try using the inbuilt XML support.

Find

Mandatory for Type=Replace.

The string to search for.

Replace

Mandatory for Type=Replace.

The string to replace the search string with. If, after environment variable replacement, this is the same as the Find string, the replacement will be skipped (e.g. if you use it to update drive letters and it’s on the same letter).

Attribute

Mandatory for Type=XML attribute

The attribute which will be set inside the element identified by the given XPath. See Dealing with XML data for more details.

XPath

Mandatory for Type=XML attribute, XML text.

Specify the XPath to find the place to write to. It is a good idea to make sure that you have a solid understanding of how XPaths work and how to use them before writing one.

For information about what this should look like, see Dealing with XML data.

CaseSensitive

Values: true / false
Default: false
Applies for Type=ConfigWrite, Replace.
Optional.

Case sensitive searches are somewhat faster than case-insensitive searches. If you can do a case-sensitive ConfigWrite or find and replace, do.

Concerning drive letter updates, you can’t guarrantee what case the drive letter will be and so it will not normally be practical to do a case sensitive replacement for drive letters.

Encoding

Values: auto / ANSI / UTF-16LE
Default: auto
Applies to Type=Replace.
Optional.

If you need to find and replace in a Unicode (UTF-16LE) file, but it is missing the byte-order mark (BOM), set the encoding here as UTF-16LE; if a file for some reason has the UTF-16LE BOM, U+FFFE, at the start of the file, but isn’t really UTF-16LE, set this to ANSI. Otherwise, omit this value and the encoding will be automatically detected by checking for the BOM.

For UTF-8 files, leave this value out. The value ANSI isn’t really ANSI, it’s just “normal”, which includes ANSI, UTF-8 and really anything which doesn’t use null bytes all over the place.

This value only works with the Type Replace; both ConfigWrite and INI automatically detect the encoding of the file (this requires that the file start with the UTF-16LE BOM, U+FFFE).

Changed in version 2.1: previously ConfigWrite was not able to write to UTF-16LE files.

Table Of Contents

Browse

You are here: