Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Emulating the "this" pointer in ASP/VBScript

Posted on 2006-06-08
6
Medium Priority
?
642 Views
Last Modified: 2008-02-26
I am seeking comments/ideas on how I might emulate the "this" pointer in ASP/VBScript. The "this" pointer is available in many object oriented languages including C++, Java and PHP, but is not available in ASP/VBScript.

Question: If you need a "this" pointer in ASP/VBScript how would you implement it?

Thank you.

Note: If you don't know what a "this" pointer is, please do not reply. Thanks!
0
Comment
Question by:dangould
6 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16862775
In what context ? Are you using classes in your VBScript ?
0
 

Author Comment

by:dangould
ID: 16863251
Yes, I should have mentioned that this is a class/object based design.

Thank you for the clarification question.
0
 
LVL 6

Expert Comment

by:inviser
ID: 16865375
ASP has very poor support for object-oriented programming. There is no support for the 'this' pointer within an object method. ASP does not provide functionality for pointers anyways, so this makes sense. My suggestion, do as much of your programming in C++, put it in a COM object, and then implement it in ASP.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:dangould
ID: 16866813
Unfortunately, my application has to be 100% script based, for portability reasons.

I agree that VBScript support for classes is limited, but what's there actually works pretty well. You can pass an object handle through a subroutine call, store it in an array or in a dictionary object. That's pretty flexible for a scripting language.

I've been experimenting with emulating the "this" pointer like this...

   Set oClass = New ClassName
   ClassName.this = oClass

Where "this" is a property defined withing clsClassName. You can then use this.property inside a class definition more or less like in C++.
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 1000 total points
ID: 16867494
Isn't Me supported in VBScript?  Yeah.  It is.

<%
class Test

   dim myVar

   sub myMethod
        dim myVar
      Me.myVar = "hello"
       myVar = "local variable"
   end sub

end class

dim o1
set o1 = new Test

o1.myMethod
response.write o1.myVar
%>
0
 

Author Comment

by:dangould
ID: 16871320
clockwatcher: You are soooo right, and I have confirmed that your sample code works in my case. Since reading your post, I found the following brief description on using the "Me" pointer in VBScript.

    http://experts.about.com/q/Active-Server-Pages-1452/understand-ASP-page-object.htm

Thank you for your assistance and excellent code sample.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question