473,586 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to declare a pointer

I'm a js newbie trying to use some very simple js to call an ActiveX
object's methods.
I need to use a pointer to call an embedded ActiveX object's method to
receive a number.
As I understand it, js is typeless so how can I get a variable to be a
pointer type?
Passing var i as the parameter gets an undefined value in return.

Thanks IA, Simon
Jul 23 '05 #1
10 4379
On Sun, 4 Apr 2004 19:35:24 +0000 (UTC), Simon
<si************ ****@btinternet .please.com> wrote:
I'm a js newbie trying to use some very simple js to call an ActiveX
object's methods.
I need to use a pointer to call an embedded ActiveX object's method to
receive a number.
As I understand it, js is typeless so how can I get a variable to be a
pointer type?
Passing var i as the parameter gets an undefined value in return.


JavaScript doesn't have pointers[1]. The closest thing is references, but
they only exist for passing objects and arrays as function parameters.
Primitive types (booleans, string, numbers) are always passed by value.

Without pointing to the documentation for this ActiveX object, or
describing it in more detail, there isn't much help anyone can provide.

Mike
[1] Microsoft's DHTML Reference documentation talks about them all the
time, but there's a lot of mistakes in those pages, and using the word
"pointer" is one of them.

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #2
>
JavaScript doesn't have pointers[1]. The closest thing is references, but
they only exist for passing objects and arrays as function parameters.
Primitive types (booleans, string, numbers) are always passed by value.

Without pointing to the documentation for this ActiveX object, or
describing it in more detail, there isn't much help anyone can provide.


Mike,

The ActiveX object is one of my own so I can change the parameters as
necessary. Currently it has a function that takes 2 paramters, one in is a
WideString (in) and the other is a Variant pointer (out). It was written
purely as an exercise to see if I can get a returned variable in javascript.
The ActiveX limitation is that 'out' type parameters must be pointers.
It may work if I can pass a variable by reference as a reference is an
address of the variable much like a pointer? Is there a way to reference a
variable in js or does it happen automatically when the variable is passed
to a function?

Thanks, Simon
Jul 23 '05 #3
On Mon, 5 Apr 2004 08:11:04 +0000 (UTC), Simon
<si************ ****@btinternet .please.com> wrote:

[snip]
The ActiveX object is one of my own so I can change the parameters as
necessary. Currently it has a function that takes 2 paramters, one in is
a WideString (in) and the other is a Variant pointer (out). It was
written purely as an exercise to see if I can get a returned variable in
javascript.
It would probably be best to use a return value, rather than attempting to
pass by reference.
The ActiveX limitation is that 'out' type parameters must be pointers.
It may work if I can pass a variable by reference as a reference is an
address of the variable much like a pointer?
There is no concept of "addresses" in JavaScript.
Is there a way to reference a variable in js or does it happen
automatically when the variable is passed to a function?


References are always used with objects and arrays, whether a function
call is involved or not. However, they are only used with objects and
arrays. You can't specify how a variable is passed during a call.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #4
> It would probably be best to use a return value, rather than attempting to
pass by reference.
Functions of automation interfaces mush have a return type of HResult (a
least that is what my IDE tells me), so I cannot emply this strategy.
References are always used with objects and arrays, whether a function
call is involved or not. However, they are only used with objects and
arrays. You can't specify how a variable is passed during a call.

Looks like it won't work then. Thanks for your help.
Jul 23 '05 #5
"Simon" <si************ ****@btinternet .please.com> wrote in message
news:c4******** **@titan.btinte rnet.com...
It would probably be best to use a return value, rather than attempting to pass by reference.

Functions of automation interfaces mush have a return type of HResult (a
least that is what my IDE tells me), so I cannot emply this strategy.
References are always used with objects and arrays, whether a function
call is involved or not. However, they are only used with objects and
arrays. You can't specify how a variable is passed during a call.

Looks like it won't work then. Thanks for your help.


Do I understand you corredtly, when I sat that you have made a (visible)
ActiveX component that you display on a web-bage like this:

<object
classid="clsid: E217D189-AEA5-4F62-A044-A716C202474B"
id="activeX">
</object>

....and that you want to access some (public) value or call a method in
that activeX component from JavaScript on the same page?

like this(?):

<script type="text/javascript">
function Test()
{
var myObj = document.getEle mentById("activ eX")
alert(myObj.get Value());
}
</script>

If so, that is quite possible, and JavaScript can call any public method,
and access any public member of the activeX control. And functions are
*not* limited to the HResult type!

