Programming Reference Manual
 
SYNTAX: Public Declare Function|Sub name Lib "ADMLIB58.DLL" (parameters) As type
 
DESCRIPTION: ADMLIB58 is a system library providing utility functions for file handling, string operations, validation, numeric conversion, date/time formatting, SQL query building, RTF formatting, array manipulation, and system information. Functions are accessed via the standard Declare statement. All functions are compatible with both Tradium Basic Script and CCL. The declaration file can easily be included, using #Uses.  A summary of available endpoints (or Subs and Functions) is specified below.
 

File Operations

 

CheckBackSlash



Syntax
CheckBackSlash(PathSpec$)
Description
Ensures that a path string ends with a trailing backslash. If the backslash is already present, the path is returned unchanged.



Parameter

PathSpec$
Returns
String
Example
Dim sPath As String
sPath = CheckBackSlash("C:\Data")
' Result: "C:\Data\"
 

ExtractDir



Syntax
ExtractDir(FileName$)
Description
Returns the directory path from a fully qualified file name, without the file name portion.



Parameter

FileName$
Returns
String
Example
Dim sDir As String
sDir = ExtractDir("C:\Data\report.doc")
' Result: "C:\Data"
 

ShortName



Syntax
ShortName(LongName$)
Description
Returns the abbreviated DOS 8.3 file name from a long Windows file name.



Parameter

LongName$
Returns
String
 

ValidateFileName



Syntax
ValidateFileName(Work$ [, MatchCase])
Description
Replaces characters that are invalid in file names with underscores.



Parameter

Work$

MatchCase
Returns
String
 

LangTemplate



Syntax
LangTemplate(DocTemplate, LanguageCode)
Description
Searches for a language-specific variant of a document template. For example, given "offerte.rtf" and language code "EN", it looks for "offerte_EN.rtf". Returns the original file if no variant is found, or if the language code is empty or "<STD>".



Parameter

DocTemplate$

LanguageCode$
Returns
String
 

LoadStringFromFile



Syntax
LoadStringFromFile(FileName$)
Description
Loads the complete contents of a text file into a string. Returns an empty string if the file does not exist or is empty.



Parameter

FileName$
Returns
String
 

SaveStringToFile



Syntax
SaveStringToFile FileName,FileData
Description
Writes a string to a file. If the file already exists, it is overwritten.



Parameter

FileName$

FileData$
 

CheckDrive



Syntax
CheckDrive(Letter$)
Description
Checks whether a drive letter is available and accessible.



Parameter

Letter$
Returns
Boolean. True if the drive exists.
 

ANOfile



Syntax
ANOfile(ImageFileName$)
Description
Generates the annotation file name corresponding to an image file by replacing the extension separator with an underscore and appending ".ano".



Parameter

ImageFileName$
Returns
String
Example
Debug.Print ANOfile("c:\fax.tiff")
' Result: "c:\fax_tiff.ano"
 

File Type Detection

 
The following functions check whether a file matches a specific type, based on the file extension and/or internal structure (magic bytes). All return Boolean (True or False).
Function
Syntax
Detected types
IsMailDoc
IsMailDoc(FileName$)
.msg, .eml
IsRTFdoc
IsRTFdoc(FileName$)
.rtf, .twrd
IsExceldoc
IsExceldoc(FileName$)
.xls, .xlsx
IsTiffDoc
IsTiffDoc(FileName$)
.tif, .tiff (verified by magic bytes)
IsPDFDoc
IsPDFDoc(FileName$)
.pdf (verified by magic bytes)
IsZPLDoc
IsZPLDoc(FileName$)
.zpl (Zebra label printer format)
IsWordDoc
IsWordDoc(FileName$)
.doc, .docx, .dot, .dotx (verified by magic bytes)
IsJPGDoc
IsJPGDoc(FileName$)
JPEG (verified by magic bytes)
IsBMPDoc
IsBMPDoc(FileName$)
BMP (verified by magic bytes)
IsPNGDoc
IsPNGDoc(FileName$)
PNG (verified by magic bytes)
IsHTML
IsHTML(sText$)
Detects HTML markup in a string
IsRTFstring
IsRTFstring(Work$)
Detects RTF markup in a string
 

