User Tools

Site Tools


tryas_exception_casting_.htm
Navigation:  Clarion.Net (Clarion#) > Clarion# Language Extensions > Operators >====== TRYAS (explicit type conversion) ====== Previous pageReturn to chapter overviewNext page

NewCNet.jpg

<;expression> TRYAS <;type>

TRYAS used for explicit casting.
type the signature of a type

blk2blue.jpg

Although Clarion performs type conversions implicitly, there are times when you may need to perform an explicit conversion. The AS and TRYAS keywords are used to perform explicit conversions between compatible types.

TRYAS uses Clarion Type Conversion rules for the casting of value-types, but throws an exception if the casting is impossible, but AS will return null in this case.

AS and TRYAS operators are new to Clarion .NET. These operators are used for explicit casting. The syntax is following:

Both operators try to cast the specified expression to the given type. The difference between these operators is the following:

' TRYAS throws an exception if the casting is impossible, but AS return null in this case.

' AS operator doesn't accept value-types for <;type>

Also, TRYAS uses Clarion Type Conversion rules for the casting of value-types.

Example:

A LONG

 CODE

 A = ('10' &amp; '20') TRYAS LONG   !  Casting to long

See Also: AS (Explicit type conversion)

tryas_exception_casting_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1