--
Dag.
Jul 23 '05 #6
>
Do I understand you corredtly, when I sat that you have made a (visible)
ActiveX component that you display on a web-bage like this:

<object
classid="clsid: E217D189-AEA5-4F62-A044-A716C202474B"
id="activeX">
</object>

Yep
...and that you want to access some (public) value or call a method in
that activeX component from JavaScript on the same page?

like this(?):

<script type="text/javascript">
function Test()
{
var myObj = document.getEle mentById("activ eX")
alert(myObj.get Value());
}
</script>
Near enough, yes.

If so, that is quite possible, and JavaScript can call any public method,
and access any public member of the activeX control. And functions are
*not* limited to the HResult type!


The return of an automation interface method is limited to HResult in
Delphi, I don't know why.

I have no problem getting and setting properties and I have no problem
calling methods. The issue is getting a return (out) parameter from the
method.

eg. Method = AddText(in Text: BSTR; out Index: long * )

I can call the above method and it will execute, but I cannot get the out
parameter.
In Delphi the out parameters must be pointer types.

Any ideas?

Simon
Jul 23 '05 #7
"Simon" <si************ ****@btinternet .please.com> wrote in message
news:c4******** **@hercules.bti nternet.com...
<snipped />
The return of an automation interface method is limited to HResult in
Delphi, I don't know why.

I have no problem getting and setting properties and I have no problem
calling methods. The issue is getting a return (out) parameter from the
method.

eg. Method = AddText(in Text: BSTR; out Index: long * )

I can call the above method and it will execute, but I cannot get the out
parameter.
In Delphi the out parameters must be pointer types.

Any ideas?


Let's clear up a couple of things first...

The HRESULT return type of an automation interface does not have
anything to do with your parameters of return value, but is the result
of the automation process (ie. success/error code).

The Delphi help file say that:
"If a parameter type is specified as a Pointer type, the Type Library
editor usually translates that type into a variable parameter. When the
type library is saved, the variable parameter's associated ElemDesc's
IDL flags are marked IDL_FIN or IDL_FOUT."

// ---------- copied from Delphi help...----------------
DevGuide: Developing COM-based applications
Valid types

Topic Groups See Also

In the Type Library editor, you use different type identifiers, depending on
whether you are working in IDL or Delphi. Specify the language you want to
use in the Environment options dialog.

The following types are valid in a type library for COM development. The
Automation compatible column specifies whether the type can be used by an
interface that has its Automation or Dispinterface flag checked. These are
the types that COM can marshal via the type library automatically.

Delphi type IDL type variant type Automation compatible Description
Smallint short VT_I2 Yes 2-byte signed integer
Integer long VT_I4 Yes 4-byte signed integer
Single single VT_R4 Yes 4-byte real
Double double VT_R8 Yes 8-byte real
Currency CURRENCY VT_CY Yes currency
TDateTime DATE VT_DATE Yes date
WideString BSTR VT_BSTR Yes binary string
IDispatch IDispatch VT_DISPATCH Yes pointer to IDispatch interface
SCODE SCODE VT_ERROR Yes Ole Error Code
WordBool VARIANT_BOOL VT_BOOL Yes True = -1, False = 0
OleVariant VARIANT VT_VARIANT Yes Ole Variant
IUnknown IUnknown VT_UNKNOWN Yes pointer to IUnknown interface
Shortint byte VT_I1 No 1 byte signed integer
Byte unsigned char VT_UI1 Yes 1 byte unsigned integer
Word unsigned short VT_UI2 Yes* 2 byte unsigned integer
LongWord unsigned long VT_UI4 Yes* 4 byte unsigned integer
Int64 __int64 VT_I8 No 8 byte signed integer
Largeuint uint64 VT_UI8 No 8 byte unsigned integer
SYSINT int VT_INT Yes* system dependent integer (Win32=Integer)
SYSUINT unsigned int VT_UINT Yes* system dependent unsigned integer
HResult HRESULT VT_HRESULT No 32 bit error code
Pointer VT_PTR -> VT_VOID No untyped pointer
SafeArray SAFEARRAY VT_SAFEARRAY No OLE Safe Array
PChar LPSTR VT_LPSTR No pointer to Char
PWideChar LPWSTR VT_LPWSTR No pointer to WideChar
* Word, LongWord, SYSINT, and SYSUINT may be Automation-compatible with some
applications.
See safe arrays for more information about the SAFEARRAY Variant type.

Note