String Operations

 

ReplaceString



Syntax
ReplaceString Work, OldStr, NewStr$[, NumCount&][, Reloop]
Description
Replaces occurrences of *OldStr*with*NewStr* with *NewStr *with*NewStr* in *Work$*. The search is case-insensitive. The source string is modified in place (ByRef).



Parameter

Work$

OldStr$

NewStr$

NumCount&

Reloop
Example
Dim s As String
s = "Hello World"
ReplaceString s, " ", " ", 0, True
' Result: "Hello World"
 

CleanUpString



Syntax
CleanUpString(Work$ [, MatchCase])
Description
Removes all characters that are not letters, digits, spaces, or common punctuation (.,@&-()/:). Invalid characters are replaced by spaces.



Parameter

Work$

MatchCase
Returns
String
 

CleanQuotes



Syntax
CleanQuotes(FileName$ [, IsPath])
Description
Strips leading and trailing double quotes from a string. When IsPath is True, a trailing backslash is appended.



Parameter

FileName$

IsPath
Returns
String
 

ReadUntil



Syntax
ReadUntil( Work, Delimiter)
Description
Returns the portion of *Work*beforethefirstoccurrenceof*Delimiter* before the first occurrence of *Delimiter *beforethefirstoccurrenceof*Delimiter*. The original string is modified: the returned portion and the delimiter are removed.



Parameter

Work$

Delimiter$
Returns
String
Example
Dim s As String
s = "name=John;age=30"
Debug.Print ReadUntil(s, ";")
' Prints: "name=John"
' s is now: "age=30"
 

WordWrap



Syntax
WordWrap( Text, NumChars&, WrapChars)
Description
Inserts line breaks at word boundaries when a line exceeds the specified width.



Parameter

Text$

NumChars&

WrapChars$
Returns
String
 

Wrapped



Syntax
Wrapped(MyText$ [, LineWidth&])
Description
Reformats text so that no line exceeds the specified width. Default is 75 characters.



Parameter

MyText$

LineWidth&
Returns
String
 

Decode



Syntax
Decode(ArtCode$)
Description
Decodes a previously encoded character string by converting each character to its numeric ASCII representation.
Returns
String
 

BuildString



Syntax
BuildString(BufSize&, WorkString$)
Description
Efficiently builds large strings using pre-allocated memory. Call in three phases: (1) BufSize > 0 to initialize the buffer, (2) BufSize = 0 to append text, (3) BufSize < 0 to retrieve the result. After each call, BufSize contains the current string length.



Parameter

BufSize&

WorkString$
Returns
String (only when BufSize < 0).
 

HexString



Syntax
HexString(Work$)
Description
Interprets hexadecimal codes embedded in a string. Hex sequences use the syntax {xx,xx,...,xx} where xx is a hexadecimal value. Example: {1B,0D} becomes Escape + CR.
Returns
String
 

Hex2String



Syntax
Hex2String(HexValue$)
Description
Converts a hexadecimal string to its ASCII equivalent. Example: "48656C6C6F" becomes "Hello".
Returns
String
 

String2Hex



Syntax
String2Hex(StringValue$)
Description
Converts an ASCII string to its hexadecimal representation. Example: "Hello" becomes "48656C6C6F".
Returns
String
 

ExtractBetween



Syntax
ExtractBetween(Source, Start, Terminator$)
Description
Extracts the text between two delimiters (case-insensitive). If no terminator is found, returns everything after the start delimiter.



Parameter

Source$

Start$

Terminator$
Returns
String
Example
Debug.Print ExtractBetween("Order [12345] confirmed", "[", "]")
' Result: "12345"
 

Validation

 

IsNumber



Syntax
IsNumber(Work$ [, AllowNegative])
Description
Checks whether a string contains only digits (0–9). Optionally accepts a leading minus sign.



Parameter

Work$

AllowNegative
Returns
Boolean
 

IsHexString



Syntax
IsHexString(Work$)
Description
Checks whether a string is a valid hexadecimal value (0–9, A–F). Case-insensitive.
Returns
Boolean
 

