A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_URI::$config is deprecated

Filename: core/URI.php

Line Number: 101

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Router::$uri is deprecated

Filename: core/Router.php

Line Number: 127

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$benchmark is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$hooks is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$config is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$log is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$utf8 is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$uri is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$exceptions is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$router is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$output is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$security is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$input is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$lang is deprecated

Filename: core/Controller.php

Line Number: 75

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property Pages::$load is deprecated

Filename: core/Controller.php

Line Number: 78

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$benchmark is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$hooks is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$config is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$log is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$utf8 is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$uri is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$exceptions is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$router is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$output is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$security is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$input is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$lang is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Loader::$load is deprecated

Filename: core/Loader.php

Line Number: 925

Backtrace:

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 147
Function: view

File: /home/project-web/vbscript-development-kit/htdocs/application/controllers/Pages.php
Line: 111
Function: loadPage

File: /home/project-web/vbscript-development-kit/htdocs/index.php
Line: 315
Function: require_once

VDK - create your own library

Create your own VDK Library

August 21, 2017Posted by Jason Ely

 

While the VDK comes standard with many libraries that you can use out of the box, it also offers you the capability to write your own libraries for use in your own projects. The below example shows you how to do that.

In the below example, I'm going to build an imaginary mathematics library. If I had to do this without the VDK, I would write some VBScript code (either procedural or OO), put all the code in one VBScript file, save that and execute like so:

                                                    intNum1 = 10
                                                    intNum2 = 20

                                                    Set objAddition = New clsAddition
                                                    Set objSubtraction = New clsSubtraction
                                                    Set objMultiplication = New clsMultiplication
                                                    Set objDivision = New clsDivision

                                                    val = objAddition.add2Numbers(intNum1, intNum2)
                                                    val = objSubtraction.subtract2Numbers(intNum1, intNum2)
                                                    val = objMultiplication.multiply2Numbers(intNum1, intNum2)
                                                    val = objDivision.divide2Numbers(intNum1, intNum2)

                                                    Class clsAddition
                                                            '/**
                                                            '

A demo class to show how to build your 'own libraries in the VDK.

' '@author Jason Ely '/ public function add2Numbers(intNum1, intNum2) '/** '

Adds 2 numbers and return the results.

' '@author Jason '@param intNum1 a numeric integer '@param intNum2 a numeric integer '/ If IsNumeric(intNum1) And IsNumeric(intNum2) then add2Numbers = intNum1 + intNum2 End If end function end Class class clsSubtraction '/** '

A demo class to show how to build your 'own libraries in the VDK.

' '@author Jason Ely '/ public function subtract2Numbers(intNum1, intNum2) '/** '

subtracts 2 numbers and return the results.

' '@author Jason '@param intNum1 a numeric integer '@param intNum2 a numeric integer '/ If IsNumeric(intNum1) And IsNumeric(intNum2) then subtract2Numbers = intNum1 - intNum2 End if end function end Class class clsMultiplication '/** '

A demo class to show how to build your 'own libraries in the VDK.

' '@author Jason Ely '/ public function multiply2Numbers(intNum1, intNum2) '/** '

multiply 2 numbers and return the results.

' '@author Jason '@param intNum1 a numeric integer '@param intNum2 a numeric integer '/ If IsNumeric(intNum1) And IsNumeric(intNum2) then multiply2Numbers = intNum1 * intNum2 End if end function end Class class clsDivision '/** '

A demo class to show how to build your 'own libraries in the VDK.

' '@author Jason Ely '/ public function divide2Numbers(intNum1, intNum2) '/** '

multiply 2 numbers and return the results.

' '@author Jason '@param intNum1 a numeric integer '@param intNum2 a numeric integer '/ If IsNumeric(intNum1) And IsNumeric(intNum2) then divide2Numbers = intNum1 / intNum2 End if end function end Class

While this approach will get the job done, you are going to start running into problems later down the line when you want to share code between various scripts. This is where most vbscript programmers start exploring ExecuteGlobal, WSF, WSC or just plain quit VBScript for another language alternative.

With the VDK, you can build your own libraries which can be shared across any vbscript WSH host. I'm going to take the above code and build a VDK mathematics compliant library.

Creating your own library path in VDK HOME

VDK_HOME is the directory in which all VDK resources and libraries live. My VDK_HOME is currently set to "c:\vdk". You can check where your VDK_HOME is by by viewing system environment variables.

VDK home in environment variables

When building your own library, you have to decide on your library path in VDK_HOME. I suggest using your organisations web address to create a directory structure. The VDK currently lives on sourceforge so I'll use io.sourceforge. Notice that I reversed the web address. To finish my new directory structure I add "math" to the last part of the path. I now have a directory structure that maps to "%VDK_HOME%\io\sourceforge\math" which looks like the below on my directory system:

VDK library directory

Once you have decided on your directory structure, you start creating your class and/or library files. I've taken the above code and put each class into a separate .vbs file with the file name being the name of the class.

VDK home in environment variables

If you have VDK Doc Viewer installed, you can now see the new libraries as in the below image.

VDK home in environment variables

Now that your libraries are built, you can reference them in a external script like so:

                                                        'Start VDK
                                                        ExecuteGlobal CreateObject("wsh.vdk.initialize").initialize

                                                        'import my math libraries that I just created
                                                        import "io.sourceforge.math.clsAddition"
                                                        import "io.sourceforge.math.clsDivision"
                                                        import "io.sourceforge.math.clsMultiplication"
                                                        import "io.sourceforge.math.clsSubtraction"

                                                        'after I have import my libraries, I can create objects
                                                        Set objAddition = New clsAddition
                                                        Set objSubtraction = New clsSubtraction
                                                        Set objMultiplication = New clsMultiplication
                                                        Set objDivision = New clsDivision

                                                        intNum1 = 10
                                                        intNum2 = 20

                                                        'Call your custom methods on the classes you just created
                                                        val = objAddition.add2Numbers(intNum1, intNum2)
                                                        val = objSubtraction.subtract2Numbers(intNum1, intNum2)
                                                        val = objMultiplication.multiply2Numbers(intNum1, intNum2)
                                                        val = objDivision.divide2Numbers(intNum1, intNum2)

                                                    

If you want to try this out yourself, you can download the DEMO project. To run the demo, do the following:

  1. Unzip the project to your VDK HOME directory.
  2. Copy the above code into a .vbs file and save.
  3. Execute the .vbs file or open the file in your favourite vbscript IDE and execute.

Share the VDK love!

I like tossing around 1's and 0's just like the next programmer but what I also like, is sharing my code so that other people can use it (free of charge!). The VDK promotes open source sharing so if you have written your own library, please share it with the rest of us by zipping it up and making it available as a download.