find size of datatype

bvrm

Member
Join Date
Mar 2010
Location
Belgium
Posts
15
Hi,

I would like to find a block or some code that does the following:

IN: pointer to local data of an elementary datatype
OUT: the size of the datatype in bytes as integer

for example

IN: #iNumber (as integer)
OUT: 2

Is this possible?

grtz

bvrm
 
If the IN is an ANY pointer, then it is possible to extract the datatype and the number of elements (repetition factor). In most cases the datatype is BYTE, so the number of bytes can be directly retrieved from the repetition factor.
The repetition factor is contained in bytes 2-3 of the 10 bytes (0-9) of the ANY pointer.
If you want to be sure, you can check the datatype in byte 1. BYTE for example is datatype B#16#02.

See the online help for the structure of the ANY pointer.
 
I have the following code

L P##i_pPointerData
LAR1
L W [AR1,P#2.0]
T #i_iSizeOf

in a FC. When calling the fc i connect i_iPointerData to #iTarget (a temp as integer). The output in i_iSizeOf is 1 instead of 2.

Can it be that the datatype in the anypointer is not BYTE?
 
Correct. When you pass in a UDT, the ANY pointer will always contain the number of byes. When you use the elementary variables, the any pointer will contain the number of variables types. If you want to know the number of bytes you will have to examine the type byte and then use a case statement to select the appropriate number of bytes for each data type.
 

Similar Topics

Hi , Where i can find Mitsubishi PLC Card end of line & replacement model details. i am looking for Q02CPU replacement model. Please advice. thanks
Replies
2
Views
126
I have tested every screen and no single screen individually has this fault pop up, but when I compile and send to the PanelView it comes up. If I...
Replies
4
Views
175
Hi, One of my customers has an old fabric tensile testing machine. The IC # AD7501KN of its controller has malfunctioned. This IC is related to...
Replies
1
Views
80
Hello everyone, I am a student and would like to take the next step and learn FactoryTalk (Batch preferably) and how to create HMIs etc. Would...
Replies
4
Views
492
Hi, Have a look at this picture... How can I find out the memory address of this tag? It was created by adding it to DB "Data_block_1", but I...
Replies
6
Views
1,058
Back
Top Bottom