Page 1 of 1

Com question

Posted: Tue Jan 21, 2003 4:46 am
by Guy
I'm creating a variable as new com object(the com is in vb).
it opens successfully.
I have a let and get for Field:
$objView = new COM("my.comobj")
the Get: $objView->Field("fName")
works and I get the parameter, but this :
$objView->Field('fName") = "newValue";
gives a Parse error: parse error, unexpected '=' in ...
if I try to use the let function in vb (same function name,takes 2 params)
I get an error in number of arguments sent.
does anyone knows how to do this set??
Guy

Posted: Tue Jan 21, 2003 4:55 am
by twigletmac
You appear to have a mismatch of quotes (single and double) in this line here:

Code: Select all

$objView->Field('fName") = "newValue";
try changing it to:

Code: Select all

$objView->Field('fName') = "newValue";
Mac

it's not quotes problem

Posted: Tue Jan 21, 2003 5:23 am
by Guy
the get works, with either 'fieldname' or "fieldname".
the problem is when adding the = 'newvalue'
i get an a parse error on the = .
this syntax works in vbscript. ( the source im converting to php now)
thanks
Guy

Posted: Tue Jan 21, 2003 6:00 am
by twigletmac
But in the code above (and it could be a typo from when you posted to the forum) you have: 'fieldname" -> you start with a single quote and end with a double quote.

That aside, is Field a function?

Mac

Posted: Tue Jan 21, 2003 6:08 am
by twigletmac
Further to my question above about Field() being a function. This test:

Code: Select all

function Field($val1, $val2)
{
	$val1 = $val2;
	return $val2;
} // end func

Field('fName') = "newValue";
produced the same error message that you are seeing. You can't set a function to be equal to something, you could however pass variables to it as arguments so it can adjust a variable based on these. I don't know what arguments Field() might take but have you tried:

Code: Select all

$objView->Field('fName', 'newValue');
Mac

sorry, the ' " is a typo, and Field is a Function

Posted: Tue Jan 21, 2003 6:08 am
by Guy
in the com interface (a get for the field) I also have let but I get a number of arguments error when trying to invoke it.
btw - since it's a function I tried to pass the return value by reference to a another function (php one) and then set it, but it didn't work.
maybe I did it wrong
Guy

i understand the error of the = to a return value(by the way

Posted: Tue Jan 21, 2003 6:19 am
by Guy
it works in vbscript).
but, and it's a big one, since the vbscript com object is close to me , i can only use the function it opens - how can i make it work?
is there another way? (byref, set or anything else?)

ths code in vbscript :
objView.Field("fName") = "newValue"