0.2.2 • Published 1 year ago

rd-utility-ahk v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Class rd_Utility

Installation

In a terminal or command line, navigate to your project folder:

npm install rd-utility-ahk

In your code include the following:

#Include, %A_ScriptDir%\node_modules\rd-regexp-ahk\rd_RegExp.ahk
#Include, %A_ScriptDir%\node_modules\rd-utility-ahk\rd_Utility.ahk

U := new rd_Utility()

Description

rd_Utility is a utility class providing string, file and miscellaneous methods for Autohotkey.

All methods have function comments and if you're looking for examples check out the tests.

If you use the VS Code AutoHotkey Plus Plus extension, you might also want to check out Peak Definition (Alt+F12) or Go To Definition (F12).

These classes will throw an exception in case of a serious error by default which works well in combination with a global error handler. This behavior can be changed by setting rd_Utility.throwExceptions := false.

Methods

String Methods

MethodDescription
convertToWrapConverts formatted paragraphs with (CR)LF to wrap
uriEncodeUri encode (JavaScript like)
uriDecodeUri decode (JavaScript like)
putVarCopies string to memory address, UTF-16 compatible
expandEnvVarsExpands all environment variables stored in string
expandAhkVarsExpands all A_ variables stored in string
expandVariablesExpands ${varname} variables in string
splitPathSplits path (Windows, URI) to object
buildFileNameChange properties in path name (Windows, URI)
formatDateTimeTransforms a time stamp into a specified date/time format

String Methods With Better Unicode Support

These string methods are experimental and handle Unicode surrogate pairs better than their corresponding Autohotkey functions:

This comes with a speed penalty though, see a benchmark here.

MethodDescription
strLengthReturns string length, Handles Unicode surrogate pairs better than Strlen
strToArrayConverts string to array, handles Unicode surrogate pairs better than StrSplit
substringRetrieves part of string, handles Unicode surrogate pairs better than Substr

File Methods

MethodDescription
fileReadRead contents of text file into variable
fileWriteWrites string to file (overwrites existing, preserves hard links)
fileAppendAppends string to file
fileTouchCreates empty file or updates modification date
createUniqueFileCreates empty file with unique name
getFullPathNameRetrieves full path name via Windows API

Misc Methods

MethodDescription
parseIntConverts string to integer
getWindowsErrorTextRetrieves Windows error message text for error number (A_LastError)
defaultToChecks value to determine whether a default value should be returned in its place
0.2.2

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago