Wiki

Scale Your Enterprise

User Tools

Site Tools


bw2:vbscript_tool

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bw2:vbscript_tool [2020/12/15 11:48]
akoehler created
bw2:vbscript_tool [2024/09/24 16:18] (current)
dlee [Introduction (VBScript)]
Line 1: Line 1:
-====== Introduction (VBScript======+====== VBScript Tool ======
  
 The VBScript tool is used to create “programming” statements in a Bizweaver workflow using the VBScript language. The results from a VBScript step can be used as variables in subsequent workflow steps. The VBScript tool is used to create “programming” statements in a Bizweaver workflow using the VBScript language. The results from a VBScript step can be used as variables in subsequent workflow steps.
  
-VBScript can be used for a broad range of purposes. Several VBScript samples are included in **//[[bw:vbscript_tool#VBScript Samples]]//** section. A web search (Google, etc.) for “VBScript” and what you are trying to accomplish will typically provide a wealth of examples as well.+VBScript can be used for a broad range of purposes. Several VBScript samples are included in **//[[bw2:vbscript_tool#VBScript Samples]]//** section. A web search (Google, etc.) for “VBScript” and what you are trying to accomplish will typically provide a wealth of examples as well.
  
 There are two key elements to the VBScript tool setup. First is the **VBScript statement**. This is the “program code” that gets executed. There are two key elements to the VBScript tool setup. First is the **VBScript statement**. This is the “program code” that gets executed.
Line 12: Line 12:
  
 where “VariableName” is the variable that will be displayed for selection (using the <**F4**> key) in subsequent workflow steps, and ScriptValue is the value from the VBScript statement. Note that the variable name must be enclosed in double-quotes. where “VariableName” is the variable that will be displayed for selection (using the <**F4**> key) in subsequent workflow steps, and ScriptValue is the value from the VBScript statement. Note that the variable name must be enclosed in double-quotes.
- 
-In the example below, DataCalc is the value being “calculated” by the script. This value is then placed in a Bizweaver variable named “TimeStamp.” 
  
 A single VBScript step can contain multiple VBScript statements. There must be a “Return” statement for each VBScript statement. A single VBScript step can contain multiple VBScript statements. There must be a “Return” statement for each VBScript statement.
  
-{{  :bw:vbimage1.png?384x158  }}+{{ :bw2:bizweavervbs1.png |}}
  
   - Enter the Script text.   - Enter the Script text.
-      - See **//[[bw:vbscript_tool#vbscript_tips|VBScript Tips]]//** and **//[[bw:vbscript_tool#vbscript_samples|VBScript Samples]]//** for more information and sample scripts. +      - See **//[[bw2:vbscript_tool#vbscript_tips|VBScript Tips]]//** and **//[[bw2:vbscript_tool#vbscript_samples|VBScript Samples]]//** for more information and sample scripts. 
-  - Click the [**Run**] button to validate your script.+  - Click the [**Execute**] button to validate your script.
       - If the Return statements are not included the VBScript may execute normally but the validation will not present any results.       - If the Return statements are not included the VBScript may execute normally but the validation will not present any results.
-      - Using the [Run] validation will let you see exactly what value will be produced. +      - Using the [Execute] validation will let you see exactly what value will be produced. 
-      - The [Run] option may not function as expected if variables from other workflow steps are used in the VBScript. In this case, you will need to use the workflow “Test Run” (Debug) option to step through the workflow.+      - The [Execute] option may not function as expected if variables from other workflow steps are used in the VBScript. In this case, you will need to use the workflow “Test Run” (Debug) option to step through the workflow.
  
 <WRAP center round info> <WRAP center round info>
Line 518: Line 516:
 END IF END IF
 </code> </code>
 +
 +==== Find and Replace seconds of a text file ====
 +<code>
 +Const ForReading = 1
 +Const ForWriting = 2
 +Dim fs
 +Dim fname
 +Dim HasCert
 +Dim vStartNum 
 +Dim vLength
 +Dim FileIndex 
 +vStartNum = 1
 +vSourcePath = "WorkFlow(GetCustomerFiles).Get(FileName)"
 +vTargetPath = "WorkFlow(GetCustomerFiles).Get(SourcePath)\Working\"
 +Set objfso = CreateObject("Scripting.FileSystemObject")
 +Set objFile = objfso.OpenTextFile(vSourcePath, ForReading)
 +strtext = objFile.ReadAll
 +sSearchString1 = "<customer"
 +sSearchString2 = "</customer>"
 +objFile.Close
 +While InStr(vStartNum, strtext, sSearchString1) > 0
 +    FileIndex = FileIndex + 1
 +    vStartNum = InStr(vStartNum, strtext, sSearchString1)
 +    vLength = InStr(vStartNum, strtext, sSearchString2) - InStr(vStartNum, strtext, sSearchString1) + 11
 +    strNewText = Mid(strtext, vStartNum, vLength)
 +    Set fname = objfso.CreateTextFile(vTargetPath & "WorkFlow(GetCustomerFiles).Get(FileTitleWithoutExtension)" & "_" & FileIndex & ".xml", True)
 +    fname.WriteLine strNewText
 +    fname.Close
 +    vStartNum = InStr(vStartNum, strtext, sSearchString2) + 11
 +Wend
 +</code>
 +
 +====VB Script Variables====
 +
 +^ Name           ^ Description          ^
 +|ScriptCode|The actual VBScript code that is written in the tool|
 +|StepMessage| During a failure the reason for failure will be populated here|
 +|StepStatus| True or False|
 +
 +----
 +**[[bizweaver:Home|Home]]**
bw2/vbscript_tool.1608050927.txt.gz · Last modified: 2020/12/15 11:48 by akoehler