|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
VBScript - How to HIde a function
Hello Guys.. I am writing a code in VB script and now i want some of my functions to be hard-coded. Say the functions like instr() or now() or date() are hard-coded and the windows script host can read them directly. Now i want to have my own function which the windows script host can understand that every time i run it without asking me to re-define them every time i want to run.
Kindly help me in this regard, Thx in advance. With Regards, Nagu |
|
#2
|
|||
|
|||
|
Good day.
Personally I create modules and have a public function and then use a call function to process when needed. I.e Code:
'In main form Private Sub PrcvItem vitem = "bob" Call PrcMakeCaps(vItem) msgbox(vitem) ' now in CAPS End Sub 'in module Public sub PrcMakeCaps(vItem) vItem = UCase(vItem) End Sub |
|
#3
|
||||
|
||||
|
--moved to the Windows Scripting forum.
I fear I have bad news: what you want is not possible with scripting languages. only "high level" programming languages can create "class libraries" which is also known as DLL files. in .NET you even have Global Assembly Cache aka GAC that contain global DLL files that are part of the system, and you can add your own assemblies. your best choice would be to create DLL using VB, register that DLL on the computer that run the VBScript, and then you can have: Code:
Set myCommonLib = CreateObject("MyProject.MyCommonLib")
Call myCommonLib.SomeFunction()
...
|
|
#4
|
||||
|
||||
|
Shadow,
I don't very often get to tell you that you're wrong, but today I'm glad I get the chance because you CAN do this in VBScript. You do not need to create a COM-enabled DLL to have functionality. The Windows Script Host does in fact support class creation through the use of Windows Script Components. These components can be registered just like any DLL or OCX and accessed via their ProgID. To the end user, there is seemingly no difference.
__________________
Click the image if at any point you don't like my decision.Scripting problems? Windows questions? Ask the Windows Guru! |
|
#6
|
||||
|
||||
|
nice, in such case it's pleasure to be wrong!
![]() I'm probably too familiar with ASP VBScript, so I didn't pay much attention to the "real" VBScript - one never stop learning.. ![]() |
|
#7
|
||||
|
||||
|
Ya, there's never an end to learning.
VBScript (even within ASP) does provide a Class construct that you can use to create an object with your reusable functions. Unfortunately, it requires that class structure to appear in every script that uses it and cannot be stored externally. |
|
#8
|
||||
|
||||
|
Quote:
indeed, and that's the source of my mistake.. ![]() I wonder where's the OP? hope we didn't scare him off.. ![]() |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > VBScript - How to HIde a function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|