IsCharString



Syntax
IsCharString(Work$ [, MatchCase])
Description
Checks whether a string contains only alphanumeric characters (A–Z, 0–9), with no spaces or special characters.
Returns
Boolean
 

ValidEmailAddress



Syntax
ValidEmailAddress(MailAddress$)
Description
Checks whether a string conforms to the basic e-mail address format (contains @ with a dot after it).
Returns
Boolean
 

ValidPostalCode



Syntax
ValidPostalCode(PCSearch$)
Description
Checks whether a string conforms to the Dutch postal code format (4 digits + 2 letters, with optional house number).
Returns
Boolean
 

ValidatePhoneNumber



Syntax
ValidatePhoneNumber(PhoneNum$ [, AllowText])
Description
Normalizes and validates a phone number by stripping formatting characters (spaces, hyphens, parentheses). Returns the cleaned number, or an empty string if invalid.



Parameter

PhoneNum$

AllowText
Returns
String
 

Numeric Conversion

 

CVCur



Syntax
CVCur(Value)
Description
Locale-independent conversion of a variant, string, or database field to a Double value. Automatically detects whether a comma or period is used as the decimal separator. Handles negative values and percentages.



Parameter

Value
Returns
Double
Example
Debug.Print CVCur("1.234,56")
' Result: 1234.56
Debug.Print CVCur("-25%")
' Result: -25
 

Opslag



Syntax
Opslag(Price@, Perc!)
Description
Calculates a selling price based on a net margin percentage. The percentage represents the desired net margin, not the markup.



Parameter

Price@

Perc!
Returns
Currency
Example
Debug.Print Opslag(100, 25)
' Result: 133.33 (25% net margin)
 

LocalDecimalSign



Syntax
LocalDecimalSign()
Description
Returns the decimal separator character from the current Windows regional settings ("," or ".").
Returns
String
 

EnglishValue



Syntax
EnglishValue(Value [, Decimals%])
Description
Converts a numeric value to a string with a period as decimal separator, suitable for SQL queries. Accepts variants, strings, and ADODB field objects.



Parameter

Value

Decimals%
Returns
String
 

Date and Time

 

SQLDate



Syntax
SQLDate(DateValue [, DenyTimePart] [, UseMinimumTimeValue] [, UseMaximumTimeValue])
Description
Converts a date value to a SQL-validated string in the format 'yyyy-mm-dd hh:nn:ss.mmm'. Accepts variants, strings, and ADODB field objects.



Parameter

DateValue

DenyTimePart

UseMinimumTimeValue

UseMaximumTimeValue
Returns
String
 

ISOWeekNum



Syntax
ISOWeekNum(wYear&, wMonth&, wDay%)
Description
Returns the ISO-compliant week number for a given date.
Returns
Long
 

Minutes2Time



Syntax
Minutes2Time(Minutes [, OnlyMinutes])
Description
Converts a number of minutes to a time string. Accepts integer values, variants, and ADODB field objects.



Parameter

Minutes

OnlyMinutes
Returns
String
 

Time2Minutes



Syntax
Time2Minutes(MyTime)
Description
Converts a time value to total minutes. Accepts strings ("HH:MM"), VB Date/Time variants, and ADODB field objects.



Parameter

MyTime
Returns
Integer
 

CleanDate



Syntax
CleanDate(DateValue, DefaultDate)
Description
Validates a date value. Returns the date as a string, or the specified default if the value is null, empty, or invalid.



Parameter

DateValue

DefaultDate
Returns
String
 

SQL Query Building

 

SQLText



Syntax
SQLText(Work$ [, UseWild] [, UseRTF])
Description
Prepares a string for use in a SQL query by escaping single quotes. Optionally adds LIKE wildcards or converts line breaks to RTF equivalents.



Parameter

Work$

UseWild

UseRTF
Returns
String (including surrounding single quotes).
Example
Dim q As String
q = "SELECT * FROM customers WHERE name = " & SQLText("O'Brien")
' Result: "... name = 'O''Brien'"
 

SQLCurText



