Component: Type Conversions (Calculation)

From Flowcode Help
Jump to navigationJump to search
Author Matrix TSL
Version 1.0
Category Calculation


Type Conversions component

Component to simplify the task of converting data into different bit type variables. Allows conversion between Bytes, Ints, Longs and Floats. Useful when you need to store Ints, Longs and Floats into Byte based memory. Uses a simple 32-bit C Union to overlay the following variable types into the same RAM space. Byte[4], Int[2], Long, Float

Component Source Code

Please click here to download the component source project: FC_Comp_Source_TypeConversions.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_TypeConversions.fcfx

Detailed description

The type conversion component overlays several variable types on top of each other using a C code union.

This allows for very efficient conversion between data types without resorting to costly mathematics or bit shifting operations.


Here is an overview of the variable overlay.

Type Conversion Overlay Map

Examples

No additional examples






Macro reference

GetByte

Fc9-comp-macro.png GetByte
Gets a single 8-bit BYTE value. Index is in little endian, 0 is the LSB and 3 is the MSB 
Fc9-u8-icon.png - BYTE Index
Range: 0-3 
Fc9-u8-icon.png - BYTE Return


GetFloat

Fc9-comp-macro.png GetFloat
Gets a single 32-bit FLOAT value 
Fc9-f32-icon.png - FLOAT Return


GetInt

Fc9-comp-macro.png GetInt
Gets a single 16-bit INT value Index is in little endian, 0 is the LSW and 1 is the MSW 
Fc9-u8-icon.png - BYTE Index
Range: 0-1 
Fc9-u16-icon.png - UINT Return


GetLong

Fc9-comp-macro.png GetLong
Gets a single 32-bit LONG value 
Fc9-u32-icon.png - ULONG Return


SetByte

Fc9-comp-macro.png SetByte
Sets a single 8-bit BYTE value Index is in little endian, 0 is the LSB and 3 is the MSB 
Fc9-u8-icon.png - BYTE Index
Range: 0-3 
Fc9-u8-icon.png - BYTE Value
Range: 0-255 
Fc9-void-icon.png - VOID Return


SetBytes

Fc9-comp-macro.png SetBytes
Allows all bytes to be set using a single macro 
Fc9-u8-icon.png - BYTE Byte0
 
Fc9-u8-icon.png - BYTE Byte1
 
Fc9-u8-icon.png - BYTE Byte2
 
Fc9-u8-icon.png - BYTE Byte3
 
Fc9-void-icon.png - VOID Return


SetFloat

Fc9-comp-macro.png SetFloat
Sets a single 32-bit FLOAT value 
Fc9-f32-icon.png - FLOAT Value
Range: 0-4294967295 
Fc9-void-icon.png - VOID Return


SetInt

Fc9-comp-macro.png SetInt
Sets a single 16-bit INT value. Index is in little endian, 0 is the LSW and 1 is the MSW 
Fc9-u8-icon.png - BYTE Index
Range: 0-1 
Fc9-u16-icon.png - UINT Value
Range: 0-65535 
Fc9-void-icon.png - VOID Return


SetLong

Fc9-comp-macro.png SetLong
Sets a single 32-bit LONG value 
Fc9-u32-icon.png - ULONG Value
Range: 0-4294967295 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-7-icon.png Generate Code