Sign in to follow this  
Followers 0
tomis

Pointer to Variant

2 posts in this topic

Hi,

Im trying call method of object which requires pointer to Variant variable. How to get pointer?

Im tried ptr() and create DllStruct $intTip. But cant get it working.

$oPLCSIM = ObjCreate("S7wspsmx.S7ProSim")
if $oPLCSIM =0 Then MsgBox(0,"Error","Object create error")
if $oPLCSIM.Connect() Then MsgBox(0,"Connect","Cant connect")

 local $intTip = DllStructCreate("USHORT")
  if @error Then
     MsgBox(0,"","Error in DllStructCreate " & @error);
     exit
 endif
  $a=$oPLCSIM.ReadOutputPoint(97,0,3,DllStructGetPtr($intTip))
  $b=DllStructGetData($intTip, 1)
  MsgBox(0,"Output",$<img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />

[u]ReadOutputPoint[/u] 
STDMETHOD(CS7ProSim::ReadOutputPoint)( long ByteIndex, 
                                       long BitIndex, 
                                       PointDataTypeConstants DataType, 
                                       VARIANT* pData) 

Description 
Reads a particular bit (Boolean), a byte (Byte), a two-byte word (Integer) or a four-byte word (Long) 
from the peripheral output image (PQ memory area). 
Parameters 

ByteIndex 
Represents the starting byte position in the peripheral image buffer to read. Valid 
values for ByteIndex are dependent on the CPU. 

BitIndex 
Represents the Bit position (in bytes) in the peripheral image buffer to read. Valid 
values are 0 to 7. 

DataType  One of the PointDataTypeConstants  (3-WORD)

pData  Pointer to the data to read. Valid values for data are dependent on the data type.

Share this post


Link to post
Share on other sites



AutoIt can't handle pointers that way (it's a bug).

You need to do

Number(DllStructGetPtr($intTip) )

Another thing is you should look for ObjEvent() function. It can catch errors for you.

And learn what Variant is.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0