The Byte (VT_UI1) is Automation-compatible, but is not allowed in a Variant
or OleVariant since many Automation servers do not handle this value
correctly.
Besides these IDL types, any interfaces and types defined in the library or
defined in referenced libraries can be used in a type library definition.
The Type Library editor stores type information in the generated type
library (.TLB) file in binary form.
If a parameter type is specified as a Pointer type, the Type Library editor
usually translates that type into a variable parameter. When the type
library is saved, the variable parameter's associated ElemDesc's IDL flags
are marked IDL_FIN or IDL_FOUT.

Often, ElemDesc IDL flags are not marked by IDL_FIN or IDL_FOUT when the
type is preceded with a Pointer. Or, in the case of dispinterfaces, IDL
flags are not typically used. In these cases, you may see a comment next to
the variable identifier such as {IDL_None} or {IDL_In}. These comments are
used when saving a type library to correctly mark the IDL flags.

--
Dag.
Jul 23 '05 #8
<snipped>
Let's clear up a couple of things first...

The HRESULT return type of an automation interface does not have
anything to do with your parameters of return value, but is the result
of the automation process (ie. success/error code).

Ok.
The Delphi help file say that:

<snipped>

Yes.

So back to my original question - how can I use an IDL_FOUT parameter in
javascipt?

Activex:
eg. Method = AddText(in Text: BSTR; out Index: long * )

Js:
var i;
i = 0;
activeX.Method( 'hello', i);
//i still = 0

Thanks, Simon
Jul 23 '05 #9
"Simon" <si************ ****@btinternet .please.com> wrote in message
news:c5******** *@hercules.btin ternet.com...
<snipped>
Let's clear up a couple of things first...

The HRESULT return type of an automation interface does not have
anything to do with your parameters of return value, but is the result
of the automation process (ie. success/error code).


Ok.
The Delphi help file say that:

<snipped>

Yes.

So back to my original question - how can I use an IDL_FOUT parameter in
javascipt?

Activex:
eg. Method = AddText(in Text: BSTR; out Index: long * )

Js:
var i;
i = 0;
activeX.Method( 'hello', i);
//i still = 0


Have you tried declaring it like:

HRESULT = _stdcall AddText([in] BSTR Text, [out, retval] long * Index);
(in the "View -> Type Library" menu...)

and use it like:

var i = activeX.method( 'hello');

???

--
Dag.

Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
12567
by: Philipp | last post by:
Hello, I've got a class Lattice which is declared like that: // file: lattice.h class Lattice:public EventChooser{ public: Lattice(LatticeParameters* params); virtual ~Lattice(); // (...snip...)
9
4801
by: Dave | last post by:
I am trying to call VerQueryValue from a C# program. VerQueryValue takes as one of its parameters a pointer to a pointer to an array of bytes, which it uses to return a pointer to the required array. Now, I can call it like this: byte* lpBuffer; int length; string subBlock = @"\StringFileInfo\" + langCodePage + @"\FileDescription"; result =...
15
5315
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have private string myArray;
6
2127
by: **Developer** | last post by:
Notice below I sometimes used the "A" version. I found by cut-and-try that only the "A" version would work correctly. Anyone have a suggestion of why the "W" version would not work correctly? One reason is that the ByRef or ByVal does not show by InteliSence so the "p" would help there. ------ Secondly, I'd like to be consistent with...
0
1388
by: eric | last post by:
Can I declare a pure virtual member function which accepts as input a boost shared pointer to an object of a base class, such that - concrete implementations of the function can redirect the pointer to a new object - clients of the function can pass in as input a boost shared pointer to an object of a derived class ? Consider the...
2
7139
by: Tany | last post by:
How can I declare function returning array of Integer pointers . Please help !!
6
3328
by: CJ | last post by:
Functions can accept "argv like" variable definitions, i.e. foo(int argc, char *argv), which was defined/initialized in the C start up stubs, but we can't declare one for our own use. Example: foo(char *args) { /* implementation excluded }; // ok int main(int argc,char *argv) {
2
2080
by: Sam Waller | last post by:
/********************* **********************/ I'm trying to declare a function pointer in class A and set it in class B, but I get syntax errors. How can I get this to compile and run? thanks, Sam
1
4579
by: rafaelcho | last post by:
Hello I am new to group, and new to development. I have question. I am doing project on embedded, need to read/write to the registers of the microprocessor. Two questions: 1. How to declare? Maybe use pointer. #define TX_Register 0x30008000 long * tx_reg = TX_Register Is this correct?
2
1333
by: Sreeramu | last post by:
Declare a pointer to a function which takes array of pointer to a function as an argument and return the pointer to a function..... how to declare this....
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.