Files
File Management
Purpose: |
Copy an external file. |
Category: |
Files |
Syntax: |
FileCopy "source file" "destination" source file The name of an existing external file on the reader’s computer. destination The drive and folder on the reader’s computer where the copied file is to be saved. You may optionally include a file name as part of the destination to save the copied file under a different name. |
Example: |
FileCopy "[PubDir]test.doc" "c:\my documents" |
Purpose: |
Erase an external file. |
Category: |
Files |
Syntax: |
FileErase "file name" file name The name of an existing external file. |
Example: |
FileErase "c:\sample files\mydata.bak" |
Purpose: |
Determine if an external or embedded file exists. |
Category: |
Files |
Syntax: |
FileExists "file name" "variable" file name The name of the file (including drive and path) to check. variable The name of the variable to store the result of the search. If the file exists, the variable will be set to “True”, otherwise, it will be set to “False”. |
Example: |
The example below displays an alert box if the file mydata.dat exists: FileExists "c:\sample files\mydata.dat" "[Result]" |
Purpose: |
Rename an external file. |
Category: |
Files |
Syntax: |
FileRename "file name" "new file name" file name The name of the file (including drive and path) to rename. new file name The new file name (including drive and path). |
Example: |
The example below displays an alert box if the file mydata.dat exists: FileRename "[PubDir]myfile.txt" "[PubDir]mynewnamefile.txt" |
Purpose: |
Get the size (in bytes) of an external or embedded file. |
Category: |
Files |
Syntax: |
FileSize "file name" "variable" file name The name of the file (including drive and path) to check. variable The name of the variable to store the file's size. If the file does not exist, the variable will be cleared and an error message displayed. |
Example: |
The example below displays an alert box containing the size of the file sample.txt: FileSize "[PubDir]sample.txt" "[Size]" |
Purpose: |
Determine if an external folder exists. |
Category: |
Files |
Syntax: |
FolderExists "path" "variable" path The name of the folder to check. variable The name of the variable to store the result of the search. If the folder exists, the variable will be set to “True”, otherwise, it will be set to “False”. |
Example: |
FolderExists "C:\Program Files" "[Result]" |
Purpose: |
Create a new folder. |
Category: |
Files |
Syntax: |
CreateFolder "folder name" folder name The path and name of the new folder. |
Example: |
CreateFolder "C:\MyFolder" |
Purpose: |
Remove an existing empty folder from the computer’s hard drive. |
Category: |
Files |
Syntax: |
RemoveFolder "folder name" folder name The name of the folder to remove. |
Example: |
RemoveFolder "c:\myfolder" |
Purpose: |
Extract a file from your compiled publication. |
Category: |
Files |
Syntax: |
ExtractFile "source file" "destination" source file The name of the source file to be extracted. This file will be stored inside your compiled publication. destination The drive and folder on the reader’s computer where the extracted file is to be saved. You may optionally include a file name to save the extracted file under a different name. |
Example: |
ExtractFile "c:\samples\template.doc" "c:\my documents" |
Purpose: |
Generate a list of files and/or folders found in the specified path. |
||||||
Category: |
Files |
||||||
Syntax: |
FileList "file mask" "options" "variable" file mask The path and file name mask to search. The mask can include wildcard characters. For example, "C:\Sample\*.*" will list all files in the C:\Sample folder. options Can include any combination of the following:
variable The name of the variable to store the list. Multiple files will be separated by carriage returns. |
||||||
Example: |
The following example compiles a list of all JPEG images in the "C:\My Photos" folder and stores them in a variable called [Pics]: FileList "C:\My Photos\*.jpg" "Files+NoExt" "[Pics]" |
File I/O
Purpose: |
Read data from an external text file. |
Category: |
Files |
Syntax: |
FileRead "file name" "line number" "variable" file name The name of an existing external file. line number The number of the line in the file to read. The first line in the file is 1, the second is 2 and so on. You can specify “All” here instead of a line number to read the entire file at once. variable The name of the variable to store the data. |
Example: |
The following example uses FileRead to build a menu from the contents of a file called “Parts.dat”. The file is read one line at a time and the contents added to [MenuChoices] to build the menu. Finally, the menu is displayed using the MenuEx Action command. SetVar "[MenuChoices]" "" Another way of doing the same thing would be to use “All” in place of a line number, which instructs FileRead will load the entire file at once: FileRead "parts.dat" "All" "[MenuChoices]" |
Purpose: |
Write data to an external text file. |
Category: |
Files |
Syntax: |
FileWrite "file name" "line number" "data" file name The name of an existing external file. You can insert the name of a communications port (COM1, COM2, etc.) here instead of a file name to send data to an external device instead. line number The number of the line in the file to write to. The first line in the file is 1, the second is 2 and so on. You can specify “Append” here instead of a line number to add the data to the end of the file. Use “All” here to replace the entire file at once. data The data to be written to the file. |
Example: |
The example below replaces the first line of the parts.dat file: FileWrite "parts.dat" "1" "Calvin Klein Blazer" By default, FileWrite will convert any pipe characters "|" contained within the text into carriage returns/line breaks. To prevent this, add an exclamation point character "!" to the beginning of the data parameter. For example: FileWrite "filename" "All" "![Data]" |
Purpose: |
Insert a blank line into an external text file. The external file must be in plain text/ASCII format. |
Category: |
Files |
Syntax: |
FileInsLine "file name" "line number" file name The name of an existing external file. line number The number of the line in the file where the new line should be inserted. All lines from this point forward will be moved down to make room. The first line in the file is 1, the second is 2 and so on. |
Example: |
The following example inserts a new first line in the file parts.dat: FileInsLine "parts.dat" "1" |
Purpose: |
Delete a specific line from an external text file. The external file must be in plain text/ASCII format. |
Category: |
Files |
Syntax: |
FileDelLine "file name" "line number" file name The name of an existing external file. line number The number of the line in the file to delete. The first line in the file is 1, the second is 2 and so on. |
Example: |
In the following example, readers are asked if they want to delete an item which is stored on a line in the parts.dat file. Their response is stored in a variable named “[Ans]”. If the response is Yes (1), the line is removed from the file. MessageBox "Delete" "Delete #[Item]?" "Yes|No" "[Ans]" |
Purpose: |
Count the number of lines contained in an external text file. |
Category: |
Files |
Syntax: |
FileLen "file name" "variable" file name The name of an existing external file. variable The name of a variable to store the line count. |
Example: |
The example below calculates the size of the parts.dat file and stores the number of lines in the [Lines] variable: FileLen "parts.dat" "[Lines]" |
Purpose: |
Read the contents of a file into a variable. This is similar to using FileRead with the “All” option, but unlike FileRead, FileToVar can be used with Embedded files. |
Category: |
Files |
Syntax: |
FileToVar "file name" "variable" file name The name of an existing external or embedded file. variable The name of the variable to store the contents of the file. |
Example: |
FileToVar "[Embedded]dealers.txt" "[TextEntry1]" |
Purpose: |
Reads a binary file into a Mime stream. |
|
Category: |
Files |
|
Syntax: |
|
|
Example: |
FileToMimeStream "[PubDir]Datafolder\Test2.jpg" "[Testvar]" (Variable: [Test2.jpg.MimeStreamContent]) |
File Name Utiltities
Purpose: |
Extract the drive and folder portion of a file name. |
Category: |
Files |
Syntax: |
ExtractFilePath "file name" "variable" file name The name of a file. variable The name of the variable to store the file’s path. If the file doesn’t have a path, the variable will be empty. |
Example: |
This example places “c:\samples” in the [Path] variable: ExtractFilePath "c:\samples\test.doc" "[Path]" |
Purpose: |
Extract the name and extension portion of a file name and store the result in a variable. |
Category: |
Files |
Syntax: |
ExtractFileName "file name" "variable" file name The name of a file. variable The name of the variable to store the file’s name. |
Example: |
This example places “test.doc” in the [Name] variable: ExtractFileName "c:\samples\test.doc" "[Name]" |
Purpose: |
Extract the extension portion of a file name. See also ChangeFileExt. |
Category: |
Files |
Syntax: |
ExtractFileExt "file name" "variable" file name The name of a file. variable The name of the variable to store the file’s extension. |
Example: |
This example places “.doc” in the [Ext] variable: ExtractFileExt "c:\samples\test.doc" "[Ext]" |
Purpose: |
Extract the drive portion of a file name and store the result in a variable. |
Category: |
Files |
Syntax: |
ExtractFileDrive "file name" "variable" file name A complete file name including drive and path. variable The name of the variable to store the drive information. |
Example: |
This example places “c:” in the [Drive] variable: ExtractFileDrive "c:\samples\test.doc" "[Drive]" |
Purpose: |
Change a file name's extension and store the result in a variable. |
Category: |
Files |
Syntax: |
ChangeFileExt "file name" "extension" "variable" file name A file name extension The new file extension including a period. For example: “.txt” variable The name of the variable to store the modified file name. |
Example: |
ChangeFileExt "sample.dat" ".txt" "[FileName]" |
Registry Utilities
Purpose: |
Read a value from the Windows System Registry database. The Registry contains information about the hardware and software installed on the computer. |
Category: |
Files |
Syntax: |
RegistryRead "key" "section" "variable" key The Registry key that contains the data you want to read. The Registry database is divided into the following key groups: HKEY_CURRENT_USER HKEY_CLASSES_ROOT HKEY_LOCAL_MACHINE HKEY_USERS HKEY_CURRENT_CONFIG HKEY_DYN_DAT Most software applications store their information in the HKEY_CURRENT_USER key. section The Registry section that contains the actual value to read. variable The name of the variable to store the retrieved data. |
Example: |
RegistryRead "HKEY_CURRENT_USER" "Software\MyPub\UserName" "[User]" |
Purpose: |
Write a value to the Windows System Registry database. The Registry contains information about the hardware and software installed on the computer. WARNING: Exercise caution when modifying the Registry. If there is an error in the Registry, your computer (or your reader’s computer) may become nonfunctional. |
Category: |
Files |
Syntax: |
RegistryWrite "key" "section" "value" key The Registry key that contains the section you want to modify. See RegistryRead for a list of available keys. section The Registry section to modify. value The data to write to the Registry. |
Example: |
RegistryWrite "HKEY_CURRENT_USER" "Software\MyPub\UserName" "Joe" |
Purpose: |
Delete a key from a section in the Registry. WARNING: Exercise caution when modifying the Registry. If there is an error in the Registry, your computer (or your reader’s computer) may become nonfunctional. |
Category: |
Files |
Syntax: |
RegistryKeyDel "key" "section" "variable" key The Registry key that contains the section you want to modify. See RegistryRead for a list of available keys. section The Registry section to delete. variable Variable to store the result string. |
Example: |
RegistryKeyDel "HKEY_CURRENT_USER" "Software\MyPub\UserName" "[result]" |
Purpose: |
Read a Registry-section key list |
Category: |
Files |
Syntax: |
RegistryReadKeyList "key" "section" "value" key The Registry key that contains the section you want to modify. See RegistryRead for a list of available keys. section The Registry section to read. variable Variable to store the result list. |
Example: |
RegistryReadKeyList "HKEY_CURRENT_USER" "Software\MyPub\" "[result]" |
Purpose: |
Read a list of all Registry-sections. |
Category: |
Files |
Syntax: |
RegistryReadSectionList "key" "section" "value" key The Registry key that contains the section you want to modify. See RegistryRead for a list of available keys. section The Registry section to read. variable Variable to store the result list. |
Example: |
RegistryReadSectionList "HKEY_CURRENT_USER" "Software\" "[result]" |
Ini File Support
An INI file is a configuration file for computer software that consists of a text-based content with a structure and syntax comprising key–value pairs for properties, and sections that organize the properties. You can use your own .ini file to customize your software user experience and/or save simple data in between sessions.
Purpose: |
Write a key and its value to a section in a ini-file. |
Category: |
Files |
Syntax: |
IniWrite "ini file" "section" "key" "value" ini file .ini file name. section The ini file section where you want to write the value. key Key name to write. value Value to assign to the key (the actual value to write). |
Example: |
IniWrite "[PubDir]myfile.ini" "mysection" "keyname" "keyvalue" |
Purpose: |
Read a value from its key and a section in a ini-file. |
Category: |
Files |
Syntax: |
IniRead "ini file" "section" "key" "default value" "variable" ini file .ini file name. section The ini file section where you want to read the value. key Key name to read. default value Default value or error message to assign to the variable if there is any error reading the key. variable The name of the variable to store the retrieved data. |
Example: |
IniRead "[PubDir]myfile.ini" "mysection" "keyname" "Error Message" "[Result]" |
Purpose: |
Delete a key from a section in a ini-file. |
Category: |
Files |
Syntax: |
IniKeyDel "ini file" "section" "key" ini file .ini file name. section The ini file section where you want to delete the value. key Key name to delete. |
Example: |
IniKeyDel "[PubDir]myfile.ini" "mysection" "keyname" |
Purpose: |
Read a complete Ini-section key list. |
Category: |
Files |
Syntax: |
IniReadKeyList "ini file" "section" "variable" ini file .ini file name. section The ini file section where you want to read the values. variable The name of the variable to store the retrieved data. |
Example: |
IniReadKeyList "[PubDir]myfile.ini" "mysection" "[Result]" |
Purpose: |
Read a list of all Ini-sections. |
Category: |
Files |
Syntax: |
IniReadSectionList "ini file" "section" "variable" ini file .ini file name. variable The name of the variable to store the retrieved data. |
Example: |
IniReadSectionList "[PubDir]myfile.ini" "[Result]" |
Zip File Support
ZIP is an archive file format that supports lossless data compression. A ZIP file may contain one or more files or directories.
IMPORTANT:When using full path for zip names directly in the action-editor you should prefix it with the ! (exclamation mark) to prevent the VN compiler to delete the path info. The wizard will add it automaticaly.
Purpose: |
Zip a string to a text file in a zip file. |
Category: |
Files |
Syntax: |
ZipString "zip file" "path/filename" "string" "pack level" "password" "encryption mode" "variable" zip file path and .zip file name to store the zipped content. (Alternatively: [MimeStream]zipfilename) path/filename Path and filename to store the text file within the .zip file. string Text string to zip. pack level Compression level (0-9). password Password to protect the file in the resulting .zip file (Optional). The password is stored for each file in zip. It could be different for each entry. encryption mode Write one of the following encryption modes if you want to password protect your .zip file:
variable The name of the variable to store the commad result (0=error, 1=success). |
Example: |
ZipString "[PubDir]MyTest.zip" "neobook/MyTest.txt" "This is a Teststring!" "9" "" "AES_128" "[Result]" |
Purpose: |
Zip a file or files to a zip file. |
Category: |
Files |
Syntax: |
ZipFiles "zip file" "base directory" "path/filenames" "exclusion list" "pack level" "encryption mode" "password" "variable" zip file path and .zip file name to store the zipped content. (Alternatively: [MimeStream]zipfilename) base directory Base directory for zip operations. path/filename Path and filenames to store within the .zip file. exclusion list Path and filenames to exclude from being zipped within the .zip file. Wildcards are allowed. pack level Compression level (0-9). encryption mode Write one of the following encryption modes if you want to password protect your .zip file:
password Password to protect the files in the resulting .zip file (Optional). variable The name of the variable to store the commad result (0=error, 1=success). |
Examples: |
.zip file1.bat and file2.bat .zip whole app path except executable files. ZipFiles "[PubDir]MyTest.zip" "[PubDir]*.*" "*.exe" "9" "my-password" "PkZip" "[Result]" |
Purpose: |
Zip a MimeStream to a binary file in a zip file or zip stream. |
Category: |
Files |
Syntax: |
ZipMimeStream "zip file" "path/filename" "mime stream" "pack level" "password" "encryption mode" "variable" zip file path and .zip file name to store the zipped content. (Alternatively: [MimeStream]zipfilename) path/filename Path and filenames to store within the .zip file. mime stream [MimeStream]stream-name.ext or variable with stream name to zip pack level Compression level (0-9). password Password to protect the files in the resulting .zip file (Optional). variable The name of the variable to store the commad result (0=error, 1=success). |
Example: |
ZipMimeStream "[PubDir]Target.zip" "NewNameInZip.zip" "[MimeStream]Base64Binary.xxx" "9" "1234" "AES_256" "[Result]" |
Purpose: |
UnZip a string, stored in a zip file or zip stream as a text file, into a variable. |
Category: |
Files |
Syntax: |
UnZipToString "zip file" "path/filename" "password" "variable" zip file path and .zip file name to retrieve the zipped content from. path/filename Path and filename to get the text file from the .zip file. password Password to decompress the file from the .zip file (If necessary). The password is stored for each file in zip. It could be different for each entry. variable The name of the variable to store the uncompressed string. |
Example: |
UnZipToString "[PubDir]mytest.zip" "filename.txt" "my-password" "[ResultVar]" |
Purpose: |
UnZip a file or files from a zip file or zip stream. |
Category: |
Files |
Syntax: |
UnZipToFiles "zip file" "extract folder" "path/filenames" "exclusion list" "password" "variable" zip file path and .zip file name to retrieve the zipped content from. extract folder Base directory for zip operations. The folder to extract the file(s) to. path/filename Path and filenames to retrieve from the .zip file. exclusion list Path and filenames to exclude from being retrieved from the .zip file. Wildcards are allowed. password Password to decompress the file from the .zip file (If necessary). variable The name of the variable to store the commad result (0=error, 1=success). |
Examples: |
UnZipToFiles "[PubDir]MyFolder.zip" "[PubDir]ExtractFolder" "*.*" "" "my-password" "[Result]" |
Purpose: |
UnZip a binary file from a zip file or zip stream to a MimeStream. |
Category: |
Files |
Syntax: |
UnZipToMimeStream "zip file" "mime stream" "password" "variable" zip file path and .zip file name to store the zipped content. mime stream stream-name.zip or variable with stream name. password Password to decompress the content from the .zip file (If necessary). variable The name of the variable to store the commad result (0=error, 1=success). |
Example: |
UnZipToMimeStream "[PubDir]MyZipContainer.zip" "MyFolder.zip" "my-password" "[Result]" |
Purpose: |
Get a file list from a zip file or zip stream. |
Category: |
Files |
Syntax: |
ZipFileList "zip file" "file mask" "exclusion file mask" "delimiter" "list variable" "count variable" zip file path and .zip file name to retrieve the file list from. file mask List of path/filenames/wildcards for listing (ie: *.txt) exclusion file mask List of path/filenames/wildcards to exclude from listing (ie: myfile.txt) Wildcards are allowed. exclusion list Path and filenames to exclude from being retrieved from the .zip file. Wildcards are allowed. delimiter Delimiter to separate list items (ie "|"). neobook\MyText.txt With delimiter a infolist is returned: MyTest.txt|27.07.2021|10:38:42|15|0,0%|17|neobook\ (filename,filedate,filetime,size,compressionrate,compressed size,path) list variable The name of the variable to store the resulting list. count variable The name of the variable to store the total items number. |
Examples: |
ZipFileList "MyFolder.zip" "*.txt" "" "" "[ZipList]" "[ZipCount]" |
Purpose: |
Rename a file in a zip file or zip stream. |
Category: |
Files |
Syntax: |
ZipRenameFile "zip file" "old file name" "new file name" "variable" zip file path and .zip file name where the file to rename is stored. (Alternatively: [MimeStream]zipfilename) old file name File name to rename new file name New name for the file variable The name of the variable to store the commad result (0=error, 1=success). |
Examples: |
ZipRenameFile "[MimeStream]MyFolder.zip" "RegExStr.txt" "RegExStrRenamed.txt" "[ZipResult]" |
Purpose: |
Delete a file or files in a zip file or zip stream. |
Category: |
Files |
Syntax: |
ZipDeleteFiles "zip file" "path/filename" "exclusion list" "variable" zip file path and .zip file name where the file to rename is stored. (Alternatively: [MimeStream]zipfilename) path/filename Path and filenames to delete from the .zip file. exclusion list Path and filenames to exclude from being deleted from the .zip file. Wildcards are allowed. variable The name of the variable to store the commad result (0=error, 1=success). |
Examples: |
ZipDeleteFiles "MyFolder.zip" "RegExStrRenamed.txt" "" "[ZipResult]" |
Purpose: |
Get a stored comment from zip itself or file in zip. (from file or stream) |
Category: |
Files |
Syntax: |
ZipGetComment "zip file" "path/filename" "variable" zip file path and .zip file name where the file to get the comment is stored. path/filename Path and filename to get the comment from. variable The name of the variable to store the comment once retrieved. |
Examples: |
ZipGetComment "MyFolder.zip" "RegExStr.txt" "[ZipResult]" |
Purpose: |
Set a comment for the zip itself or a file in zip. (in file or stream) |
Category: |
Files |
Syntax: |
ZipSetComment "zip file" "path/filename" "comment" "variable" zip file path and .zip file name where the file to set the comment. Alternatively: [MimeStream]zipfilename path/filename Path and filename to set the comment into. variable The name of the variable to store the commad result (0=error, 1=success). |
Examples: |
ZipSetComment "MyFolder.zip" "" "Changed Comment for Zip-File itself" "[Result]" |