Index  |  Related pages  |  Classes  |  Functions  |  Entities  |  Function Sets  |  Groups

Function set generic_item_api

Functions managing item conversions, type detection, item structure management and generically manipulating Falcon items.


Function list

chr Returns a string containing a single character that corresponds to the given number.
getProperty Returns the value of a property in an object.
int Converts the given parameter to integer.
isCallable Determines if an item is callable.
len Retreives the lenght of a collection
numeric Converts the given parameter to numeric.
ord Returns the numeric UNICODE ID of a given character.
setProperty
toString Returns a string representation of the item.
typeOf Returns an integer indicating the type of an item.

Functions

chr()

Returns a string containing a single character that corresponds to the given number.

chr( number )
number

Numeric code of the desired character

Returns:

a single-char string.

This function returns a single character string whose only character is the UNICODE equivalent for the given number. The number must be a valid UNICODE character, so it must be in range 0-0xFFFFFFFF.

getProperty()

Returns the value of a property in an object.

getProperty( obj, propName )
obj

the source object

propName

A string representing the name of a property or a method inside the object.

Returns:

the property

Raises:
AccessError

if the property can't be found.

An item representing the property is returned. The returned value is actually a copy of the property; assigning a new value to it won't have any effect on the original object.

If the property is a method, a callable method item is returned. If the property is not found, an error of class RangeError is raised.

int()

Converts the given parameter to integer.

int( item )
item

The item to be converted

Returns:

An integer value.

Raises:
ParseError

in case the given string cannot be converted to an integer.

MathError

if a given floating point value is too large to be converted to an integer.

Integer values are just copied. Floating point values are converted to long integer; in case they are too big to be prepresented a RangeError is raised. Strings are converted from base 10. If the string cannot be converted, or if the value is anything else, a MathError instance is raised.

isCallable()

Determines if an item is callable.

isCallable( item )
item

The item to be converted

Returns:

true if the item is callable, false otheriwse.

If the function returns true, then the call operator can be applied. If it returns false, the item is not a callable one, and trying to call it would cause an error.

len()

Retreives the lenght of a collection

len( item )
item

an item of any kind

Returns:

the count of items in the sequence, or 0.

The returned value represent the "size" of the item passed as a parameter. The number is consistent with the object type: in case of a string, it represents the count of characters, in case of arrays or dictionaries it represents the number of elements, in all the other cases the returned value is 0.

numeric()

Converts the given parameter to numeric.

numeric( item )
item

The item to be converted

Returns:

A numeric value.

Raises:
ParseError

in case the given string cannot be converted to an integer.

MathError

if a given floating point value is too large to be converted to an integer.

Floating point values are just copied. Integer values are converted to floating point; in case of very large integers, precision may be lost. Strings are converted from base 10. If the string cannot be converted, or if the value is anything else, a MathError instance is raised.

ord()

Returns the numeric UNICODE ID of a given character.

ord( string )
string

The character for which the ID is requested.

Returns:

the UNICODE value of the first element in the string.

The first character in string is taken, and it's numeric ID is returned.

See also chr.

setProperty()

setProperty( obj, propName, value )
obj

The source object.

propName

A string representing the name of a property or a method inside the object.

value

The property new value.

Raises:
AccessError

If the property can't be found.

Alters the value of the property in the given object. If the required property is not present, an AccessError is raised.

toString()

Returns a string representation of the item.

toString( item, [numprec] )
item

The item to be converted to string.

numprec

Number of significative decimals for numeric items.

Returns:

the string representation of the item.

This function is useful to convert an unknown value in a string. The item may be any kind of Falcon item; the following rules apply:

This function is not meant to provide complex applications with pretty-print facilities, but just to provide simple scripts with a simple and consistent output facility.

See also Format.

typeOf()

Returns an integer indicating the type of an item.

typeOf( item )
item

An item of any kind.

Returns:

A constant indicating the type of the item.

The typeId returned is an integer; the Falcon compiler is fed with a set of compile time constants that can be used to determine the type of an item. Those constants are always available at Falcon sources.

The value returned may be one of the following:


Index  |  Related pages  |  Classes  |  Functions  |  Entities  |  Function Sets  |  Groups
Made with Faldoc 1.0.0