473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Execute From Pointer

Hi,
Is there any way to execute a function by using it's pointer?
The reason I want to do this is: I have a control on a form that I
have wrapped with a class. I want to be able to dynamically assign a
function that is in the form's code to an event defined in the wrapper
class. The application.run function won't recognise the name of the
function in a form (at least I don't know how to make it so). e.g.
Applicaion.Run "Form_fMyForm.MyFunction" So I thought that pointer to
the function might work - if I could figure out how to execute the
function using it's address.
Thanks in advance
Pachydermitis

Nov 7 '06 #1
9 1279
On 6 Nov 2006 18:07:45 -0800, "Pachydermitis" <pr*******@gmail.com>
wrote:

Not by pointer (unless you would consider AddressOf, an advanced
topic), but by name: check out the Eval function.

-Tom.

>Hi,
Is there any way to execute a function by using it's pointer?
The reason I want to do this is: I have a control on a form that I
have wrapped with a class. I want to be able to dynamically assign a
function that is in the form's code to an event defined in the wrapper
class. The application.run function won't recognise the name of the
function in a form (at least I don't know how to make it so). e.g.
Applicaion.Run "Form_fMyForm.MyFunction" So I thought that pointer to
the function might work - if I could figure out how to execute the
function using it's address.
Thanks in advance
Pachydermitis
Nov 7 '06 #2
Pachydermitis wrote:
Hi,
Is there any way to execute a function by using it's pointer?
The reason I want to do this is: I have a control on a form that I
have wrapped with a class. I want to be able to dynamically assign a
function that is in the form's code to an event defined in the wrapper
class. The application.run function won't recognise the name of the
function in a form (at least I don't know how to make it so). e.g.
Applicaion.Run "Form_fMyForm.MyFunction" So I thought that pointer to
the function might work - if I could figure out how to execute the
function using it's address.
Thanks in advance
Pachydermitis
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The correct syntax is: Forms!FormName.FunctionName

Try the Eval() function:

strFunction = "Forms!myForm.FunctionName"
Eval(strFunction)

--
MGFoster:::mgf00 <atearthlink <decimal-pointnet
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRU/z4IechKqOuFEgEQIo0ACg6Kt4eU1i5DK98VGwBDZfq1vmgK0Ao NJE
hbxWd9uahJiNexNbiH/mwQfv
=yui4
-----END PGP SIGNATURE-----
Nov 7 '06 #3
I was counting on addressof for the function address, but once I have
the pointer to a function, how do I execute it?
Thanks
P
Tom van Stiphout wrote:
On 6 Nov 2006 18:07:45 -0800, "Pachydermitis" <pr*******@gmail.com>
wrote:

Not by pointer (unless you would consider AddressOf, an advanced
topic), but by name: check out the Eval function.

-Tom.

Hi,
Is there any way to execute a function by using it's pointer?
The reason I want to do this is: I have a control on a form that I
have wrapped with a class. I want to be able to dynamically assign a
function that is in the form's code to an event defined in the wrapper
class. The application.run function won't recognise the name of the
function in a form (at least I don't know how to make it so). e.g.
Applicaion.Run "Form_fMyForm.MyFunction" So I thought that pointer to
the function might work - if I could figure out how to execute the
function using it's address.
Thanks in advance
Pachydermitis
Nov 7 '06 #4
Thanks for the tip MG. I tried that but it did not work. It seems
that eval, run and CallByName can not recognize methods of classes
unless called within them.

MGFoster wrote:
Pachydermitis wrote:
Hi,
Is there any way to execute a function by using it's pointer?
The reason I want to do this is: I have a control on a form that I
have wrapped with a class. I want to be able to dynamically assign a
function that is in the form's code to an event defined in the wrapper
class. The application.run function won't recognise the name of the
function in a form (at least I don't know how to make it so). e.g.
Applicaion.Run "Form_fMyForm.MyFunction" So I thought that pointer to
the function might work - if I could figure out how to execute the
function using it's address.
Thanks in advance
Pachydermitis

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The correct syntax is: Forms!FormName.FunctionName

Try the Eval() function:

strFunction = "Forms!myForm.FunctionName"
Eval(strFunction)

--
MGFoster:::mgf00 <atearthlink <decimal-pointnet
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRU/z4IechKqOuFEgEQIo0ACg6Kt4eU1i5DK98VGwBDZfq1vmgK0Ao NJE
hbxWd9uahJiNexNbiH/mwQfv
=yui4
-----END PGP SIGNATURE-----
Nov 7 '06 #5

Pachydermitis wrote:
Hi,
Is there any way to execute a function by using it's pointer?
The reason I want to do this is: I have a control on a form that I
have wrapped with a class. I want to be able to dynamically assign a
function that is in the form's code to an event defined in the wrapper
class. The application.run function won't recognise the name of the
function in a form (at least I don't know how to make it so). e.g.
Applicaion.Run "Form_fMyForm.MyFunction" So I thought that pointer to
the function might work - if I could figure out how to execute the
function using it's address.
Thanks in advance
Pachydermitis
Did you try

Form_fMyForm.MyFunction

?

This works for me for both a Sub and Function. One must remember to
close the form afterward. The Function or Sub must be Public.

I have been doing this since the last century. It works in standard
modules.

I have never needed eval although I remember someone posting a good use
for it, I just don't remember the use.

And yes, this works for a sub-form too. The notion of using the
Form!Control.Form etc etc obsolete syntax is pointless.

I see you want to use it for a class event. Well, I'm not going to take
the time to test that. But it works flawlessly in event procedures of
another form, which are just classes with nice boobs anyway.

Nov 8 '06 #6
Hey Lyle,
What I actually need is to be able to execute a function that resides
in a class and whose name I need to be able to change during runtime.

dim sFunctionName as string
sFunctionName ="MyFunction"
application.run sFunctionName
works well, as does Eval

dim sFunctionName as string
sFunctionName ="mMyClass.MyMethod"
application.run sFunctionName
Does not

I am having the same results with CallByName and Eval
Hence my question as to how I can execute a proceedure using it's
pointer.

Thanks again all for your help
P

Lyle Fairfield wrote:
Pachydermitis wrote:
Hi,
Is there any way to execute a function by using it's pointer?
The reason I want to do this is: I have a control on a form that I
have wrapped with a class. I want to be able to dynamically assign a
function that is in the form's code to an event defined in the wrapper
class. The application.run function won't recognise the name of the
function in a form (at least I don't know how to make it so). e.g.
Applicaion.Run "Form_fMyForm.MyFunction" So I thought that pointer to
the function might work - if I could figure out how to execute the
function using it's address.
Thanks in advance
Pachydermitis

Did you try

Form_fMyForm.MyFunction

?

This works for me for both a Sub and Function. One must remember to
close the form afterward. The Function or Sub must be Public.

I have been doing this since the last century. It works in standard
modules.

I have never needed eval although I remember someone posting a good use
for it, I just don't remember the use.

And yes, this works for a sub-form too. The notion of using the
Form!Control.Form etc etc obsolete syntax is pointless.

I see you want to use it for a class event. Well, I'm not going to take
the time to test that. But it works flawlessly in event procedures of
another form, which are just classes with nice boobs anyway.
Nov 8 '06 #7
Ok, I'm a dork and did not read properly, here's how it works:

dim sFunctionName as string
dim cMyForm as Form_MyForm 'declared so we can explicitly destroy it
set cMyForm =new Form_MyForm
sFunctionName="MyMethod"
CallByName Form_MyForm, sFunctionName, VbMethod
set cMyForm =nothing

CallByName was specifically designed to answer this need.
Thanks all
P

Nov 8 '06 #8
Hi Pachydermitis,

What I do is the following:
In any event on the I can add these statements:
ThisProcname = ....
Run ThisProcname, ThisForm
ThisProcname is composed dynamically, and results in the name of a
Public Sub.
Depending on situation ThisProcname (and so it behaviour) can be quite
different.

The Sub ThisProcname takes one argument: ThisForm, i.e. the Form on
which the event was fired. So the Sub knows exactly all the Controls
and their values (instead of using parameters) on the form.
In case you need a function-value: ThisProcname can leave a value in a
certain (invisible) control on ThisForm.

Regards, HBinc.

Pachydermitis schreef:
Hi,
Is there any way to execute a function by using it's pointer?
The reason I want to do this is: I have a control on a form that I
have wrapped with a class. I want to be able to dynamically assign a
function that is in the form's code to an event defined in the wrapper
class. The application.run function won't recognise the name of the
function in a form (at least I don't know how to make it so). e.g.
Applicaion.Run "Form_fMyForm.MyFunction" So I thought that pointer to
the function might work - if I could figure out how to execute the
function using it's address.
Thanks in advance
Pachydermitis
Nov 8 '06 #9
oops should be
CallByName cMyForm, sFunctionName, VbMethod

Pachydermitis wrote:
Ok, I'm a dork and did not read properly, here's how it works:

dim sFunctionName as string
dim cMyForm as Form_MyForm 'declared so we can explicitly destroy it
set cMyForm =new Form_MyForm
sFunctionName="MyMethod"
CallByName Form_MyForm, sFunctionName, VbMethod
set cMyForm =nothing

CallByName was specifically designed to answer this need.
Thanks all
P
Nov 10 '06 #10

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

Similar topics

4
by: tom | last post by:
Problem: In PHP, need to execute a program in (freebsd terms) /usr/local/bin in meta-terms: int i; i = (arguments); There seems to be quite a few execution methods in PHP (sorry in advance...
1
by: arfanameer | last post by:
How can i add Execute permissions on the Stored Procedures under the created user permission iusing SQLDMO ?
3
by: DCM Fan | last post by:
All, A month or so ago I started a thread titled "I was *forced* to use RunSQL." At that time, I said I'd get back to you after trying the dbSeeChanges constant in the Execute method. I was...
22
by: chellappa | last post by:
Hello, I would like to know how i can execute an exe file using c prgogram? I am using the GNU GCC in Linux Could someone explain me how to do that ? send mail chellappa at gmail .com Thanks...
3
by: JerryW | last post by:
I uninstalled/reinstalled .NET 2003 with no errors. When I try to create a Visual C# ASP.NET Web Application I get the error: "The Web server reported the following error when attempting to...
7
by: Mike L. | last post by:
Hi, I got this 'EXECUTE permission denied on object <mySproc>' error message everytime I try executing my SQL server Sproc. What's this and how to fix this err? many thnaks in advance, mike
19
by: citronelu | last post by:
Is it possible to execute a binary string stored within a python script as executable code ? The script is run under Windows, and the binary code (a full executable file) is stored in a variable...
0
by: karthi.guru | last post by:
how can i retrieve the ProjectItems pointer from ContextParam in IDTWizard::Execute method by Karthikeyan.G -- karthi.guru...
6
by: ma740988 | last post by:
I'm perusing a question and curiosity got the best of me in part because I cant solve the problem Consider: typedef unsigned int word_type ; class foo { public: void set_mx_digits_1 (...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.