- Table of contents
- File/Folder Handling
- /fopen
- /fclose
- /flist
- /fseek
- /write
- /filter
- /loadbuf
- /savebuf
- /copy
- /rename
- /remove
- /rmdir
- /mkdir
- /paths
- /run
- $crc
- $exists
- $file
- $finddir
- $findfile
- $getdir
- $isdir
- $isfile
- $lines
- $logdir
- $longfn
- $shortfn
- $mircexe
- $adiircexe
- $mircini
- $adiircini
- $mircdir
- $adiircdir
- $scriptdir
- $mkfn
- $mklogfn
- $mknickfn
- $msfile
- $nofile
- $nopath
- $read
- $readn
- $sdir
- $sfile
- $sysdir
- $fopen
- $fread
- $fgetc
- $feof
- $ferr
File/Folder Handling¶
/fopen¶
Added in 1.8.10
/fopen [-nox] <handle> <filename>
Opens the specified file and assigns a name to it for later reference. The open fails if the file does not exist.
See also /fclose, /fwrite, /fseek, /flist, $fread, $fgetc, $feof, $ferr, $fopen.
Switches
Switch | Description |
-n | Creates the file if it does not exists, fails if the file exists. |
-o | Creates a new file, overwrites if it exists. |
-x | Opens the file in exclusive access. |
Parameters
Parameter | Description |
<handle> | Handle to assign the file. |
<filename> | Path/Filename to open. |
Example
alias fopen_example { ;Open hello.txt file. /fopen -n h hello.txt ;Error check if ($ferr) { /echo -sce info * /fopen_example: $err /halt } ;Write 'Hello There' to the file. /fwrite h Hello There ;Close the handle. /fclose h ;Open file in default editor. /run hello.txt }
/fclose¶
Added in 1.8.10
/fclose <handle>
Closes the file associated with this handle.
If you specify a wildcard, all matching handles are closed.
See also /fopen, /fwrite, /fseek, /flist, $fread, $fgetc, $feof, $ferr, $fopen.
Parameters
Parameter | Description |
<handle> | The handle to close. |
Example
alias example { ; Open a file. /fopen -o x example.txt ; write to the file. /fwrite x Print this line. ; Close the file handle. /fclose x }
/flist¶
Added in 1.9.0
/flist [handle]
Lists all open files, or those matching the specified handle.
Wildcards can be used.
See also /fopen, /fclose, /fwrite, /fseek, $fread, $fgetc, $feof, $ferr, $fopen.
Parameters
Parameter | Description |
[handle] | Handle to match. |
Examples
;List all open files matching myhandle*. /flist myhandle* ;List all open files. /flist
/fseek¶
Added in 1.8.10
/fseek [-lnrwp] <handle> <position | line number | wildcard | regex>
Sets the read/write pointer to the specified position in the file.
See also /fopen, /fclose, /fwrite, /flist, $fread, $fgetc, $feof, $ferr, $fopen.
Switches
Switch | Description |
-l | Set position to line 'line number'. |
-n | Set position to start of the next line. |
-r | Set position to text matching 'regex'. |
-w | Set position to text matching 'wildcard'. |
-p | Set position to start of the previous line. |
Parameters
Parameter | Description |
<handle> | The file handle to seek. |
<position | line number | wildcard | regex> | The position/Line number with -l/Wildcard with -w/regex with -w to set. |
/write¶
Added in 1.9.0
/write [-cidnaiNmN l<line> s<text> w<wildcard> r</regex/>] <filename> [text]
Writes lines to a text file.
Switches
Switch | Description |
-c | Clears the entire file before writing to it. |
-i | Inserts the text at a given line instead of replacing it. |
-d | Deletes the given or last line. |
-n | Prevent adding $crlf at the end of the text. |
-a | Appends the text to an existing line. |
-lN | Line number for the line to write/modify/delete. |
-sN | Operates on a line that matches the scanned <text>. |
-wN | Operates on a line that matches the scanned <wildcard> pattern. |
-r | same as -w - but uses a regular expression match. |
-mN | changes how $crlf are written to the end of a file, where N = 0 is the default behavior, N = 1 adds $crlf to end of file if it is not already there before writing a line, and N = 2 never adds $crlf to end of file before writing a line. |
Parameters
Parameter | Description |
<line> | The line number to find. |
<text> | The text to scan. |
<wildcard> | Wildcard pattern to match. |
</regex/> | Regular expression pattern to match. |
<filename> | The file name to manipulate. |
[text] | The text to be written to the file. |
Example
alias example { ; Create a file and add a few lines of text to it. /write Example.txt this is a cool line /write Example.txt hello there! /write Example.txt text files are cool ; Locate the line that starts with "hello" and insert the following text before it. /write -is"Hello" Example.txt This will become line 2! ; Delete line 1. /write -dl1 Example.txt }
/filter¶
Added in 1.9.4
/filter [-asdfhHNkwxnpriocteubglLzNDE] [n-n2] [c s] <infile | dialog id> <outfile | dialog id | alias> [alias] <matchtext>
Scans lines of text in a window, file or dialog control, any matches are then written out to another window, file, or dialog control.
The order of the switch are important, they define what is the infile and what is the outfile, see the examples for more information.
You can filter blank lines by specifying $crlf for the matchtext.
The $filtered identifier will retrieve the number of matches found.
Switches
Switch | Description |
-w | Indicates the parameter is a window. |
-f | Indicates the parameter is a file. |
-a | Sorts filtered lines by calling the optional [alias] parameter, the alias is passed two lines, $1 and $2, it must compare both and return -1, 0, or 1 to indicate relative sort order of these lines to each other. |
-x | Excludes matching lines. |
-n | Prefixes lines with a line number. (the Nth match) |
-d | TODO |
-s | Indicates the status window will be used. |
-p | TODO (AdiIRC always wraps lines) |
-r | Specifies the range of lines n to n2 for filtering. |
-b | Strips any control codes when matching text. |
-g | Indicates the matchtext is a regular expression. |
-z | Retains line colors when filtering between custom windows. |
-k | Indicates that you have specified an <alias> as the output instead of a window name. The alias will be called with the result of each filtered line with the form $<alias>($1) where $1 is the matched line. |
-i | Indicates that you have provided a [dialog id] custom dialog control as the input. |
-o | Indicates that you have provided a [dialog id] custom dialog control as the output. |
-c | Clears the output window/file before writing to it. |
-t | Sorts the output based on [c s], column C using character S as the columns separator. |
-e | Used with -t, specifies a descending sort. |
-u | Used with -t, specifies a numeric sort. |
-l | Filters from the side-listbox in the first window. |
-L | Filters to the side-listbox in the second window. |
-hN | TODO |
-H | Halt the running /filter loop if used inside the [alias]. (AdiIRC only) |
-N | Keep the nickcolumn character when filtering from a window. (AdiIRC only) |
-E | Filters from the Editbox up/down history in the first window. (AdiIRC only) |
-D | Filters to the Editbox up/down history in the second window. (AdiIRC only) |
Parameters
Parameter | Description |
[n | n2] - if -r is used, indicates the range of lines to be scanned* |
[c s] | if -t is used, indicates how to do the sort |
<infile | dialog id> | if no switch implies a window's name to be use as the infile, you must provide an infile (a window, a file, or a dialog control) |
<outfile | dialog id | alias> | if no switch implies a window's name to be used as the outfile, you must provide an outfile (a window, a file, a dialog control, or an alias name if -k is used) |
[alias] | Optional alias called if -a is used. |
<matchtext> | The expression used for the search, if $null is used, it matches everything. |
Example
;Filter from the file "c:\my file.txt" to the custom window @mywin. /filter -fw "c:\my file.txt" @mywin *findthis* ;Filter from the custom window @mywin to the file "c:\my file.txt". filter -wf @mywin "c:\my file.txt" *findthat* ;Filter from the status window to the single message window. /filter -sd *findthis* ;Filter from the single message window to the status window. /filter -ds *findthat* ;Filter from the filename @this_is_a_file to the dialog 'dialog', id '1'. /filter -fo @this_is_a_file dialog 1 *findthis* ;Filter from a file and call an alias for each line. /filter -fk file myalias *findthat* ;Filter from a file to a file using regex. /filter -ffg file1 file2 /regex here/ alias sortexample { ;Create 2 windows. /window @asd1 /window @asd2 ;Add some unordered lines. aline @asd1 cccc3|cccc2|cccc1 aline @asd1 aaaa3|aaaa2|aaaa1 aline @asd1 bbbb3|bbbb2|bbbb1 ;Sort by column "1" where column separator is "|" (ascii char 124). (equal to $gettok(cccc3|cccc2|cccc1, 1, 124)) /filter -twwc 1 124 @asd1 @asd2 }
/loadbuf¶
Added in 1.9.0
/loadbuf [lines] [-acNegilmnoprst<topic>] <window | dialog id> <filename>
Loads the specified number of lines from the end of the file of filename into the specified window.
Switches
Switch | Description |
-a | Loads the text into the active window. |
-cN | Specifies the default color (N) for the line being read. |
-e | Evaluates variables and identifiers in the line being read. |
-g | TODO |
-i | TODO |
-l | Reads the lines into side-listbox in a custom window. |
-m | Indicates that the logging text is already timestamped. |
-n | Logs the loaded text to a log file, if logging is enabled for that window |
-o | Indicates that you have specified the [dialog id] parameters instead of a window name in order to load lines into a custom dialog control. |
-p | TODO |
-r | Clears the contents of the output window before adding read lines. |
-s | Reads the lines into the associated status window. |
-t<topic> | Loads the text under the [topic] section in an INI or plain text file. |
Parameters
Parameter | Description |
[lines] | If specified, the number of lines to add from the end the file, otherwise the whole content of the file is added. |
<window | dialog id> | Window or dialog id to load into. |
<filename> | File to load. |
Example
; Open a custom window. /window @Example ; Read 10 lines from the AdiIRC config file into the custom window //loadbuf 10 -r @Example $qt($adiircini) ; Only loads the [Messages] AdiIRC section of the config file. //loadbuf -rTMessages @Example $qt($adiircini)
/savebuf¶
Added in 1.9.4
/savebuf [-aglosNn] [n1-n2] <window | dialog id> <filename>
Saves the specified number of lines from the end of the buffer of the specified window into the specified filename.
Switches
Switch | Description |
-a | Append the text to the end of the file. |
-l | Use side-listbox. |
-o | Indicates that you have specified [dialog id] parameters instead of a window name in order to save text from a custom dialog control. |
-s | Use status window. |
-N | Keep the nickcolumn character when saving a window. (AdiIRC only) |
-p | Strip all control codes. |
-n | TODO |
Parameters
Parameter | Description |
n1-n2 | Save only lines n1 to n2 starting from the end of the buffer. (if no lines are specified, all lines are saved) |
<window | dialog id> | Window or dialog/dialogid to save from. |
<filename> | Filename to save to. |
/copy¶
Added in 1.9.6
/copy [-aop] <filename> <filename/directory>
Copies a file to another filename or directory.
Switches
Switch | Description |
-a | Appends the source file to the target file. |
-o | Overwrites the target file if it exists. |
-f | Flushes copy to disk immediately. |
-p | Preserves accessed/created/modified timestamps. |
Parameters
Parameter | Description |
<filename> | Filename to copy from. (Can be a wildcard) |
<filename/directory> | Filename or directory to copy to. |
Example
; Copy all the files in directory 'aaa' into directory 'bbb'. /copy aaa bbb ; Copy file 'aaa.png' into folder 'bbb' /copy aaa.png bbb
/rename¶
Added in 1.9.0
_
/rename [-of] <filename> <new filename>
Renames a file or folder, can also be used to move a file or folder to another location.
Switches
Switch | Description |
-o | Overwrites the target file if it exists. |
-f | Flushes copy to disk immediately. |
Parameters
Parameter | Description |
<filename> | File/folder to rename or move. |
<new filename> | New filename/foldername. |
Example
/rename E:\example.txt "E:\renamed with spaces.txt"
/remove¶
Added in 1.9.0
/remove [-b] <filename>
Deletes the specified file.
Switches
Switch | Description |
-b | Move the file to the recycle bin instead of deleting it. |
Parameters
Parameter | Description |
<filename> | File to remove. |
Example
;Create and write to a file. /write test.txt Hello There ;Remove the file. /remove test.txt
/rmdir¶
Added in 1.9.0
/rmdir <dirname>
Deletes the specified directory but only if it is empty.
Parameters
Parameter | Description |
<dirname> | Directory to delete. |
Example
;Delete folder $adiircdir $+ test /rmdir test ;Delete folder "c:\test folder" /rmdir "c:\test folder"
/mkdir¶
Added in 1.9.0
/mkdir <dirname>
Creates the specified directory.
Parameters
Parameter | Description |
<dirname> | Directory to create. |
Examples
;Create directory $adiircdir $+ test /mkdir test ;Create directory "c:\test directory" /mkdir "c:\test directory"
/paths¶
Added in 1.8.3
/paths [-dilorst]
No parameters shows current install and config directory paths.
Switches
Switch | Description |
-d | Opens dcc directory. |
-i | Opens dictionary directory. |
-l | Opens log directory. |
-o | Opens config directory. |
-r | Opens install directory. |
-s | Opens scripts directory. |
-t | Opens themes directory. |
/run¶
Added in 1.5
/run [-ahnp] <filename|url> [arguments]
Runs the specified program.
If a URL is entered, default browser will be used.
See also $exec.
Filenames using spaces must be enclosed in quotes unless the filetype is .exe or .bat when passing arguments.
Switches
Switch | Description |
-a | Ask to run the application as a administrator. |
-h | Hide the application in context. |
-n | Minimizes the window of the program. |
-p | Sets the working path to the path of the program. |
-u | If AdiIRC is running as admin, runs the program without admin right. |
Parameters
Parameter | Description |
<filename|url> | File or url to run. |
[arguments] | Arguments list to be passed to the program. |
Example
; Open www.adiirc.com. /run www.adiirc.com ; Open notepad. /run notepad.exe ; Open firefox to the url 'www.adiirc.com'. /run C:\Program Files\firefox.exe www.adiirc.com
$crc¶
Added in 1.9.0
$crc(text|&binvar|filename,[N])
Returns the CRC checksum of the specified item.
Parameters
Parameter | Description |
text|&binvar|filename | Value to calculate CRC checksum from. |
N | 0 = plain text, 1 = &binvar, 2 = filename (content of the file), 2 is default. |
$exists¶
Added in 1.9.0
$exists(file|dir)
Returns $true if a file or dir exists otherwise $false.
Parameters
Parameter | Description |
file|dir | File or directory. |
Example
; Check if file exists if ($exists(c:\windows\notepad.exe) file exists ; Check if directory exists if ($exists(c:\windows) directory exists
$file¶
Added in 1.8.10
$file(filename|foldername|name)
Returns information about the specified file or folder.
Default returns file size.
Same as $lof.
Parameters
Parameter | Description |
filename|foldername|name | Filename or folder or open file in $fopen to retrieve information from. |
Properties
Property | Description |
.size | File size in bytes. (returns 0 for folders) |
.ctime | Creation time. (unix timestamp) |
.mtime | Last modification time. (unix timestamp) |
.atime | Last access time. (unix timestamp) |
.shortfn | Short file name. |
.longfn | Full file name. |
.attr | File attributes. |
.sig | Returns "ok" if digital signed, else "none". |
.version | Returns the file version, if any. |
.path | The path directory. |
.name | The filename without the file extension. |
.ext | The file extension. |
.pid | Returns the first process id started by this file. (AdiIRC Only) |
Example
; Show AdiIRC.exe filesize //echo -ag $file($adiircexe).size ; Show explorer.exe digital signature //echo -ag $file(c:\windows\explorer.exe).sig
$finddir¶
Added in 1.9.0
$finddir(dir,wildcard,N,[depth],[@window|command])
Searches the specified directory and its sub directories for the Nth directory name matching the wildcard specification and returns the full path and directory if it is found.
If /halt is used in the [command], the search is halted instead of the entire script.
Parameters
Parameter | Description |
dir | The directory to search. |
wildcard | Wildcard to search for. |
N | If N = 0, number of directories, otherwise the Nth directory. |
[depth] | Maximum folder depth. (optional) |
[@window|command] | Custom window name to fill with the result or a command to run on each result. (optional) |
Properties
Property | Description |
.shortfn | Return the path in a shortfn format. |
Example
; Print number of sub directories found in $adiircdir. //echo -ag $finddir($adiircdir,*.*,0) ; Print the 1st directory found. //echo -ag $finddir($adiircdir,*.*,1) ; Print all sub directories in $adiircdir, when using the command parameter, $1- will hold the path. //noop $finddir($adiircdir,*.*,0,echo -ag $1-)
$findfile¶
Added in 1.9.0
$findfile(dir,wildcard,N,[depth],[@window|command])
Searches the specified directory and its subdirectories for the Nth filename matching the wildcard file specification and returns the full path and filename if it is found.
If /halt is used in the [command], the search is halted instead of the entire script.
Parameters
Parameter | Description |
dir | The directory to search. |
wildcard | Wildcard to search for. |
N | If N = 0, number of files, otherwise the Nth filename. |
[depth] | Maximum folder depth. (optional) |
[@window|command] | Custom window name to fill with the result or a command to run on each result. (optional) |
Properties
Property | Description |
.shortfn | Return the path in a shortfn format. |
Example
; Print number of filenames found in $adiircdir. //echo -ag $findfile($adiircdir,*.*,0) ; Print the 1st filename found. //echo -ag $findfile($adiircdir,*.*,1) ; Print all filenames in $adiircdir, when using the command parameter, $1- will hold the path. //noop $findfile($adiircdir,*.*,0,echo -ag $1-)
$getdir¶
Added in 1.9.0
$getdir
Returns the DCC download directory specified in Options -> DCC.
$getdir(filespec)
Returns the DCC download directory matching the filespec, otherwise the directory specified in Options -> DCC.
Parameters
Parameter | Description |
filespec | The filespec. |
Example
; Get the directory for .mp3 files. //echo -ag $getdir(*.mp3)
$isdir¶
Added in 1.8.10
$isdir(dirfile)
Returns $true if the specified directory exists, otherwise $false.
Parameters
Parameter | Description |
dirfile | Directory to check. |
Example
; Check if 'windows' exists. //if ($isdir(C:\Windows)) echo -ag directory exists
$isfile¶
Added in 1.8.10
$isfile(file)
Returns $true if the specified file exists, otherwise $false.
Parameters
Parameter | Description |
file | File to check. |
Example
; Check if notepad.exe exists. //if ($isfile(C:\Windows\notepad.exe)) echo -ag file exists
$lines¶
Added in 1.9.0
$lines(filename)
Returns the total number of lines in the specified text file.
Parameters
Parameter | Description |
filename | Filename to read from. |
Example
;Open a file for writing /fopen file file.txt ;Write a line to the file /fwrite file Hello World ;Close the file /fclose file ;Print the number of lines in file.txt //echo -ag $lines(file.txt) <pre>
$logdir¶
Added in 1.8.10
$logdir
Returns the Logs directory set in Options -> Logging -> Log folder.
$longfn¶
Added in 1.9.0
$longfn(filename)
Returns the long version of a short filename.
Parameters
Parameter | Description |
filename | The filename. |
Example
alias Example { ; Get the shortfn of AdiIRC.exe var %short $shortfn($adiircexe) ; Print the long filename echo -ag $longfn(%short) vs %short }
$shortfn¶
{{include($shortfn}}
$mircexe¶
Added in 1.9.0
$mircexe
Returns the full path and filename of the AdiIRC executable file.
Same as $adiircexe.
Can be used inside text without being surrounded by white spaces.
Example
//echo -ag the adiirc exe file is $mircexe.. notice how $mircexeisreplacedhere
$adiircexe¶
Added in 1.9.0
$adiircexe
Returns the full path and filename of the AdiIRC executable file.
In combination with $~ this can be used to test which client is running the script. You cannot assume the client name based on the filename.exe, but instead testing whether $adiircexe exists as a built-in identifier. The $~ prefix allows the test to evade the presence of a custom alias of that name, and it also does not trigger the optional identifier warning.
//if (!$~adiircexe) echo -a this script is not running in AdiIRC
Same as $mircexe.
Can be used inside text without being surrounded by white spaces.
Example
//echo -ag the adiirc exe file is $adiircexe.. notice how $adiircexeisreplacedhere
$mircini¶
Added in 1.9.0
$mircini
Returns the full path and filename of the AdiIRC settings file (config.ini).
Same as $adiircini.
Can be used inside text without being surrounded by white spaces.
Example
//echo -ag the adiirc ini file is $mircini .. notice how $mirciniisreplacedhere
$adiircini¶
Added in 1.9.0
$adiircini
Returns the full path and filename of the AdiIRC settings file (config.ini).
Same as $mircini.
Can be used inside text without being surrounded by white spaces.
Example
//echo -ag the adiirc ini file is $adiircini.. notice how $adiirciniisreplacedhere
$mircdir¶
Added in 1.9.0
$mircdir
Returns the directory where AdiIRC stores its settings, themes, scripts and so on.
Same as $adiircdir.
Can be used inside text without being surrounded by white spaces.
Example
; Print the scripts folder, no space after $mircdir is needed. //echo -ag $mircdir\Scripts
$adiircdir¶
Added in 1.9.0
$adiircdir
Returns the directory where AdiIRC stores its settings, themes, scripts and so on.
Can be used inside text without being surrounded by white spaces.
Same as $mircdir.
Example
; Print the scripts folder, no space after $adiircdir is needed. //echo -ag $adiircdir\Scripts
$scriptdir¶
Added in 1.9.0
$scriptdir
Returns the directory of the currently executing script.
Can be used inside text without being surrounded by white spaces..
Example
; Print the script directory. //echo -ag current scriptdir is $scriptdir ; Print the script directory inside text. //echo -ag $scriptdir\somefile.ini
$mkfn¶
Added in 1.9.0
$mkfn(filename)
Replaces invalid filename characters with underscore.
Parameters
Parameter | Description |
filename | The filename to format. |
Example
; Format the filename 'tes\t.txt' to 'tes_t.txt' //echo -ag $mkfn(tes\t.txt)
$mklogfn¶
Added in 1.9.0
$mklogfn(filename)
Returns the filename formatted according to options set in Options -> Logging.
Parameters
Parameter | Description |
filename | The filename to format. |
$mknickfn¶
Added in 1.9.0
$mknickfn(nickname)
Formats a nick for use as a valid filename.
Removes certain characters from the nick.
Parameters
Parameter | Description |
nickname | The nickname to format. |
Example
; Format the nickname 'tes\t' to 'test' //echo -ag $mknickfn(tes\t)
$msfile¶
Added in 1.9.0
$msfile(dir,[title],[oktext])
Displays the multiple select file dialog and returns the number of selected files.
Parameters
Parameter | Description |
dir | Starting folder in the file dialog. |
[title] | Dialog title text. (optional) |
[oktext] | TODO (optional) |
Example
; Select some files and print the number of selected files. //echo -ag Number of selected files is $msfile($adiircdir, Select Files)
$msfile(N)
Returns the Nth file from the last $msfile selection.
Parameters
Parameter | Description |
N | If N = 0, number of selected files, otherwise the Nth selected file. |
Example
; Select some files. //noop $msfile($adiircdir, Select Files) ; Print the first selected file. //echo -ag First selected file was $msfile(1)
$nofile¶
Added in 1.9.0
$nofile(filename)
Returns the path in filename without the actual filename.
Parameters
Parameter | Description |
filename | The filename to extract the path from. |
Example
; Print the path 'c:\windows\notepad.exe' without the filename. //echo -ag $nofile(c:\windows\notepad.exe)
$nopath¶
Added in 1.9.0
$nopath(filename)
Returns filename without a path if it has one.
Parameters
Parameter | Description |
filename | The filename/path to get the filename from. |
Example
; Print the filename for the path 'c:\windows\notepad.exe'. //echo -ag $nopath(c:\windows\notepad.exe)
$read¶
Added in 1.9.0
$read(filename, [ntswrp], [matchtext], [N])
Returns a single line of text from a file.
See also $readn.
Parameters
Parameter | Description |
filename | Filename to read. |
[ntswrp] | (optional) |
[matchtext] | Matchtext to search. (optional) |
[N] | The Nth line. |
Options
Option | Description |
n | Don't evaluate any identifiers in the line. |
t | Treat the first line as a plain text, even if it's a number. |
s | Search for matchtext. |
w | Search for case-insensitive matchtext as a wildmatch. |
W | Search for case-sensitive matchtext as a wildmatch. (AdiIRC only) |
r | Search for matchtext as a regular expression. |
p | Treat command | separators as such instead of as plain text. |
Example
; Prints a random line from the file 'file.txt'. //echo $read(file.txt) ; Prints line '10' from the file 'file,txt. //echo $read(file.txt, 10) ; Searches file 'file,txt for a line beginning with the text 'Hello World' and prints the text following the match value. //echo $read(file.txt, s, Hello World) ; Searches file 'file.txt' for a line matching the wildmatch '*Hello World*' and prints it. //echo $read(file.txt, w, *Hello World*)
$readn¶
Added in 1.9.0
$readn
Returns the line number that was matched in a previous call to $read. If no match was found, $readn is set to zero.
Example
; Read a random line from the file 'file.txt'. //noop $read(file.txt) ; Print the line number from the last $read. //echo -ag Line number from the last read was: $readn
$sdir¶
Added in 1.9.0
$sdir(dir,[title],[oktext])
Displays the select folder dialog and returns the selected folder.
Parameters
Parameter | Description |
dir | Starting folder in the folder dialog. |
[title] | Dialog title text. (optional) |
[oktext] | TODO (optional) |
Example
; Open the folder dialog. //echo -ag $sdir(c:\windows,Select Folder)
$sfile¶
Added in 1.9.0
$sfile(file,[title],[oktext])
Displays the select file dialog and returns the selected file.
Parameters
Parameter | Description |
file | Start filename filter in the file dialog. |
[title] | Dialog title text. (optional) |
[oktext] | TODO (optional) |
Example
; Open the file dialog. //echo -ag $sfile(*.*,Select File)
$sysdir¶
Added in 1.9.7
$sysdir(item)
Returns the system folder for the specified item.
Parameters
Parameter | Description |
item | The item to retrieve: profile, desktop, documents, downloads, music, pictures and videos. |
Example
; Retrieve the documents folder //echo -ag Documents folder is $sysdir(documents)
$fopen¶
Added in 1.9.0
$fopen(name|N)
Returns information about an open file.
See also /fopen, /fclose, /fwrite, /fseek, /flist, $fread, $fgetc, $feof, $ferr.
Parameters
Parameter | Description |
name|N | Name of an open file, If N = 0 number of open files, otherwise the Nth open file. |
Properties
Property | Description |
.fname | Returns the name associated with the file. |
.pos | Returns the current position in the file. |
.eof | Returns $true if the position is as the end of the file, otherwise $false. |
.err | TODO |
.line | Returns the current line position. (AdiIRC only) |
Example
; Open a file. /fopen Example Example.txt ; Print number of open files. //echo -ag $fopen(0) ; Print information about the 'Example' file. //echo -ag $fopen(Example) position is $fopen(Example).pos ; Close the file. /fclose Example
$fread¶
Added in 1.9.0
$fread(name|N)
Returns the next $crlf delimited line from an open file from the current position.
See also /fopen, /fclose, /fwrite, /fseek, /flist, $fgetc, $feof, $ferr, $fopen.
Parameters
Parameter | Description |
name|N | Name of the file or the Nth file. |
Properties
Property | Description |
.back | Returns the previous $crlf delimited line from an open file from the current position. (AdiIRC only) |
Example
; Open a file. /fopen Example Example.txt ; Add some text to the file. /fwrite Example Hello World ; Read the next line. //echo -ag Next line is: $fread(Example) ; Close the file. /fclose Example ; Delete the file. /remove Example
$fread(name|N, M, &binvar)
Reads M bytes from an open file to a &binvar.
Parameters
Parameter | Description |
name|N | Name of the file or the Nth file. |
M | Number of bytes to read from current position. |
&binvar | The &binvar to read into. |
Properties
Property | Description |
.back | Returns M bytes from an open file to a &binvar backwards. (AdiIRC only) |
$fgetc¶
Added in 1.9.0
$fgetc(name|N)
Returns the next character from current position in an open file.
See also /fopen, /fclose, /fwrite, /fseek, /flist, $fread, $feof, $ferr, $fopen.
Parameters
Parameter | Description |
name|N | Name of the file or the Nth file. |
Example
; Open a file. /fopen Example Example.txt ; Add some text to the file. /fwrite Example Hello World ; Read the next character. //echo -ag Next char is: $fgetc(Example) ; Close the file. /fclose Example ; Delete the file. /remove Example
$feof¶
Added in 1.9.0
$feof
Returns $true if end of file was reached during the last file access attempt, otherwise $false.
Can be used inside text without being surrounded by white spaces.
See also /fopen, /fclose, /fwrite, /fseek, /flist, $fread, $fgetc, $ferr, $fopen.
Example
; Open a file. /fopen Example Example.txt ; Add some text to the file. /fwrite Example Hello World ; Read the text. //echo -ag $fread(Example) ; Close the file. /fclose Example ; Delete the file. /remove Example ; Print the status from $feof. //echo -ag File $IIf($feof,was,was not) read to end
$ferr¶
Added in 1.9.0
$ferr
Returns any errors during the last file access attempt.
Can be used inside text without being surrounded by white spaces.
See also /fopen, /fclose, /fwrite, /fseek, /flist, $fread, $fgetc, $feof, $fopen.
Example
; Print the status from $ferr. //echo -ag Error was: $ferr
Updated by Per Amundsen almost 7 years ago · 13 revisions