Skip to content

badursun/ASP-Dynamic-Include

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

VBScript Dynamic Includes

A simple utilitary library to provide real dynamic includes in Classic ASP.

There are not many relevent new resources to be added in this project, so certainly it won't be updated frequenly.

Parsing proccess

The inclusion is made reading and parsing the files, converting all plain-text blocks to sequences of Response.Write commands. Short ASP output tags (<%=) in are expanded to Response.Write commands.

During the previous steps, all ASP tags (<% and >%) are removed from the code.
At the end of this proccess, all plain text is conveted to VBScript output with valid code.

Warning: If a included file contains class declarations it will be executed on the global namespace - it's a simple fix for a VBScript limitation.

This library is not meant to be used in pure VBScript projects, because such complex parsing isn't even needed for plain .vbs files.

Provided Include Methods

There are two include methods, inspired in PHP way of including files:

  • Include(string File)
    Tries to include a file on current script. If no errors occur file is included, else just fails quietly.
  • Require(string File)
    Tries to include a file on current script. If no errors occur file is included, else ends script execution with error message.

Additional Methods

The following extra methods are also provided with the library, because they are internaly used by Include and Require:

  • ExecuteFile( string File, FileSystemObject System)
    Imports and executes File in the global namespace.
  • boolean FileDoExist( string File, FileSystemObject System)
    Checks if File does exist in System. Useful to avoid extra FileSystemObject allocation.
  • boolean FileExists( string File)
    Checks if File exist.
  • string FileName( string File)
    Gets the name of the file.
  • string FilePath( string File)
    Gets the path of a file.
  • FileSystemObject FileSystem( )
    Syntax sugar.
  • string MapPath( string File)
    Gets the absolute equivalent of Path.
  • string ParseFile( string File)
    Reads File as ASP code.
  • string ReadFile( string File)
    Reads File as plain text.

About

A simple utilitary library to provide *real* dynamic includes in Classic ASP.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Classic ASP 100.0%