Skip to content

Conversion Functions

Asc

Returns the NUMBER code that represents the specific character.

Syntax

Asc( string )

Arguments

  • string
    • The specified character to retrieve the NUMBER code for. If more than one character is entered, the function will return the value for the first character and ignore all of the characters after the first.

Example

Asc("A")   ' Returns 65

Base64DecodeText

Decocdes a textual value encoded in Base64 form.

This function is often used in webservice type integrations, where a Base64 encoded value is returned from a service.

Syntax

Base64DecodeText( value )

Arguments

  • value
    • The Base64 encoded value.

Example

' IMan-specific. The inverse of Base64EncodeText; UTF-8
' throughout. An empty input returns an empty string
' rather than erroring.
Base64DecodeText("QUNNRTAwMQ==")   ' Returns "ACME001"

Base64EncodeBinary

Base64 encode a binary value such as an image (png, jpg, gif) or document (pdf).

This function is often used in webservice type integrations, where a Base64 encoded value is required to post to a service.

This function should often be used with the WebserviceGetBinary Function function to encode the result to a usable format.

Syntax

Base64EncodeBinary( value )

Arguments

  • value
    • The binary value.

Example

' IMan-specific. Takes a binary field's value, not text
' -- anything else raises a conversion error. Use it to
' put an attachment that is already in the dataset into
' a JSON or XML webservice payload.
Base64EncodeBinary(%DocumentImage)

Base64EncodeFile

Base64 encodes the contents of a file.

This function is often used in webservice type integrations, where a Base64 encoded value is required to post to a service.

This function can be used to upload images to a webservice, assuming it requires a Base64 encoded representation of the image (such as the Shopify Product Image upload).

Syntax

Base64EncodeFile ( file [, throwonerror])

Arguments

  • file

    • The path to the file.
  • throwonerror

    • Optional. When set to False the function will return an empty string instead of raising an error when an error occurs either opening or reading the file.

Example

' IMan-specific. Reads a file and returns its Base64
' encoding. The second argument is throwOnError: leave
' it False and an unreadable file yields an empty
' string, so the integration continues.
Base64EncodeFile("C:\IMan\Outbound\SO-10432.pdf", False)

' A FileSystem setup can be named FIRST, in which case
' the path is resolved through it -- Azure Blob, OneDrive
' or S3 -- rather than against the IMan server's own
' filesystem. The container comes from the setup.
Base64EncodeFile("AzureBlob-Archive", "outbound/SO-10432.pdf", True)

Base64EncodeText

Base64 encodes a textual value.

This function is often used in webservice type integrations, where a Base64 encoded value is required to post to a service.

Syntax

Base64EncodeBinary( value )

Arguments

  • value
    • The textual value.

Example

' IMan-specific. UTF-8 in, Base64 out.
Base64EncodeText(%CustomerCode)   ' "ACME001" returns "QUNNRTAwMQ=="

CBool

Converts a value to a boolean.

Syntax

CBool( expression )

Arguments

  • expression
    • Any valid expression. If expression is zero, False is returned; otherwise, True is returned. If expression can't be interpreted as a numeric value, a run-time error occurs.

Example

' Zero is False, every other number is True.
CBool(%Qty)   ' 10 returns True; 0 returns False

CByte

converts a value to a byte. (ie: number between 0 and 255).

Use the CByte function to provide conversions from any data type to a Byte subtype. For example, CByte forces byte arithmetic when currency, single-precision, double-precision, or integer arithmetic would normally occur.

The CByte function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

Syntax

CByte( expression )

Arguments

  • expression
    • Any valid expression. If expression lies outside the acceptable range for the byte subtype, an error occurs.

Example

' 0 to 255 only, and it rounds rather than truncating.
CByte(12.6)   ' Returns 13

CCur

Use the CCur function to provide conversions from any data type to a Currency subtype. For example, CCur forces currency arithmetic when integer arithmetic would normally occur.

The CCur function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized, depending on the locale setting, as are different thousand separators.

Description

Returns an expression that has been converted to a Variant of subtype Currency.

Syntax

CCur( expression )

Arguments

  • expression
    • Any valid expression.

Example

' Fixes the value at four decimal places, which is what
' stops repeated arithmetic on a Double drifting a penny
' out over a long order.
CCur("948.00")   ' Returns 948

CDate

Use the IsDate function to determine if date can be converted to a date or time. CDate recognizes date literals and time literals as well as some numbers that fall within the range of acceptable dates. When converting a number to a date, the whole number portion is converted to a date. Any fractional part of the number is converted to a time of day, starting at midnight.

CDate recognizes date formats according to the locale setting of your system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings. In addition, a long date format is not recognized if it also contains the day-of-the-week string.

Description

Returns an expression that has been converted to a Variant of subtype Date.

Syntax

CDate( date )

Arguments

  • date
    • Any valid date expression.

Example

' Parsed using the IMan server's locale, so "12/03/2026"
' is 12 March on a UK server and 3 December on a US one.
' Test IsDate first if the source cannot be trusted.
CDate("12/03/2026")   ' Returns 12/03/2026 on a UK server

