Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Xpounded CheezWiz


The CheezeWiz Wizard

     Xpounded brings you the CheezWiz Wizard.
I've chosen to write the implementation in VBS limiting its operation to Explorer enviornments
CheezWiz is a cool idea designd to easily implement code reuse where you have many variants on a base code.
A simple example would be the div statement. Let's say that when you make a div you usually use the color and background style properties, but you wind up altering their values according to your needs.
With CheezWiz, you write the code just once, and from then on, you use the CheezWiz Wizard to create your code for you.

Algorithm Key:
The key to the algorithm is specified delimiters. I've chosen brackets as the delimiters.
bracketed values will act like variables, the brackets along with the content in the brackets act as the variable name.
These bracketed values are used in a multi-line string that the CheezeWiz will parse.
When CheezWiz parses such a string, it replaces all occurance of the bracketed value with a new value the user provides via an inputbox.

USE:
You have to feed the CheezeWiz Algoritm a specifically formatted string that it will parse, createing your simple wizard.
    Requirements
  • Bracket variables always come first in the parse string.
  • You can place a default value immediately after a bracket variable.
  • Place the bracket variable at the point in the string you want to use it.
(The string refered to is a multi-line string)
The example below should clear this up a bit - try it out!
(You can try writting your own wiz here. Just match up the bracket variables)

Try It!
Source for the CheezeWizThe CheezWiz Result


This small div example only hints at the use of the CheezeWiz. It really comes into its own when you start designing more complex structures and code segments.

CheezWiz Sorce Code:
[START...]

Function CheezWiz(sTextString)
Dim dummyVar(100)
Dim dummyVarContent(100)
Dim cnt
Dim wizContent
Dim varLocation
Dim contetnInsert
Dim intermediateString
Dim returnString
    cnt = 0
    wizContent = Split(sTextString, vbCrLf)
    For i = 0 To UBound(wizContent)
        If left(wizContent(i), 1) = "[" Then
            varLocation = InStr(1, wizContent(i), "]")
            If varLocation > 0 Then
                dummyVar(cnt) = Mid(wizContent(i), 2, varLocation - 2)
                dummyVarContent(cnt) = Trim(Right(wizContent(i), Len(wizContent(i)) - varLocation))
                dummyVarContent(cnt) = InputBox(dummyVar(cnt), "CheezeWiz Input Variable", dummyVarContent(cnt))
                cnt = cnt + 1
            End If
        Else
            Exit For
        End If
    Next
    For i = cnt To UBound(wizContent)
        intermediateString = wizContent(i)
        'If intermediateString <> "" Then
            For j = 0 To UBound(dummyVar)
                If dummyVarContent(j) <> "" Then
                    contetnInsert = "[" + dummyVar(j) & "]"
                    intermediateString = Replace(intermediateString, contetnInsert, dummyVarContent(j), 1, -1, vbBinaryCompare)
                End If
            Next
            intermediateString = intermediateString & vbCrLf
            returnString = returnString & intermediateString
        'End If
    Next
	returnString = returnString & vbCrLf
	CheezWiz=returnString
End Function

[...END]

- Copyright 2003 Xpounded -
All JS code developed by Xpounded is developed in RHSCoder.
All VBS code developed by Xpounded is developed in VBS QuickDev IDE, or RHSCoder.
Privacy Statement
Feedback