#include "stdafx.h" #include "t5vm.h" /* long_to_bytes - Source code (requires t5vm.h include) */ /* Function block */ /* Argument list */ #define _P_LONG_VAL_ (*((T5_PTLONG)(T5GET_DBDATA32(pBase))+pArgs[0])) #define _P_BYTE1_ (*((T5_PTBYTE)(T5GET_DBDATA8(pBase))+pArgs[1])) #define _P_BYTE2_ (*((T5_PTBYTE)(T5GET_DBDATA8(pBase))+pArgs[2])) #define _P_BYTE3_ (*((T5_PTBYTE)(T5GET_DBDATA8(pBase))+pArgs[3])) #define _P_BYTE4_ (*((T5_PTBYTE)(T5GET_DBDATA8(pBase))+pArgs[4])) /* private block data */ typedef struct { T5_DWORD dwData; /* TODO: replace dwData by the items you need */ } _str_FB_LONG_TO_BYTES; /* handler */ T5_DWORD __declspec(dllexport) LONG_TO_BYTES ( T5_WORD wCommand, T5PTR_DB pBase, T5_PTR pClass, T5_PTR pInst, T5_PTWORD pArgs) { _str_FB_LONG_TO_BYTES *pData; pData = (_str_FB_LONG_TO_BYTES *)pInst; switch (wCommand) { case T5FBCMD_ACTIVATE : /* activates the function block */ /* enter your code here... */ _P_BYTE1_ = _P_LONG_VAL_ & 0xFF; _P_BYTE2_ = (_P_LONG_VAL_ >> 8) & 0xFF; _P_BYTE3_ = (_P_LONG_VAL_ >> 16) & 0xFF; _P_BYTE4_ = (_P_LONG_VAL_ >> 24) & 0xFF; return 0L; case T5FBCMD_INITINSTANCE : /* initialize private data */ /* enter your code here... */ return 0L; case T5FBCMD_EXITINSTANCE : /* release private data */ /* enter your code here... */ return 0L; case T5FBCMD_HOTRESTART : /* actuate private data for hot restart */ /* enter your code here... */ return 0L; case T5FBCMD_SIZEOFINSTANCE : /* dont change that */ return (T5_DWORD)sizeof(_str_FB_LONG_TO_BYTES); case T5FBCMD_ACCEPTCT : /* dont change that */ return 1L; default : return 0L; } } /* Undefine argument list */ #undef _P_LONGVAL #undef _P_BYTE1 #undef _P_BYTE2 #undef _P_BYTE3 #undef _P_BYTE4