User Tools

Site Tools


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

NewCNet.jpg

<;expression> AS <;type>

AS Used for explicit casting
type 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.

AS and TRYAS operators are used for explicit casting. 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.

Both AS and TRYAS 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: TRYAS (Explicit type conversion)

as_null_casting_.htm.txt · Last modified: 2021/04/15 15:56 by 127.0.0.1