Jump to content
Sign in to follow this  

Pointer to Variant

Recommended Posts



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);
  $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)' />

STDMETHOD(CS7ProSim::ReadOutputPoint)( long ByteIndex, 
                                       long BitIndex, 
                                       PointDataTypeConstants DataType, 
                                       VARIANT* pData) 

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). 

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

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.




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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.