CDbl

Use the CDbl function to provide conversions from any data type to a Double subtype. For example, CDbl forces double-precision arithmetic when currency or integer arithmetic would normally occur.

The CDbl function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

Description

Returns an expression that has been converted to a Variant of subtype Double.

Syntax

CDbl( expression )

Arguments

  • expression
    • Any valid expression.

Example

' Prices arriving as text from a CSV or webservice need
' this before arithmetic, or "35.00" & 1 concatenates
' instead of adding.
CDbl(%UnitPrice) * %Qty   ' "35.00" and 10 return 350

Chr

Description

Returns the character based on the number code.

Syntax

Chr( number_code )

Arguments

  • number_code
    • The NUMBER used to retrieve the character.

Example

' Chr(9) is a tab, Chr(13) & Chr(10) a Windows line
' break.
Chr(65)   ' Returns "A"

ChrW

Description

Returns the unicode character based on the number code.

Some Unicode characters can be difficult represent, enter or are non-visible. This function allows you to represent (or return) any Unicode character through its decimal value.

Syntax

ChrW( number_code )

Arguments

  • number_code
    • The Unicode decimal NUMBER used to retrieve the character.

Example

ChrW(2032)
' Returns the Unicode Prime (′) character.
ChrW(8206)
' Returns the non-printable Unicode Left-To-Right Mark.
ChrW(39277)
' Returns the chinese symbol 饭.

CInt

Use the CInt function to provide conversions from any other data type to an Integer subtype. For example, CInt forces integer arithmetic when currency, single-precision, or double-precision arithmetic would normally occur.

The CInt function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

If expression lies outside the acceptable range for the Integer subtype, an error occurs.

Description

Returns an expression that has been converted to a Variant of subtype Integer.

Syntax

CInt( expression )

Arguments

  • expression
    • Any valid expression.

Example

' -32,768 to 32,767, and it uses banker's rounding:
' exact halves go to the nearest EVEN number.
CInt(%Qty)   ' "10" returns 10
CInt(2.5)    ' Returns 2
CInt(3.5)    ' Returns 4

CLng

Use the CLng function to provide conversions from any data type to a Long subtype. For example, CLng forces integer arithmetic when currency, single-precision, or double-precision arithmetic would normally occur.

The CLng function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

If expression lies outside the acceptable range for the Long subtype, an error occurs.

Description

Returns an expression that has been converted to a Variant of subtype Long.

Syntax

CLng( expression )

Arguments

  • expression
    • Any valid expression.

Example

' Same rounding as CInt, but the full 32-bit range.
CLng(35000.6)   ' Returns 35001

CSng

Use the CSng function to provide conversions from any data type to a Single subtype. For example, CSng forces single-precision arithmetic when currency or integer arithmetic would normally occur.

The CSng function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

If expression lies outside the acceptable range for the Single subtype, an error occurs.

Description

Returns an expression that has been converted to a Variant of subtype Single.

Syntax

CSng( expression )

Arguments

  • expression
    • Any valid expression.

Example

' Single precision. Prefer CDbl or CCur for money --
' Single carries roughly seven significant digits, which
' a large order total exceeds.
CSng(%UnitPrice)   ' "35.00" returns 35

CStr

Use the CStr function to provide conversions from any data type to a String subtype. CStr forces the results to be expressed as a String.

The CStr function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized, depending on the locale setting.

The data in expression determines what is returned according to the following expressions:

Description

Returns an expression that has been converted to a Variant of subtype String.

  • Boolean
    • A String containing True or False.
  • Date
    • A String containing a date in the short-date format of your system.
  • Null
    • A run-time error.
  • Empty
    • A zero-length String ("").
  • Error
    • A String containing the word Error followed by the error number.
  • Other numeric
    • A String containing the number.

Syntax

CStr( expression )

Arguments

  • expression
    • Any valid expression.

Example

' Forces a number to text, so & concatenates rather than
' adding.
CStr(%Qty) & " x " & %ItemCode   ' Returns "10 x ACME-4471-BLU"

Hex

Description

Returns a string representing the hexadecimal value of a number.

Syntax

Hex(number)

Arguments

  • number
    • Any valid expression. If number is not a whole number, it is rounded to the nearest whole number before the number is evaluated.

Example

Hex(255)   ' Returns "FF"

IsNumeric

Description

Returns a Boolean value indicating whether an expression can be evaluated as a number.

Syntax

IsNumeric(expression)

Arguments

  • expression
    • Any valid expression.

Example

' Test before casting: CDbl on non-numeric text raises a
' type mismatch and fails the record.
If IsNumeric(%UnitPrice) Then
  CDbl(%UnitPrice)
Else
  0
End If   ' "35.00" returns 35; "N/A" returns 0

Oct

Description

Returns a string representing the octal value of a number.

Syntax

Oct(number)

Arguments

  • number
    • Any valid expression. If number is not already a whole number, it is rounded to the nearest whole number before being evaluated.

Example

Oct(8)   ' Returns "10"