Mike@hcc


I am using VFP9, Sp1, and am trying to assign an array to an Activex property but I keep getting a "type mismatch" error.

Using the same control and similar code works using VB6.

Using the object browser shows the property to be of type variant and at runtime, using the debugger, shows it to be an array of type "Z", and the array I'm passing to be an array of type "A".

Here are code snippets from both applications (in both cases assigning values (numbers, strings, etc.) to other properties of the control work okay):


==========================================
VB code - works fine

Private Sub Command3_Click()

Dim arrRx(8) As Variant

arrRx(0) = "string 0"
arrRx(1) = "string 1"
arrRx(2) = "string 2"
arrRx(3) = "string 3"
arrRx(4) = "string 4"
arrRx(5) = "string 5"
arrRx(6) = "string 6"
arrRx(7) = "string 7"

o.RxNumbers = arrRx

==========================================

VFP9 code (for Click event) - get "type mismatch"


DIMENSION arrRx[10]

arrRx[1] = "string 0"
arrRx[2] = "string 1"
arrRx[3] = "string 2"
arrRx[4] = "string 3"
arrRx[5] = "string 4"
arrRxDevil = "string 5"
arrRx[7] = "string 6"
arrRxMusic = "string 7"


o.RxNumbers = arrRx
==========================================



Thanks for your help,
Mike




Re: Assigning an array to an Activex property

CetinBasoz


This migh work for you:

o.RxNumbers = getArrayRef("arrRx")

procedure getArrayRef(tcArrayName)

return @&tcArrayName






Re: Assigning an array to an Activex property

Mike@hcc

Trying that gives me a "syntax error" message.

I also tried:
m = getArrayRef("arrRx")
o.RxNumbers = m

and I got the original error message again (and m was an array containing all of the strings).






Re: Assigning an array to an Activex property

Naomi Nosonovsky

There were several discussions on this topic in UT and on the Russian foxclub.ru forum. Here is an idea from Russian forum: (from http://forum.foxclub.ru/read.php 29,287021 )

PUBLIC ARRAY ByteArray[Len(strPostData)] as byte
For i = 1 To LEN(strPostData)
strCH = substr(strPostData, i, 1)
ByteArray(i) = Asc(strCH)
Next

local Inet1 As InternetExplorer.application
Inet1 = CREATEOBJECT('InternetExplorer.application')
Inet1.Navigate(strURL, 0, "", @ByteArray, strHeader)





Re: Assigning an array to an Activex property

CetinBasoz

I don't knwo if it'd work for any activex object. Here is a sample with Excel:

Code Snippet

Local ix,jx

Dimension arrRx[10,5]

For ix=1 To Alen(arrRx,1)

For jx=1 To Alen(arrRx,2)

arrRx[m.ix,m.jx] = Textmerge("This is row:<<m.ix>>, col:<<m.jx>> array element")

Endfor

Endfor

oExcel = Createobject("EXCEL.Application")

With oExcel

.Workbooks.Add()

.Visible = .t.

With .ActiveWorkBook.ActiveSheet

.Range(.Cells(1,1),.Cells(Alen(arrRx,1),Alen(arrRx,2))).Value = ;

getArrayRef('arrRx')

.UsedRange.Columns.Autofit

ENDWITH

Endwith

Procedure getArrayRef(tcArrayName)

Return @&tcArrayName

Endproc

This works with VFP7 and later and saying object browser I assume you have a version VFP7 or later. In VFP6 it wouldn't work.





Re: Assigning an array to an Activex property

Mike@hcc

I've tried all of the things suggested, but keep getting errors.

I think the problem is with the variant type in the control or with VFP9 passing values to a variant. There are a couple of other variants in the control and I cannot assign any value to them either. I've tried assigning integer values, strings, etc., but always get "data type mismatch" errors.

For example, I've tried:
o.RxNumbers = 1
o.RxNumbers = ""
o.RxNumbers = "test string"

All return the data type mismatch. And, as I've said, the same thing happens with any variant field in the control. By the way, the controal is an activex exe, not an ocx.





Re: Assigning an array to an Activex property

Naomi Nosonovsky

Did you check the thread (though in Russian) I referenced

There was another solution there, which you may try:

Code Snippet

oScr = CreateObject("MSScriptControl.ScriptControl")
oScr.Language = "javascript"
oScr.Eval("Arr = new Array()")
oVarArray = oScr.Eval("Arr")





Re: Assigning an array to an Activex property

Mike@hcc

I did to to the thread you referenced. I think my problem is not so much with arrays but with variants. I've tried assigning simple values to that field in the control with no luck.





Re: Assigning an array to an Activex property

Mike@hcc

I was never able to assign any kind of value to a variant in a control.

To solve the problem we added a new property to the control that would take a string value and parse it out and populate the variant field.