locked
OPC.Automation array data access, 800a000d mismatch type error RRS feed

  • Question

  • User-1494023998 posted

    Good morning to all, i'm new to VBScript, so forgive me if i made some errors.

    I have this piece of code wich reads an array from plc data.

    Dim obj_val
    Dim objOPC, OPCGroup
    Dim Val, dati_plc
    Set dati_plc = CreateObject ("Scripting.Dictionary")
    Set objOPC = server.CreateObject("OPC.Automation")
    objOPC.Connect "RSLinx OPC Server"
    Set OPCGroup = objOPC.OPCGroups.add("Gruppo")
    Dim OPCItems
    ' GENERALE -> UHP '
    Set OPCItems = OPCGroup.OPCItems.AddItem("[CC1_L1]N235:0,L10,C1", timeout)
    OPCGroup.IsActive = True
    OPCItems.Read  2, obj_val
    dati_plc.add "OPCItems", OPCGroup.OPCItems.count
    if isArray(obj_val) then
    	dati_plc.Add "isArray", isArray(obj_val)
    	dati_plc.Add "LBound", LBound(obj_val)
    	dati_plc.Add "UBound", UBound(obj_val)
    	dati_plc.Add "typename", typename(obj_val)
    	dati_plc.Add "VarType", VarType(obj_val)
    	dati_plc.Add "isEmpty", isEmpty(obj_val)
    	For i = LBound(obj_val) To UBound(obj_val)	
    		dati_plc.Add "OBJA"+CStr(i), obj_val(i)
    	Next
    else
    	dati_plc.Add "OBJA", (obj_val)		
    end if
    objOPC.disconnect

    For debugging purpose, i added type control, which output is

    <OPCItems>1</OPCItems>
    <isArray>True</isArray>
    <LBound>0</LBound>
    <UBound>9</UBound>
    <typename>Integer()</typename>
    <VarType>8194</VarType>
    <isEmpty>False</isEmpty>

    So, it reads correctly 10 items from plc.

    The problem is when i try to access obj_val data: everytime i get this error:

    error '800a000d'
    Mismatch type error

    I also tried type casting with Format, CStr, CInt etc with no success.

    I found there are some issues with ActiveX results and VBScripts.

    This is an very strange, because i get Integer() type and i cannot cast to variant() type.


    Can anyone help me? Thanks!

    Friday, December 9, 2016 8:20 AM