Syntax
SQLCurText(Expression, Rate# [, OutputName ])
Description
Generates a SQL expression that converts a field value to a different currency using the specified exchange rate. Suitable for use in SELECT clauses.
Returns
String
 

SQLFROM



Syntax
SQLFROM(TableName [,Alias [, WithRowLock] [, NoLockingHints])
Description
Generates a FROM clause with the appropriate locking hints. By default, applies WITH (READUNCOMMITTED). Table-valued functions and subqueries are automatically detected and excluded from locking hints.



Parameter

TableName$

Alias$

WithRowLock

NoLockingHints
Returns
String
 

SQLDELETE



Syntax
SQLDELETE(TableName$ [, NoLockingHints])
Description
Generates a DELETE FROM clause with ROWLOCK hint.



Parameter

TableName$

NoLockingHints
Returns
String
 

SortedQuery



Syntax
SortedQuery( Query, SortKeys)
Description
Replaces or appends an ORDER BY clause in an existing SQL query string.
Returns
String
 

FilterQuery



Syntax
FilterQuery(SourceName$)
Description
Extracts the FROM portion of a SQL query, including any GROUP BY or ORDER BY clause.
Returns
String
 

SearchQuery



Syntax
SearchQuery(Search, FieldNames() )
Description
Builds a WHERE clause for searching across multiple fields using LIKE wildcards. Supports special prefixes: = (all words must match), ~ (include Dutch spelling variants), ! (exact word boundaries), - per word (exclude), + per word (required).



Parameter

Search$

FieldNames$()
Returns
String
 

SearchPostalCode



Syntax
SearchPostalCode(PCSearch ,AddressField , ZipCodeField$)
Description
Builds a WHERE clause for searching by Dutch postal code and optional house number.
Returns
String. Returns "ERR:..." if the postal code format is invalid.
 

Boolean Conversion

 

YesNoValue



Syntax
YesNoValue(Value)
Description
Evaluates a variant to a boolean. Recognizes: True/False, Yes/No, Ja/Nee, Waar/Onwaar, and numeric values (0 = False, non-zero = True). Accepts ADODB field objects.
Returns
Boolean
 

RTF Formatting

 
Function
Syntax
Description
RTF_BOLD
RTF_BOLD([Text$])
Applies bold formatting. Without text, returns the opening tag only.
RTF_ITALIC
RTF_ITALIC([Text$])
Applies italic formatting.
RTF_UNDERLINE
RTF_UNDERLINE([Text$])
Applies underline formatting.
RTF_STRIKE
RTF_STRIKE([Text$])
Applies strikethrough formatting.
RTF_FONT
RTF_FONT(Size& [, Text$])
Sets the font size (in half-points).
CrLfToRTF
CrLfToRTF(Text$)
Converts CR/LF line breaks to RTF paragraph markers (\par).
RTFToCrLf
RTFToCrLf(Text$)
Converts RTF paragraph markers to CR/LF line breaks.
StringToHex
StringToHex(Text$)
Converts a string to RTF Unicode hex codes.
 

Address and Formatting

 

KIXCode



Syntax
KIXCode(AddressField , ZipCodeField)
Description
Generates a KIX barcode string for PostNL address labels, based on the postal code and house number extracted from the address.
Returns
String
 

FormatName



Syntax
FormatName(Name$)
Description
Converts a name from "Last, First" format to "First Last" format.
Returns
String
Example
Debug.Print FormatName("Jansen, Pieter")
' Result: "Pieter Jansen"
 

E-Mail Parsing

 
Function
Syntax
Description
MailExtractAddressee
MailExtractAddressee(Message$)
Extracts the To/Aan field from a plain-text e-mail message.
MailExtractSender
MailExtractSender(Message$)
Extracts the Reply-To or From field.
MailExtractSubject
MailExtractSubject(Message$)
Extracts the Subject/Onderwerp field.
 

Compression (requires ZLIB.DLL)

 

CompressString



Syntax
CompressString(TheString$)
Description
Compresses a string using zlib deflate. The original length is prepended (4 bytes) for decompression. The source string is replaced with the compressed result (ByRef).
Returns
Long. 0 = success.
 

DecompressString



Syntax
DecompressString(TheString$)
Description
Decompresses a previously compressed string. The source string is replaced with the decompressed result (ByRef).
Returns
Long. 0 = success.
 

Array Operations

 
Function
Syntax
Description
SortString
SortString Arr$()
Sorts a string array in ascending order.
SortInt
SortInt Arr%()
Sorts an integer array in ascending order.
SortLong
SortLong Arr&()
Sorts a long integer array in ascending order.
SortSingle
SortSingle Arr!()
Sorts a single-precision array in ascending order.
SortDouble
SortDouble Arr#()
Sorts a double-precision array in ascending order.
SortCurrency
SortCurrency Arr@()
Sorts a currency array in ascending order.
 

ScanString



Syntax
ScanString(Arr(), FirstEl&, NumEls&, Work [, DeleteIfFound])
Description
Searches a string array (case-insensitive). Optionally deletes the found element and decrements the element count.



Parameter

Arr$()

FirstEl&

NumEls&

Work$

DeleteIfFound
Returns
Long. Position (1-based) or 0 if not found.
 

InsertString



Syntax
InsertString Arr(), Position&, Work 
Description
Inserts a string element at the specified position, shifting subsequent elements. The array must have sufficient capacity.
 

DeleteString



Syntax
DeleteString Arr$(), Position&
Description
Removes the element at the specified position, shifting subsequent elements. The last element becomes an empty string. Array bounds remain unchanged.
 

Conv2Word



Syntax
Conv2Word Text, Arr(), WNum& [, SepChar$]
Description
Splits a text string into individual words and fills an array. Supports quoted strings as single words.



Parameter

Text$

Arr$()

WNum&

SepChar$
 

INI File

 

ReadIni



Syntax
ReadIni(AppName, KeyName, [, AltFileName$])
Description
Reads a value from an INI file. Without AltFileName$, reads from the default Tradium INI file (ADMINSQL.INI in the Windows directory).
Returns
String
 

WriteIni



Syntax
WriteIni AppName, KeyName, Value [, AltFileName ]
Description
Writes a value to an INI file. Without AltFileName$, writes to the default Tradium INI file.
 

System Information

 
Function
Syntax
Description
isHost64bit
isHost64bit()
Returns True if the operating system is 64-bit.
GetWinVersion
GetWinVersion()
Returns the Windows version number as a string.
GetWinPlatform
GetWinPlatform()
Returns the Windows platform type.
GetFileVersion
GetFileVersion(FileName$)
Returns the version information string of a DLL, OCX, or EXE.
WinDir
WinDir()
Returns the Windows directory (e.g. "C:\Windows").
WinSysDir
WinSysDir()
Returns the System32 directory.
WinKey
WinKey()
Returns True if a Windows product key is present in the registry.
CreateGUID
CreateGUID()
Generates a unique 128-bit GUID as a 38-character string.
ErrorMessageText
ErrorMessageText(ErrorCode& [, DefaultMsg$])
Returns the Windows error message for a given error code.
FileCopyBoot
FileCopyBoot(FileFrom , FileTo)
Schedules a file copy for the next Windows restart. Returns 0 on success.
CloseForm
CloseForm hWnd&
Closes a window by its handle.
GetVolumeID
GetVolumeID(Root, Serial&, Name)
Reads the serial number and volume name of a disk drive.
 

Serial Communication

 

SendToComm



Syntax
SendToComm(Handle&, Data$)
Description
Sends data to a serial port. On first call (Handle = 0), opens the port using the specified settings string. With an empty data string, closes the port.



Parameter

Handle&

Data$
Returns
Long. The port handle, or 0 on error/close.
Example
Dim h As Long
h = SendToComm(0, "COM1,9600,n,8,1")
SendToComm h, "Hello printer"
SendToComm h, "" ' close
 

ReadFromComm



Syntax
ReadFromComm(Handle&, RecvData$)
Description
Reads available data from an open serial port.



Parameter

Handle&

RecvData$
Returns
Long. Number of bytes read, or -1 on error.
 

SEE ALSO: Declare, QPRO32 System Library