All replies

  • User-460007017 posted

    Hi marcopete87,

    This link provide some solution to resolve 800a000d error:

    http://www.computerperformance.co.uk/Logon/code/code_800A000D.htm

    Hope it could help you.

    Best Regards,

    Yuk Ding

    Monday, December 12, 2016 9:37 AM
  • User-1494023998 posted

    Hi, thank you, but unfortunately i also tried this approach without success.

    This is on asp page.

    It seems asp can see which kind of data is, but won't access for some reason...

    Tuesday, December 13, 2016 10:27 AM
  • User-1122936508 posted

    marcopete87

    The problem is when i try to access obj_val data: everytime i get this error:

    error '800a000d'
    Mismatch type error

    I also tried type casting with Format, CStr, CInt etc with no success.

    You checked the Type of obj_val, but did you check the Type of each element? You might have an Array or NULL as an element - in which case CStr() will fail.

    Also, instead of doing a loop, just access the first element and get that working first.

    Tuesday, December 13, 2016 11:20 PM
  • User-1494023998 posted

    yes, i tested and every action over array items cause this failure, including get type name of each element.

    Now, i changed the behaviour of my application, now i don't need anymore this array, however, i need some info about that issue.

    Wednesday, December 14, 2016 8:22 AM
  • User-1122936508 posted

    yes, i tested and every action over array items cause this failure, including get type name of each element.

    Can you show us some sample code?

    Thursday, December 15, 2016 4:35 AM
  • User-1494023998 posted

    This is the code:

    <% @Language = "VBScript" %>
    <%
    Dim obj_val
    Dim objOPC, OPCGroup
    Dim Val, dati_plc
    Set dati_plc = CreateObject ("Scripting.Dictionary")
    Set objOPC = server.CreateObject("OPC.Automation")
    objOPC.Connect "RSLinx OPC Server"
    Set OPCGroup = objOPC.OPCGroups.add("Gruppo")
    Dim OPCItems
    ' GENERALE -> UHP '
    Set OPCItems = OPCGroup.OPCItems.AddItem("[CC1_L1]N235:0,L10,C1", timeout)
    OPCGroup.IsActive = True
    OPCItems.Read  2, obj_val
    dati_plc.add "OPCItems", OPCGroup.OPCItems.count
    if isArray(obj_val) then
    	dati_plc.Add "isArray", isArray(obj_val)
    	dati_plc.Add "LBound", LBound(obj_val)
    	dati_plc.Add "UBound", UBound(obj_val)
    	dati_plc.Add "typename", typename(obj_val)
    	dati_plc.Add "VarType", VarType(obj_val)
    	dati_plc.Add "isEmpty", isEmpty(obj_val)
    	For i = LBound(obj_val) To UBound(obj_val)	
    		'dati_plc.Add "OBJA"+CStr(i), typename(obj_val(i))
    	Next
    else
    	dati_plc.Add "OBJA", (obj_val)		
    end if
    objOPC.disconnect
    %>
    <xml>
    <%	
    	dim items, keys, response_out
    	dim variable_name, variable_value
    	items=dati_plc.items
    	keys=dati_plc.keys
    	for i=0 to dati_plc.count-1
    		variable_value=keys(i)
    		variable_name=items(i)
    		%>
    		<<%=variable_value%>><%=variable_name%></<%=variable_value%>><%
    	Next
    %>
    </xml>

    When i comment line

    'dati_plc.Add "OBJA"+CStr(i), typename(obj_val(i))

    I obtain 

    <xml>
    		<OPCItems>1</OPCItems>
    		<isArray>True</isArray>
    		<LBound>0</LBound>
    		<UBound>9</UBound>
    		<typename>Integer()</typename>
    		<VarType>8194</VarType>
    		<isEmpty>False</isEmpty>
    </xml>

    But, when i comment out to get typename of each item, i always get this error:

    <font face="Arial" size=2>
    <p>Errore di run-time di Microsoft VBScript</font> <font face="Arial" size=2>error '800a000d'</font>
    <p>
    <font face="Arial" size=2>Tipo non corrispondente</font>
    <p>
    <font face="Arial" size=2>test.asp</font><font face="Arial" size=2>, riga 24</font> 

    Friday, December 16, 2016 12:26 PM
  • User-1122936508 posted

    This might be beating a dead horse, but as I mentioned in the previous post, is it possible to test a couple of things:

    If isNull obj_val(0) then Response.Write "Is Null"

    and also

    Response.Write TypeName(obj_val(0))

    ? (and then test each item separately).

    Just in case there's either:

    a) one odd element that's causing the problem, but the others are fine

    b) a problem adding the output to the Dictionary object

    I'm suspecting this isn't going to help, but you never know...

    Monday, December 19, 2016 1:01 AM
  • User-1494023998 posted
    If isNull obj_val(0) then Response.Write "Is Null"
     <font face="Arial" size=2>
    <p>Errore di compilazione di Microsoft VBScript</font> <font face="Arial" size=2>error '800a03f9'</font>
    <p>
    <font face="Arial" size=2>Previsto 'Then'</font>
    <p>
    <font face="Arial" size=2>test.asp</font><font face="Arial" size=2>, riga 30</font>
    <pre>If isNull obj_val(0) then Response.Write &quot;Is Null&quot;
    ----------^</pre> 

    No, this isn't going to work.

    If isNull (obj_val(0)) then Response.Write "Is Null"
     <font face="Arial" size=2>
    <p>Errore di run-time di Microsoft VBScript</font> <font face="Arial" size=2>error '800a000d'</font>
    <p>
    <font face="Arial" size=2>Tipo non corrispondente</font>
    <p>
    <font face="Arial" size=2>test.asp</font><font face="Arial" size=2>, riga 30</font> 
    Response.Write TypeName(obj_val(0))

    <font face="Arial" size=2>
    <p>Errore di run-time di Microsoft VBScript</font> <font face="Arial" size=2>error '800a000d'</font>
    <p>
    <font face="Arial" size=2>Tipo non corrispondente</font>
    <p>
    <font face="Arial" size=2>test.asp</font><font face="Arial" size=2>, riga 30</font> 


    I added on row 30.
    So, the problem persists... and i don't know why...

    Monday, December 19, 2016 10:44 AM
  • User-460007017 posted

    Hi marcopete87,

    Have you tried to convert the subtype?

    Best Regards,

    Yuk Ding

    Thursday, December 29, 2016 9:45 AM
  • User-1494023998 posted

    I also tried type casting with Format, CStr, CInt etc with no success.

    As on first message, i tried without success.

    However, i'm not spending anymore time on it, so it is unsolved.

    Friday, January 27, 2017 9:44 AM