Search is not available for this dataset
content
stringlengths 0
376M
|
---|
'The combination of holding to the second fork
'(HOLDON=True) and all philosophers start
'with same hand (DIJKSTRASOLUTION=False) leads
'to a deadlock. To prevent deadlock
'set HOLDON=False, and DIJKSTRASOLUTION=True.
Public Const HOLDON = False
Public Const DIJKSTRASOLUTION = True
Public Const X = 10 'chance to continue eating/thinking
Public Const GETS = 0
Public Const PUTS = 1
Public Const EATS = 2
Public Const THKS = 5
Public Const FRSTFORK = 0
Public Const SCNDFORK = 1
Public Const SPAGHETI = 0
Public Const UNIVERSE = 1
Public Const MAXCOUNT = 100000
Public Const PHILOSOPHERS = 5
Public semaphore(PHILOSOPHERS - 1) As Integer
Public positi0n(1, PHILOSOPHERS - 1) As Integer
Public programcounter(PHILOSOPHERS - 1) As Long
Public statistics(PHILOSOPHERS - 1, 5, 1) As Long
Public names As Variant
Private Sub init()
names = [{"Aquinas","Babbage","Carroll","Derrida","Erasmus"}]
For j = 0 To PHILOSOPHERS - 2
positi0n(0, j) = j + 1 'first fork in right hand
positi0n(1, j) = j 'second fork in left hand
Next j
If DIJKSTRASOLUTION Then
positi0n(0, PHILOSOPHERS - 1) = j ' first fork in left hand
positi0n(1, PHILOSOPHERS - 1) = 0 'second fork in right hand
Else
positi0n(0, PHILOSOPHERS - 1) = 0 'first fork in right hand
positi0n(1, PHILOSOPHERS - 1) = j 'second fork in left hand
End If
End Sub
Private Sub philosopher(subject As Integer, verb As Integer, objekt As Integer)
statistics(subject, verb, objekt) = statistics(subject, verb, objekt) + 1
If verb < 2 Then
If semaphore(positi0n(objekt, subject)) <> verb Then
If Not HOLDON Then
'can't get a fork, release first fork if subject has it, and
'this won't toggle the semaphore if subject hasn't firt fork
semaphore(positi0n(FRSTFORK, subject)) = 1 - objekt
'next round back to try to get first fork
programcounter(subject) = 0
End If
Else
'just toggle semaphore and move on
semaphore(positi0n(objekt, subject)) = 1 - verb
programcounter(subject) = (programcounter(subject) + 1) Mod 6
End If
Else
'when eating or thinking, (100*(X-1)/X)% continue eating or thinking
'(100/X)% advance program counter
programcounter(subject) = IIf(X * Rnd > 1, verb, verb + 1) Mod 6
End If
End Sub
Private Sub dine()
Dim ph As Integer
Do While TC < MAXCOUNT
For ph = 0 To PHILOSOPHERS - 1
Select Case programcounter(ph)
Case 0: philosopher ph, GETS, FRSTFORK
Case 1: philosopher ph, GETS, SCNDFORK
Case 2: philosopher ph, EATS, SPAGHETI
Case 3: philosopher ph, PUTS, FRSTFORK
Case 4: philosopher ph, PUTS, SCNDFORK
Case 5: philosopher ph, THKS, UNIVERSE
End Select
TC = TC + 1
Next ph
Loop
End Sub
Private Sub show()
Debug.Print "Stats", "Gets", "Gets", "Eats", "Puts", "Puts", "Thinks"
Debug.Print "", "First", "Second", "Spag-", "First", "Second", "About"
Debug.Print "", "Fork", "Fork", "hetti", "Fork", "Fork", "Universe"
For subject = 0 To PHILOSOPHERS - 1
Debug.Print names(subject + 1),
For objekt = 0 To 1
Debug.Print statistics(subject, GETS, objekt),
Next objekt
Debug.Print statistics(subject, EATS, SPAGHETI),
For objekt = 0 To 1
Debug.Print statistics(subject, PUTS, objekt),
Next objekt
Debug.Print statistics(subject, THKS, UNIVERSE)
Next subject
End Sub
Public Sub main()
init
dine
show
End Sub
|
Public Sub test()
Dim filesystem As Object, stream As Object, line As String
Set filesystem = CreateObject("Scripting.FileSystemObject")
Set stream = filesystem.OpenTextFile("D:\test.txt")
Do While stream.AtEndOfStream <> True
line = stream.ReadLine
Debug.Print line
Loop
stream.Close
End Sub
|
Option Explicit
Dim a, b
Select Case WScript.Arguments.Count
Case 0 'No arguments, prompt for them.
WScript.Echo "Enter values for a and b"
a = WScript.Stdin.ReadLine
if Instr(a, " ") > 0 then 'If two variables were passed
b = Split(a)(1)
a = Split(a)(0)
else
WScript.Echo "Enter value for b"
b = WScript.Stdin.ReadLine
end if
Case 1 'One argument, assume it's an input file, e.g. "in.txt"
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
With FSO.OpenTextFile(WScript.Arguments(0), 1)
a = .ReadLine
b = Split(a)(1)
a = Split(a)(0)
.Close
End With
Case 2 'Two arguments, assume they are values
a = WScript.Arguments(0)
b = WScript.Arguments(1)
End Select
'At this point, a and b are strings as entered, make them numbers
a = CInt(a)
b = CInt(b)
'Write the sum
Wscript.Echo a + b
if 1 = WScript.Arguments.Count then
With FSO.CreateTextFile("out.txt")
.WriteLine a + b
.Close
End With
end if
|
<gh_stars>1-10
Sub triangle(o)
n = 2 ^ o
Dim line()
ReDim line(2*n)
line(n) = "*"
i = 0
Do While i < n
WScript.StdOut.WriteLine Join(line,"")
u = "*"
j = n - i
Do While j < (n+i+1)
If line(j-1) = line(j+1) Then
t = " "
Else
t = "*"
End If
line(j-1) = u
u = t
j = j + 1
Loop
line(n+i) = t
line(n+i+1) = "*"
i = i + 1
Loop
End Sub
triangle(4)
|
VERSION 5.00
Begin VB.Form Dialog
BorderStyle = 3 'Fixed Dialog
Caption = "Operation Results"
ClientHeight = 6015
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 11040
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6015
ScaleWidth = 11040
ShowInTaskbar = 0 'False
Begin VB.ListBox ListDisabled
Height = 2010
ItemData = "ResultsDialog.frx":0000
Left = 7680
List = "ResultsDialog.frx":0002
Sorted = -1 'True
TabIndex = 8
Top = 2280
Width = 2175
End
Begin VB.ListBox ListMissingEnabled
Height = 2010
ItemData = "ResultsDialog.frx":0004
Left = 4200
List = "ResultsDialog.frx":0006
Sorted = -1 'True
TabIndex = 7
Top = 2280
Width = 2175
End
Begin VB.Frame Frame4
Caption = "Unsuccessfully Disabled"
Height = 2895
Left = 7440
TabIndex = 5
Top = 1800
Width = 2655
End
Begin VB.Frame Frame3
Caption = "Missing Enabled"
Height = 2895
Left = 3960
TabIndex = 4
Top = 1800
Width = 2655
End
Begin VB.Frame Frame2
Caption = "Enabled"
Height = 2895
Left = 600
TabIndex = 3
Top = 1800
Width = 2655
Begin VB.ListBox ListEnabled
Height = 2010
ItemData = "ResultsDialog.frx":0008
Left = 240
List = "ResultsDialog.frx":000A
Sorted = -1 'True
TabIndex = 6
Top = 480
Width = 2175
End
End
Begin VB.Frame Frame1
Caption = "Status"
Height = 735
Left = 360
TabIndex = 1
Top = 240
Width = 3135
Begin VB.Label Status
Caption = "Undefined"
BeginProperty Font
Name = "Verdana"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 720
TabIndex = 2
Top = 240
Width = 2175
End
End
Begin VB.CommandButton CancelButton
Cancel = -1 'True
Caption = "Exit"
Height = 375
Left = 4680
TabIndex = 0
Top = 5400
Width = 1215
End
Begin VB.Frame Frame5
Caption = "Privilege Settings"
Height = 3855
Left = 360
TabIndex = 9
Top = 1320
Width = 10215
End
End
Attribute VB_Name = "Dialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub CancelButton_Click()
Unload Me
End Sub
Sub SetData(providerInfo As SWbemLastError)
On Error Resume Next
If Not providerInfo Is Nothing Then
'Look for the status property
Dim property As SWbemProperty
Set property = providerInfo.Properties_!Status
If Err = 0 Then
If property.Value = False Then
Status.Caption = "Failed"
Else
Status.Caption = "Success"
End If
Else
Status.Caption = "Unknown"
Err.Clear
End If
'Look for enabled privileges
Set property = providerInfo.Properties_!EnabledPrivilegeList
If Err = 0 Then
For i = LBound(property.Value) To UBound(property.Value)
ListEnabled.AddItem property(i)
Next
Else
Err.Clear
End If
'Look for missing enabled privileges
Set property = providerInfo.Properties_!MissingEnabledPrivileges
If Err = 0 Then
For i = LBound(property.Value) To UBound(property.Value)
ListMissingEnabled.AddItem property(i)
Next
Else
Err.Clear
End If
'Look for unsuccessfully disabled privileges
Set property = providerInfo.Properties_!DisabledPrivilegesFoundEnabled
If Err = 0 Then
For i = LBound(property.Value) To UBound(property.Value)
ListDisabled.AddItem property(i)
Next
Else
Err.Clear
End If
End If
End Sub
|
Sub Main()
Dim temp() As String
temp = Tokenize("Hello,How,Are,You,Today", ",")
Display temp, Space(5)
End Sub
Private Function Tokenize(strS As String, sep As String) As String()
Tokenize = Split(strS, sep)
End Function
Private Sub Display(arr() As String, sep As String)
Debug.Print Join(arr, sep)
End Sub
|
VERSION 5.00
Begin VB.Form CopyKeyForm
BorderStyle = 3 'Fixed Dialog
Caption = "Copy a Key"
ClientHeight = 1845
ClientLeft = 45
ClientTop = 330
ClientWidth = 4335
Icon = "CopyKey.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1845
ScaleWidth = 4335
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.TextBox SourceText
Height = 285
Left = 1200
TabIndex = 7
Top = 120
Width = 3015
End
Begin VB.CommandButton OkButton
Cancel = -1 'True
Caption = "OK"
Default = -1 'True
Height = 345
Left = 1560
TabIndex = 6
Top = 1440
Width = 1260
End
Begin VB.CommandButton CancelButton
Caption = "Cancel"
Height = 345
Left = 3000
TabIndex = 5
Top = 1440
Width = 1260
End
Begin VB.CheckBox OverwriteCheck
Caption = "Overwrite"
Height = 195
Left = 2040
TabIndex = 3
Top = 1080
Value = 1 'Checked
Width = 1215
End
Begin VB.OptionButton MoveOption
Caption = "Move"
Height = 195
Left = 1080
TabIndex = 2
Top = 1080
Width = 855
End
Begin VB.OptionButton CopyOption
Caption = "Copy"
Height = 195
Left = 120
TabIndex = 1
Top = 1080
Value = -1 'True
Width = 855
End
Begin VB.TextBox DestText
Height = 285
Left = 1200
TabIndex = 0
Top = 600
Width = 3015
End
Begin VB.Label Label2
Caption = "Source:"
Height = 255
Left = 120
TabIndex = 8
Top = 120
Width = 975
End
Begin VB.Label Label1
Caption = "Destination:"
Height = 255
Left = 120
TabIndex = 4
Top = 600
Width = 975
End
End
Attribute VB_Name = "CopyKeyForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
DefInt A-Z
'Form Parameters
Public SourceKey As String 'In
Public Moved As Boolean 'Out
Public Sub Init()
SourceText.Text = SourceKey
SourceText.Enabled = False
DestText.Text = SourceKey
DestText.Enabled = True
End Sub
Private Sub OkButton_Click()
On Error GoTo LError
Dim Overwrite As Boolean
If OverwriteCheck.Value = vbChecked Then
Overwrite = True
Else
Overwrite = False
End If
If CopyOption.Value = True Then
MainForm.MetaUtilObj.CopyKey SourceKey, DestText.Text, Overwrite
Moved = False
ElseIf MoveOption.Value = True Then
MainForm.MetaUtilObj.MoveKey SourceKey, DestText.Text, Overwrite
Moved = True
End If
Me.Hide
Exit Sub
LError:
MsgBox "Failure to copy key: " & Err.Description, vbExclamation + vbOKOnly, "Copy a Key"
End Sub
Private Sub CancelButton_Click()
Me.Hide
End Sub
|
VERSION 5.00
Begin VB.Form frmFilterSKU
BorderStyle = 1 'Fixed Single
Caption = "Filter By SKU"
ClientHeight = 3735
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3735
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 375
Left = 3360
TabIndex = 13
Top = 3240
Width = 1215
End
Begin VB.CommandButton cmdOK
Caption = "OK"
Height = 375
Left = 2040
TabIndex = 12
Top = 3240
Width = 1215
End
Begin VB.Frame fraFilterSKUs
Caption = "&Display Nodes and Topics with the following SKUs"
Height = 3015
Left = 120
TabIndex = 0
Top = 120
Width = 4455
Begin VB.CommandButton cmdClearAll
Caption = "Clear All"
Height = 375
Left = 1440
TabIndex = 11
Top = 2520
Width = 1215
End
Begin VB.CommandButton cmdSelectAll
Caption = "Select All"
Height = 375
Left = 120
TabIndex = 10
Top = 2520
Width = 1215
End
Begin VB.CheckBox chkSKU
Caption = "Windows &Me"
Height = 255
Index = 0
Left = 120
TabIndex = 1
Top = 240
Width = 2775
End
Begin VB.CheckBox chkSKU
Caption = "64-bit Datac&enter Server"
Height = 255
Index = 8
Left = 120
TabIndex = 9
Top = 2160
Width = 2775
End
Begin VB.CheckBox chkSKU
Caption = "64-bit Ad&vanced Server"
Height = 255
Index = 6
Left = 120
TabIndex = 7
Top = 1680
Width = 2775
End
Begin VB.CheckBox chkSKU
Caption = "64-bit Pro&fessional"
Height = 255
Index = 3
Left = 120
TabIndex = 4
Top = 960
Width = 2775
End
Begin VB.CheckBox chkSKU
Caption = "32-bit Data¢er Server"
Height = 255
Index = 7
Left = 120
TabIndex = 8
Top = 1920
Width = 2775
End
Begin VB.CheckBox chkSKU
Caption = "32-bit &Advanced Server"
Height = 255
Index = 5
Left = 120
TabIndex = 6
Top = 1440
Width = 2775
End
Begin VB.CheckBox chkSKU
Caption = "32-bit &Server"
Height = 255
Index = 4
Left = 120
TabIndex = 5
Top = 1200
Width = 2775
End
Begin VB.CheckBox chkSKU
Caption = "32-bit &Professional"
Height = 255
Index = 2
Left = 120
TabIndex = 3
Top = 720
Width = 2775
End
Begin VB.CheckBox chkSKU
Caption = "32-bit P&ersonal"
Height = 255
Index = 1
Left = 120
TabIndex = 2
Top = 480
Width = 2775
End
End
End
Attribute VB_Name = "frmFilterSKU"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Enum SKU_INDEX_E
SI_WINDOWS_MILLENNIUM_E = 0
SI_STANDARD_E = 1
SI_PROFESSIONAL_E = 2
SI_PROFESSIONAL_64_E = 3
SI_SERVER_E = 4
SI_ADVANCED_SERVER_E = 5
SI_ADVANCED_SERVER_64_E = 6
SI_DATA_CENTER_SERVER_E = 7
SI_DATA_CENTER_SERVER_64_E = 8
End Enum
Private enumSKUs As SKU_E
Private Sub Form_Activate()
cmdCancel.Cancel = True
p_SetSelectedSKUs
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set frmFilterSKU = Nothing
End Sub
Private Sub cmdSelectAll_Click()
enumSKUs = ALL_SKUS_C
p_SetSelectedSKUs
End Sub
Private Sub cmdClearAll_Click()
enumSKUs = 0
p_SetSelectedSKUs
End Sub
Private Sub cmdOK_Click()
frmMain.SetSKUs p_GetSelectedSKUs
Unload Me
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Public Sub SetSKUs( _
ByVal i_enumSKUs As SKU_E _
)
enumSKUs = i_enumSKUs
End Sub
Private Function p_GetSelectedSKUs() As SKU_E
Dim enumSelectedSKUs As SKU_E
If (chkSKU(SI_WINDOWS_MILLENNIUM_E).Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_WINDOWS_MILLENNIUM_E
End If
If (chkSKU(SI_STANDARD_E).Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_STANDARD_E
End If
If (chkSKU(SI_PROFESSIONAL_E).Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_PROFESSIONAL_E
End If
If (chkSKU(SI_PROFESSIONAL_64_E).Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_PROFESSIONAL_64_E
End If
If (chkSKU(SI_SERVER_E).Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_SERVER_E
End If
If (chkSKU(SI_ADVANCED_SERVER_E).Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_ADVANCED_SERVER_E
End If
If (chkSKU(SI_ADVANCED_SERVER_64_E).Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_ADVANCED_SERVER_64_E
End If
If (chkSKU(SI_DATA_CENTER_SERVER_E).Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_DATA_CENTER_SERVER_E
End If
If (chkSKU(SI_DATA_CENTER_SERVER_64_E).Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_DATA_CENTER_SERVER_64_E
End If
p_GetSelectedSKUs = enumSelectedSKUs
End Function
Private Sub p_SetSelectedSKUs()
If (enumSKUs And SKU_WINDOWS_MILLENNIUM_E) Then
chkSKU(SI_WINDOWS_MILLENNIUM_E).Value = 1
Else
chkSKU(SI_WINDOWS_MILLENNIUM_E).Value = 0
End If
If (enumSKUs And SKU_STANDARD_E) Then
chkSKU(SI_STANDARD_E).Value = 1
Else
chkSKU(SI_STANDARD_E).Value = 0
End If
If (enumSKUs And SKU_PROFESSIONAL_E) Then
chkSKU(SI_PROFESSIONAL_E).Value = 1
Else
chkSKU(SI_PROFESSIONAL_E).Value = 0
End If
If (enumSKUs And SKU_PROFESSIONAL_64_E) Then
chkSKU(SI_PROFESSIONAL_64_E).Value = 1
Else
chkSKU(SI_PROFESSIONAL_64_E).Value = 0
End If
If (enumSKUs And SKU_SERVER_E) Then
chkSKU(SI_SERVER_E).Value = 1
Else
chkSKU(SI_SERVER_E).Value = 0
End If
If (enumSKUs And SKU_ADVANCED_SERVER_E) Then
chkSKU(SI_ADVANCED_SERVER_E).Value = 1
Else
chkSKU(SI_ADVANCED_SERVER_E).Value = 0
End If
If (enumSKUs And SKU_ADVANCED_SERVER_64_E) Then
chkSKU(SI_ADVANCED_SERVER_64_E).Value = 1
Else
chkSKU(SI_ADVANCED_SERVER_64_E).Value = 0
End If
If (enumSKUs And SKU_DATA_CENTER_SERVER_E) Then
chkSKU(SI_DATA_CENTER_SERVER_E).Value = 1
Else
chkSKU(SI_DATA_CENTER_SERVER_E).Value = 0
End If
If (enumSKUs And SKU_DATA_CENTER_SERVER_64_E) Then
chkSKU(SI_DATA_CENTER_SERVER_64_E).Value = 1
Else
chkSKU(SI_DATA_CENTER_SERVER_64_E).Value = 0
End If
End Sub
|
Public Sub LetterFrequency(fname)
'count number of letters in text file "fname" (ASCII-coded)
'note: we count all characters but print only the letter frequencies
Dim Freqs(255) As Long
Dim abyte As Byte
Dim ascal as Byte 'ascii code for lowercase a
Dim ascau as Byte 'ascii code for uppercase a
'try to open the file
On Error GoTo CantOpen
Open fname For Input As #1
On Error GoTo 0
'initialize
For i = 0 To 255
Freqs(i) = 0
Next i
'process file byte-per-byte
While Not EOF(1)
abyte = Asc(Input(1, #1))
Freqs(abyte) = Freqs(abyte) + 1
Wend
Close #1
'add lower and upper case together and print result
Debug.Print "Frequencies:"
ascal = Asc("a")
ascau = Asc("A")
For i = 0 To 25
Debug.Print Chr$(ascal + i), Freqs(ascal + i) + Freqs(ascau + i)
Next i
Exit Sub
CantOpen:
Debug.Print "can't find or read the file "; fname
Close
End Sub
|
<filename>Task/Count-the-coins/VBScript/count-the-coins.vb<gh_stars>1-10
Function count(coins,m,n)
ReDim table(n+1)
table(0) = 1
i = 0
Do While i < m
j = coins(i)
Do While j <= n
table(j) = table(j) + table(j - coins(i))
j = j + 1
Loop
i = i + 1
Loop
count = table(n)
End Function
'testing
arr = Array(1,5,10,25)
m = UBound(arr) + 1
n = 100
WScript.StdOut.WriteLine count(arr,m,n)
|
<filename>Task/Binary-strings/VBA/binary-strings-4.vba
Sub String_Comparison_FirstWay()
Dim A$, B$, C$
If A = B Then Debug.Print "A = B"
A = "creation": B = "destruction": C = "CREATION"
'test equality : (operator =)
If A = B Then
Debug.Print A & " = " & B
'used to Sort : (operator < and >)
ElseIf A > B Then
Debug.Print A & " > " & B
Else 'here : A < B
Debug.Print A & " < " & B
End If
'test if A is different from C
If A <> C Then Debug.Print A & " and " & B & " are differents."
'same test without case-sensitive
If UCase(A) = UCase(C) Then Debug.Print A & " = " & C & " (no case-sensitive)"
'operator Like :
If A Like "*ation" Then Debug.Print A & " Like *ation"
If Not B Like "*ation" Then Debug.Print B & " Not Like *ation"
'See Also :
'https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/like-operator
End Sub
|
<gh_stars>10-100
' Windows Installer utility to report or update file versions, sizes, languages
' For use with Windows Scripting Host, CScript.exe or WScript.exe
' Copyright (c) 1999-2000, Microsoft Corporation
' Demonstrates the access to install engine and actions
'
Option Explicit
' FileSystemObject.CreateTextFile and FileSystemObject.OpenTextFile
Const OpenAsASCII = 0
Const OpenAsUnicode = -1
' FileSystemObject.CreateTextFile
Const OverwriteIfExist = -1
Const FailIfExist = 0
' FileSystemObject.OpenTextFile
Const OpenAsDefault = -2
Const CreateIfNotExist = -1
Const FailIfNotExist = 0
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const msiOpenDatabaseModeReadOnly = 0
Const msiOpenDatabaseModeTransact = 1
Const msiViewModifyInsert = 1
Const msiViewModifyUpdate = 2
Const msiViewModifyAssign = 3
Const msiViewModifyReplace = 4
Const msiViewModifyDelete = 6
Const msiUILevelNone = 2
Const msiRunModeSourceShortNames = 9
Const msidbFileAttributesNoncompressed = &h00002000
Dim argCount:argCount = Wscript.Arguments.Count
Dim iArg:iArg = 0
If (argCount < 2) Then
Wscript.Echo "Windows Installer utility to updata File table sizes and versions" &_
vbNewLine & " The 1st argument is the path to MSI database, at the source file root" &_
vbNewLine & " The 2nd argument specifies the source file directory" &_
vbNewLine & " The following options may be specified at any point on the command line" &_
vbNewLine & " /U to update the MSI database with the file sizes, versions, and languages" &_
vbNewLine & " Notes:" &_
vbNewLine & " If source type set to compressed, all files will be opened at the root" &_
vbNewLine & " Using CSCRIPT.EXE without the /U option, the file info will be displayed" &_
vbNewLine &_
vbNewLine & "Copyright (C) Microsoft Corporation, 1999-2000. All rights reserved."
Wscript.Quit 1
End If
' Get argument values, processing any option flags
Dim updateMsi : updateMsi = False
Dim sequenceFile : sequenceFile = False
Dim databasePath : databasePath = NextArgument
Dim sourceFolder : sourceFolder = NextArgument
If Not IsEmpty(NextArgument) Then Fail "More than 2 arguments supplied" ' process any trailing options
If Not IsEmpty(sourceFolder) And Right(sourceFolder, 1) <> "\" Then sourceFolder = sourceFolder & "\"
Dim console : If UCase(Mid(Wscript.FullName, Len(Wscript.Path) + 2, 1)) = "C" Then console = True
' Connect to Windows Installer object
On Error Resume Next
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError
' Check if multiple language package, and force use of primary language
REM Set sumInfo = database.SummaryInformation(3) : CheckError
' Open database
Dim database, openMode, view, record, updateMode, sumInfo
If updateMsi Then openMode = msiOpenDatabaseModeTransact Else openMode = msiOpenDatabaseModeReadOnly
Set database = installer.OpenDatabase(databasePath, openMode) : CheckError
' Create an install session and execute actions in order to perform directory resolution
installer.UILevel = msiUILevelNone
Dim session : Set session = installer.OpenPackage(database,1) : If Err <> 0 Then Fail "Database: " & databasePath & ". Invalid installer package format"
Dim shortNames : shortNames = session.Mode(msiRunModeSourceShortNames) : CheckError
'REM If Not IsEmpty(sourceFolder) Then session.Property("OriginalDatabase") = sourceFolder : CheckError
Dim stat : stat = session.DoAction("CostInitialize") : CheckError
If stat <> 1 Then Fail "CostInitialize failed, returned " & stat
Set view = database.OpenView("SELECT File,FileSize,Version,Language,Sequence FROM File ORDER BY File") : CheckError
view.Execute : CheckError
wscript.echo "Updating File properties in the MSI"
Dim objFS : Set objFS=WScript.CreateObject ("Scripting.FileSystemObject")
Dim cabFileFolder : Set cabFileFolder=objFS.GetFolder(sourceFolder) : CheckError
Dim g_cabFileList : Set g_cabFileList = cabFileFolder.Files : CheckError
Dim objFile, nIndex
Dim g_cabFileArray(600)
If (g_cabFileList.Count > 600) Then Fail "Need to increase max file count constant beyond 600"
nIndex = 1
'
' Fill the array of files from the collection. The binary search for
' the files relies on the fact that this collection is alphabetized already.
'
For Each objFile In g_cabFileList
Set g_cabFileArray(nIndex) = objFile
nIndex = nIndex + 1
Next
' Fetch each file and request the source path, then verify the source path, and get the file info if present
Dim fileKey, sourcePath, fileSize, version, language, message, info, nFileCount, nLastIndex
nLastIndex = Round(g_cabFileList.Count / 2)
nFileCount = 0
Do
nFileCount = nFileCount + 1
Set record = view.Fetch : CheckError
If record Is Nothing Then Exit Do
fileKey = record.StringData(1)
REM fileSize = record.IntegerData(2)
REM version = record.StringData(3)
REM language = record.StringData(4)
REM sequence = record.StringData(5)
'wscript.echo nFileCount & ": " & fileKey
sourcePath = sourceFolder & fileKey
If installer.FileAttributes(sourcePath) = -1 Then
message = message & vbNewLine & sourcePath
Else
fileSize = installer.FileSize(sourcePath) : CheckError
version = Empty : version = installer.FileVersion(sourcePath, False) : Err.Clear ' early MSI implementation fails if no version
language = Empty : language = installer.FileVersion(sourcePath, True) : Err.Clear ' early MSI implementation doesn't support language
If language = version Then language = Empty ' Temp check for MSI.DLL version without language support
If Err <> 0 Then version = Empty : Err.Clear
If updateMsi Then
record.IntegerData(2) = fileSize
If Len(version) > 0 Then record.StringData(3) = version
If Len(language) > 0 Then record.StringData(4) = language
nIndex = GetFileIndex(fileKey, nLastIndex)
record.IntegerData(5) = nIndex
view.Modify msiViewModifyUpdate, record : CheckError
nLastIndex = nIndex + 1
ElseIf console Then
info = fileName : If Len(info) < 12 Then info = info & Space(12 - Len(info))
info = info & " size=" & fileSize : If Len(info) < 26 Then info = info & Space(26 - Len(info))
If Len(version) > 0 Then info = info & " vers=" & version : If Len(info) < 45 Then info = info & Space(45 - Len(info))
If Len(language) > 0 Then info = info & " lang=" & language
Wscript.Echo info
End If
End If
Loop
REM Wscript.Echo "SourceDir = " & session.Property("SourceDir")
If Not IsEmpty(message) Then Fail "Error, the following files were not available:" & message
' Update SummaryInformation
If updateMsi Then
Set sumInfo = database.SummaryInformation(3) : CheckError
sumInfo.Property(11) = Now
sumInfo.Property(13) = Now
sumInfo.Persist
End If
' Commit database in case updates performed
database.Commit : CheckError
Wscript.Quit 0
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' GetFileIndex
'
' Description
' Performs a binary search for a file in an alphabetized list so that
' the sequence number can be changed to match the index of the file
' in the CAB.
'
' Parameters
' strFilename Filename to search for
' nIndex A best guess of where to start looking
' in the array for the filename
'
' Returns
' The index of the file in the list
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetFileIndex(strFilename, nIndx)
Dim nMin, nMax, nRound, nCompare
'
' nMin and nMax are the inclusive boundaries where the file can be found
' in the array
'
nMin = 1
nMax = g_cabFileList.Count
If (nIndx > nMax) OR (nIndx < nMin) Then nIndx = Round(nMax / 2)
nRound = 1
Do
'wscript.echo "Entering loop: min=" & nMin & " max=" & nMax & " current=" & nIndx
nCompare = StrComp(strFilename, g_cabFileArray(nIndx).Name, 1)
If nCompare = 0 Then
Exit Do 'Found the string
ElseIf nCompare < 0 Then
nMax = nIndx - 1 'The string is in the lower half of the bounds
Else
nMin = nIndx + 1 'The string is in the upper half of the bounds
End If
nIndx = Round((nMax + nMin) / 2)
If nMax < nMin Then Fail "ERROR: Could not find file " & strFilename & " in CAB directory. Files may not be sorted properly"
nRound = nRound + 1
Loop
'wscript.echo "Index for " & strFilename & " is " & nIndx & " (" & nRound & " tries)"
GetFileIndex = nIndx
End Function
' Extract argument value from command line, processing any option flags
Function NextArgument
Dim arg
Do ' loop to pull in option flags until an argument value is found
If iArg >= argCount Then Exit Function
arg = Wscript.Arguments(iArg)
iArg = iArg + 1
If (AscW(arg) <> AscW("/")) And (AscW(arg) <> AscW("-")) Then Exit Do
Select Case UCase(Right(arg, Len(arg)-1))
Case "U" : updateMsi = True
Case Else: Wscript.Echo "Invalid option flag:", arg : Wscript.Quit 1
End Select
Loop
NextArgument = arg
End Function
Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & " " & Hex(Err) & ": " & Err.Description & ", " & Err.number
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbNewLine & errRec.FormatText
End If
Fail message
End Sub
Sub Fail(message)
Wscript.Echo message
Wscript.Quit 2
End Sub
|
Public Sub substring()
'(1) starting from n characters in and of m length;
'(2) starting from n characters in, up to the end of the string;
'(3) whole string minus last character;
'(4) starting from a known character within the string and of m length;
'(5) starting from a known substring within the string and of m length.
sentence = "the last thing the man said was the"
n = 10: m = 5
'(1)
Debug.Print Mid(sentence, n, 5)
'(2)
Debug.Print Right(sentence, Len(sentence) - n + 1)
'(3)
Debug.Print Left(sentence, Len(sentence) - 1)
'(4)
k = InStr(1, sentence, "m")
Debug.Print Mid(sentence, k, 5)
'(5)
k = InStr(1, sentence, "aid")
Debug.Print Mid(sentence, k, 5)
End Sub
|
<gh_stars>1-10
' Factors of a Mersenne number
for i=1 to 59
z=i
if z=59 then z=929 ':) 61 turns into 929.
if isPrime(z) then
r=testM(z)
zz=left("M" & z & space(4),4)
if r=0 then
Wscript.echo zz & " prime."
else
Wscript.echo zz & " not prime, a factor: " & r
end if
end if
next
function modPow(base,n,div)
dim i,y,z
i = n : y = 1 : z = base
do while i
if i and 1 then y = (y * z) mod div
z = (z * z) mod div
i = i \ 2
loop
modPow= y
end function
function isPrime(x)
dim i
if x=2 or x=3 or _
x=5 or x=7 _
then isPrime=1: exit function
if x<11 then isPrime=0: exit function
if x mod 2=0 then isPrime=0: exit function
if x mod 3=0 then isPrime=0: exit function
i=5
do
if (x mod i) =0 or _
(x mod (i+2)) =0 _
then isPrime=0: exit function
if i*i>x then isPrime=1: exit function
i=i+6
loop
end function
function testM(x)
dim sqroot,k,q
sqroot=Sqr(2^x)
k=1
do
q=2*k*x+1
if q>sqroot then exit do
if (q and 7)=1 or (q and 7)=7 then
if isPrime(q) then
if modPow(2,x,q)=1 then
testM=q
exit function
end if
end if
end if
k=k+1
loop
testM=0
end function
|
<gh_stars>10-100
'Dim l As New SWbemLocator
'Dim s As ISWbemServices
on error resume next
Set l = CreateObject("WbemScripting.SWbemLocator")
Set s = l.ConnectServer("wsms2", "root\sms\site_wn2", "administrator", "")
'This succeeds. Array (collectionRules) contains 1 element
WScript.Echo UBound(s.Get("sms_collection.collectionid=""sms00001""").Properties_("CollectionRules").Value)
'This fails. Array is empty.
Set Property = s.Get("sms_collection.collectionid=""collroot""").Properties_("CollectionRules")
WScript.Echo Property.Name
if IsNull(Property.Value) then
WScript.Echo "Array value is Null"
else
WScript.Echo UBound(Property.Value)
end if
if err <> 0 then
WScript.Echo Err.Description, Err.Number, Err.Source
end if
|
VERSION 5.00
Begin VB.Form frmDocument
Caption = "frmDocument"
ClientHeight = 4230
ClientLeft = 60
ClientTop = 405
ClientWidth = 8895
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4230
ScaleWidth = 8895
Begin VB.PictureBox Picture1
Height = 495
Left = 3840
ScaleHeight = 435
ScaleWidth = 1155
TabIndex = 0
Top = 1920
Width = 1215
End
End
Attribute VB_Name = "frmDocument"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Form_Resize
End Sub
Private Sub Form_Resize()
On Error Resume Next
txtText.Move 100, 100, Me.ScaleWidth - 200, Me.ScaleHeight - 200
End Sub
|
<filename>admin/wmi/wbem/scripting/test/vb/secasync/secasync.frm
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5595
ClientLeft = 60
ClientTop = 345
ClientWidth = 7470
LinkTopic = "Form1"
ScaleHeight = 5595
ScaleWidth = 7470
StartUpPosition = 3 'Windows Default
Begin VB.ListBox List
Height = 3180
Left = 600
TabIndex = 1
Top = 600
Width = 6375
End
Begin VB.CommandButton Start
Caption = "Start"
Height = 615
Left = 2520
TabIndex = 0
Top = 4560
Width = 2655
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim WithEvents objSink As SWbemSink
Attribute objSink.VB_VarHelpID = -1
Dim Services As SWbemServices
Private Sub Form_Load()
Dim Locator As New WbemScripting.SWbemLocator
Set Services = Locator.ConnectServer("alanbos4", "root\cimv2", "Administrator", "ladolcevita")
Set Services = Locator.ConnectServer("alanbos4", "root\cimv2", "Administrator", "ladolcevita")
End Sub
Private Sub objSink_OnCompleted(ByVal iHResult As WbemScripting.WbemErrorEnum, ByVal objErrorObject As WbemScripting.ISWbemObject, ByVal objAsyncObject As WbemScripting.ISWbemSinkControl, ByVal objAsyncContext As WbemScripting.ISWbemNamedValueSet)
Debug.Print "Completed"
End Sub
Private Sub objSink_OnObjectReady(ByVal objObject As WbemScripting.ISWbemObject, ByVal objAsyncObject As WbemScripting.ISWbemSinkControl, ByVal objAsyncContext As WbemScripting.ISWbemNamedValueSet)
List.AddItem (objObject.Path_.DisplayName)
List.AddItem (objObject.Security_.AuthenticationLevel)
List.AddItem (objObject.Security_.ImpersonationLevel)
End Sub
Private Sub Start_Click()
Services.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
Services.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
Debug.Print "Before call: " & _
Services.Security_.AuthenticationLevel & ":"; Services.Security_.ImpersonationLevel
Set objSink = Services.InstancesOfAsync("Win32_LogicalDisk")
Services.Security_.AuthenticationLevel = wbemAuthenticationLevelPktIntegrity
Services.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate
Debug.Print "After call:" & _
Services.Security_.AuthenticationLevel & ":"; Services.Security_.ImpersonationLevel
End Sub
|
<filename>admin/activec/test/script/snapindispatch.vbs
'
L_Welcome_MsgBox_Message_Text = "This script demonstrates how to access scriptable objects from snapin thro MMC methods. This uses ExplSnap which is made scriptable."
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample"
Call Welcome()
' ********************************************************************************
Dim mmc
Dim doc
Dim snapins
Dim frame
Dim views
Dim view
Dim scopenamespace
Dim rootnode
Dim Nodes
Dim scopenode
Dim SnapNode
Dim ResultItem
Dim MySnapin
' Following are snapin exposed objects.
Dim ScopeNodeObject
Dim ResultItemObject
Dim Name
'get the various objects we'll need
Set mmc = wscript.CreateObject("MMC20.Application")
Set frame = mmc.Frame
Set doc = mmc.Document
Set namespace = doc.ScopeNamespace
Set rootnode = namespace.GetRoot
Set views = doc.views
Set view = views(1)
Set snapins = doc.snapins
snapins.Add "{99C5C401-4FBE-40ec-92AE-8560A0BF39F6}" ' the Component2Test snapin
' Get rootnode of the snapin
' And ask View interface for disp interface.
Set SnapNode1 = namespace.GetChild(rootnode)
view.ActiveScopeNode = SnapNode1
Set ScopeNodeObject = view.SnapinScopeObject
ScopeNodeObject.StringFromScriptToSnapin "StringFromScriptToSnapin"
Name = ScopeNodeObject.Name
MsgBox("ScopeNodeObject.Name =" + Name)
Set ScopeNodeObject = view.SnapinScopeObject(SnapNode1)
ScopeNodeObject.Name = "Name"
Name = ScopeNodeObject.StringFromSnapinToScript
MsgBox("ScopeNodeObject.StringFromSnapinToScript =" + Name)
Set ScopeNodeObject = Nothing
view.Select view.ListItems.Item(1)
Set ResultItemObject = view.SnapinSelectionObject
ResultItemObject.StringFromScriptToSnapin "StringFromScriptToSnapin"
Name = ResultItemObject.Name
MsgBox("ResultItemObject.Name =" + Name)
ResultItemObject.Name = "Name"
Name = ResultItemObject.StringFromSnapinToScript
MsgBox("ResultItemObject.StringFromSnapinToScript =" + Name)
Set mmc = Nothing
' ********************************************************************************
' *
' * Welcome
' *
Sub Welcome()
Dim intDoIt
intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
vbOKCancel + vbInformation, _
L_Welcome_MsgBox_Title_Text )
If intDoIt = vbCancel Then
WScript.Quit
End If
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData
Sub M_snb()
Set d_00 = CreateObject("scripting.dictionary")
Set d_01 = CreateObject("scripting.dictionary")
Set d_02 = CreateObject("scripting.dictionary")
sn = Split("abe abi eve cath ivy jan dee fay bea hope gay _" & _
"bob cath hope abi dee eve fay bea jan ivy gay _" & _
"col hope eve abi dee bea fay ivy gay cath jan _" & _
"dan ivy fay dee gay hope eve jan bea cath abi _" & _
"ed jan dee bea cath fay eve abi ivy hope gay _" & _
"fred bea abi dee gay eve ivy cath jan hope fay _" & _
"gav gay eve ivy bea cath abi dee hope jan fay _" & _
"hal abi eve hope fay ivy cath jan bea gay dee _" & _
"ian hope cath dee gay bea abi fay ivy jan eve _" & _
"jon abi fay jan gay eve bea dee cath ivy hope ", "_")
sp = Split("abi bob fred jon gav ian abe dan ed col hal _" & _
"bea bob abe col fred gav dan ian ed jon hal _" & _
"cath fred bob ed gav hal col ian abe dan jon _" & _
"dee fred jon col abe ian hal gav dan bob ed _" & _
"eve jon hal fred dan abe gav col ed ian bob _" & _
"fay bob abe ed ian jon dan fred gav col hal _" & _
"gay jon gav hal fred bob abe col ed dan ian _" & _
"hope gav jon bob abe ian dan hal ed col fred _" & _
"ivy ian col hal gav fred bob abe ed jon dan _" & _
"jan ed hal gav abe bob jon col ian fred dan ", "_")
For j = 0 To UBound(sn)
d_00(Split(sn(j))(0)) = ""
d_01(Split(sp(j))(0)) = ""
d_02(Split(sn(j))(0)) = sn(j)
d_02(Split(sp(j))(0)) = sp(j)
Next
Do
For Each it In d_00.keys
If d_00.Item(it) = "" Then
st = Split(d_02.Item(it))
For jj = 1 To UBound(st)
If d_01(st(jj)) = "" Then
d_00(st(0)) = st(0) & vbTab & st(jj)
d_01(st(jj)) = st(0)
Exit For
ElseIf InStr(d_02.Item(st(jj)), " " & st(0) & " ") < InStr(d_02.Item(st(jj)), " " & d_01(st(jj)) & " ") Then
d_00(d_01(st(jj))) = ""
d_00(st(0)) = st(0) & vbTab & st(jj)
d_01(st(jj)) = st(0)
Exit For
End If
Next
End If
Next
Loop Until UBound(Filter(d_00.items, vbTab)) = d_00.Count - 1
MsgBox Join(d_00.items, vbLf)
End Sub
|
REM
REM LOCALIZATION
REM
L_SWITCH_OPERATION = "-t"
L_SWITCH_SERVER = "-s"
L_SWITCH_INSTANCE_ID = "-v"
L_SWITCH_FEED_SERVER = "-r"
L_SWITCH_FEED_ID = "-i"
L_SWITCH_TYPE = "-f"
L_SWITCH_UUCPNAME = "-u"
L_SWITCH_ACCOUNT = "-a"
L_SWITCH_PASSWORD = <PASSWORD>"
L_SWITCH_ENABLED = "-e"
L_SWITCH_INBOUND_ACTION = "-ia"
L_SWITCH_INBOUND_NEWSGROUPS = "-in"
L_SWITCH_INBOUND_INTERVAL = "-ix"
L_SWITCH_INBOUND_AUTO_CREATE = "-ic"
L_SWITCH_INBOUND_PROCESS_CTRL_MSGS = "-iz"
L_SWITCH_INBOUND_PULL_TIME = "-io"
L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS = "-im"
L_SWITCH_INBOUND_PORT = "-ip"
L_SWITCH_INBOUND_TEMPDIR = "-it"
L_SWITCH_OUTBOUND_ACTION = "-oa"
L_SWITCH_OUTBOUND_NEWSGROUPS = "-on"
L_SWITCH_OUTBOUND_INTERVAL = "-ox"
L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS = "-oz"
L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS = "-om"
L_SWITCH_OUTBOUND_PORT = "-op"
L_SWITCH_OUTBOUND_TEMPDIR = "-ot"
L_OP_ADD = "a"
L_OP_DELETE = "d"
L_OP_GET = "g"
L_OP_SET = "s"
L_OP_ENUMERATE = "e"
L_DESC_PROGRAM = "rfeed - Set NNTP feeds"
L_DESC_ADD = "add a feed"
L_DESC_DELETE = "delete a feed"
L_DESC_GET = "get information on a feed"
L_DESC_SET = "set information on a feed"
L_DESC_ENUMERATE = "enumerate feeds"
L_DESC_OPERATIONS = "<operations>"
L_DESC_SERVER = "<server> Specify computer to configure"
L_DESC_INSTANCE_ID = "<virtual server id> Specify virtual server id"
L_DESC_FEED_ID = "<feed id> Specify feed id"
L_DESC_INBOUND = "Switches for inbound feed settings:"
L_DESC_OUTBOUND = "Switches for outbound feed settings:"
L_DESC_FEED_SERVER = "server against which the feed operates"
L_DESC_TYPE = "[peer | master | slave]"
L_DESC_UUCPNAME = "uucp name"
L_DESC_ACCOUNT = "authinfo account"
L_DESC_PASSWORD = "<PASSWORD>"
L_DESC_ENABLED = "[true | false] Enable feed"
L_DESC_INBOUND_ACTION = "[Pull | Accept | None]"
L_DESC_OUTBOUND_ACTION = "[Push | None ]"
L_DESC_NEWSGROUPS = "newsgroup patterns"
L_DESC_INTERVAL = "<# minutes> wait time between feed runs"
L_DESC_AUTO_CREATE = "[true | false] Create Newsgroups automatically (pull feed only)"
L_DESC_PROCESS_CTRL_MSGS = "[true | false] Process control messages"
L_DESC_PULL_TIME = "<date> get articles after this date (pull feed only)"
L_DESC_MAX_CONNECTION_ATTEMPTS = "Max Connection attempts"
L_DESC_OUTBOUND_PORT = "Outbound IP port"
L_DESC_TEMPDIR = "Temporary files directory"
L_DESC_EXAMPLES = "Examples:"
L_DESC_EXAMPLE1 = "rfeed.vbs -t e"
L_DESC_EXAMPLE2 = "rfeed.vbs -t a -r FeedServer.mydomain.com -f peer -ia pull -in *"
L_DESC_EXAMPLE3 = "rfeed.vbs -t d -i 1"
L_DESC_EXAMPLE4 = "rfeed.vbs -t s -i 1 -ix 120"
L_STR_INBOUND_FEED = "Inbound feed properties:"
L_STR_OUTBOUND_FEED = "Outbound feed properties:"
L_STR_FEED_SERVER = "Remote server:"
L_STR_FEED_ID = "Feed ID:"
L_STR_TYPE = "Feed type:"
L_STR_ACTION = "Action:"
L_STR_ENABLED = "Enabled:"
L_STR_INTERVAL = "Interval (minutes):"
L_STR_UUCPNAME = "Path header (Uucp name):"
L_STR_PROCESS_CTRL_MSGS = "Process control messages:"
L_STR_ACCOUNT = "Authinfo account:"
L_STR_MAX_CONNECTION_ATTEMPTS = "Maximum connection attempts:"
L_STR_AUTO_CREATE = "Create newsgroups automatically?"
L_STR_PULL_TIME = "Pull news articles from:"
L_STR_OUTGOING_PORT = "Outgoing port:"
L_STR_NEWSGROUPS = "Newsgroups:"
L_STR_TEMPDIR = "Temp Directory:"
L_STR_FEED_TYPE_PEER = "Peer"
L_STR_FEED_TYPE_MASTER = "Master"
L_STR_FEED_TYPE_SLAVE = "Slave"
L_STR_FEED_ACTION_NONE = "None"
L_STR_FEED_ACTION_PULL = "Pull"
L_STR_FEED_ACTION_PUSH = "Push"
L_STR_FEED_ACTION_ACCEPT = "Accept"
L_STR_UNLIMITED = "Unlimited"
L_STR_ADDED_FEED = "Successfully added the following feed:"
L_ERR_MUST_ENTER_ID = "Error: You must enter an ID"
L_ERR_FEED_ID_NOT_FOUND = "Error: There is no feed with that ID"
L_ERR_INVALID_FEED_TYPE = "Error: Invalid feed type"
L_ERR_BOTH_FEEDS_NONE = "Error: At least one feed must have an action"
L_ERR_EMPTY_FEED_SERVER = "Error: You must enter a feed server"
L_ERR_EMPTY_NEWSGROUPS = "Error: You must enter a newsgroup list"
REM
REM END LOCALIZATION
REM
REM
REM --- Constants ---
REM
NNTP_FEED_TYPE_PEER = 1
NNTP_FEED_TYPE_MASTER = 2
NNTP_FEED_TYPE_SLAVE = 3
NNTP_FEED_ACTION_NONE = 0
NNTP_FEED_ACTION_PULL = 1
NNTP_FEED_ACTION_PUSH = 2
NNTP_FEED_ACTION_ACCEPT = 3
dim rgstrFeedType(4)
dim rgstrFeedAction(4)
rgstrFeedType(NNTP_FEED_TYPE_PEER) = L_STR_FEED_TYPE_PEER
rgstrFeedType(NNTP_FEED_TYPE_MASTER) = L_STR_FEED_TYPE_MASTER
rgstrFeedType(NNTP_FEED_TYPE_SLAVE) = L_STR_FEED_TYPE_SLAVE
rgstrFeedAction(NNTP_FEED_ACTION_PULL) = L_STR_FEED_ACTION_PULL
rgstrFeedAction(NNTP_FEED_ACTION_PUSH) = L_STR_FEED_ACTION_PUSH
rgstrFeedAction(NNTP_FEED_ACTION_ACCEPT) = L_STR_FEED_ACTION_ACCEPT
REM
REM --- Globals ---
REM
dim g_dictParms
dim g_admin
set g_dictParms = CreateObject ( "Scripting.Dictionary" )
set g_admin = CreateObject ( "NntpAdm.Feeds" )
REM
REM --- Set argument defaults ---
REM
g_dictParms(L_SWITCH_OPERATION) = ""
g_dictParms(L_SWITCH_SERVER) = ""
g_dictParms(L_SWITCH_INSTANCE_ID) = "1"
g_dictParms(L_SWITCH_FEED_SERVER) = ""
g_dictParms(L_SWITCH_FEED_ID) = ""
g_dictParms(L_SWITCH_TYPE) = "Peer"
g_dictParms(L_SWITCH_UUCPNAME) = ""
g_dictParms(L_SWITCH_ACCOUNT) = ""
g_dictParms(L_SWITCH_PASSWORD) = ""
g_dictParms(L_SWITCH_ENABLED) = True
g_dictParms(L_SWITCH_INBOUND_ACTION) = "None"
g_dictParms(L_SWITCH_INBOUND_NEWSGROUPS) = ""
g_dictParms(L_SWITCH_INBOUND_INTERVAL) = "15"
g_dictParms(L_SWITCH_INBOUND_AUTO_CREATE) = True
g_dictParms(L_SWITCH_INBOUND_PROCESS_CTRL_MSGS) = True
g_dictParms(L_SWITCH_INBOUND_PULL_TIME) = Date
g_dictParms(L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS) = 10
g_dictParms(L_SWITCH_INBOUND_PORT) = 119
g_dictParms(L_SWITCH_INBOUND_TEMPDIR) = ""
g_dictParms(L_SWITCH_OUTBOUND_ACTION) = "None"
g_dictParms(L_SWITCH_OUTBOUND_NEWSGROUPS) = ""
g_dictParms(L_SWITCH_OUTBOUND_INTERVAL) = "15"
g_dictParms(L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS) = True
g_dictParms(L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS) = 10
g_dictParms(L_SWITCH_OUTBOUND_PORT) = 119
g_dictParms(L_SWITCH_OUTBOUND_TEMPDIR) = ""
REM
REM --- Begin Main Program ---
REM
if NOT ParseCommandLine ( g_dictParms, WScript.Arguments ) then
usage
WScript.Quit ( 0 )
end if
REM If it is setting attribute, clear the default value and reparse the command line
if (g_dictParms(L_SWITCH_OPERATION)=L_OP_SET) then
g_dictParms.RemoveAll()
g_dictParms(L_SWITCH_INSTANCE_ID) = "1"
if NOT ParseCommandLine2 ( g_dictParms, WScript.Arguments ) then
WScript.echo "Command line parsing failed"
WScript.Quit ( 0 )
end if
end if
dim cFeeds
dim i
dim id
dim index
dim feedpair
dim nFeedType
dim nInAction
dim nOutAction
dim infeed
dim outfeed
dim strNewsgroups
REM
REM Debug: print out command line arguments:
REM
REM switches = g_dictParms.keys
REM args = g_dictParms.items
REM
REM
REM for i = 0 to g_dictParms.Count - 1
REM WScript.echo switches(i) & " = " & args(i)
REM next
REM
g_admin.Server = g_dictParms(L_SWITCH_SERVER)
g_admin.ServiceInstance = g_dictParms(L_SWITCH_INSTANCE_ID)
On Error Resume Next
g_admin.Enumerate
if ( Err.Number <> 0 ) then
WScript.echo " Error Enumerating Feeds: " + Err.Description + "(" + Err.Number + ")"
else
PrintFeed g_admin
end if
id = g_dictParms(L_SWITCH_FEED_ID)
select case g_dictParms(L_SWITCH_OPERATION)
case L_OP_ENUMERATE
REM
REM List the existing feeds:
REM
cFeeds = g_admin.Count
for i = 0 to cFeeds - 1
set feedpair = g_admin.ItemDispatch ( i )
WScript.Echo
PrintFeed feedpair
next
case L_OP_ADD
REM
REM Add a new feed
REM
nFeedType = StringToFeedType ( g_dictParms ( L_SWITCH_TYPE ) )
nInAction = StringToFeedAction ( g_dictParms ( L_SWITCH_INBOUND_ACTION ) )
nOutAction = StringToFeedAction ( g_dictParms ( L_SWITCH_OUTBOUND_ACTION ) )
if nInAction = NNTP_FEED_ACTION_PUSH OR _
nOutAction = NNTP_FEED_ACTION_PULL OR _
nOutAction = NNTP_FEED_ACTION_ACCEPT then
WScript.Echo L_ERR_INVALID_FEED_TYPE
WScript.Quit 0
end if
if nInAction = NNTP_FEED_ACTION_NONE AND nOutAction = NNTP_FEED_ACTION_NONE then
WScript.Echo L_ERR_BOTH_FEEDS_NONE
WScript.Quit 0
end if
if g_dictParms ( L_SWITCH_FEED_SERVER ) = "" then
WScript.Echo L_ERR_EMPTY_FEED_SERVER
WScript.Quit 0
end if
REM Create feed objects:
set feedpair = CreateObject ( "NntpAdm.Feed" )
set infeed = CreateObject ( "NntpAdm.OneWayFeed" )
set outfeed = CreateObject ( "NntpAdm.OneWayFeed" )
feedpair.RemoteServer = g_dictParms ( L_SWITCH_FEED_SERVER )
feedpair.FeedType = nFeedType
if nInAction <> NNTP_FEED_ACTION_NONE then
strNewsgroups = g_dictParms ( L_SWITCH_INBOUND_NEWSGROUPS )
if strNewsgroups = "" then
WScript.Echo L_ERR_EMPTY_NEWSGROUPS
WScript.Quit 0
end if
infeed.Default
infeed.FeedAction = nInAction
infeed.Enabled = BooleanToBOOL ( g_dictParms ( L_SWITCH_ENABLED ) )
infeed.UucpName = g_dictParms ( L_SWITCH_UUCPNAME )
infeed.AccountName = g_dictParms ( L_SWITCH_ACCOUNT )
infeed.Password = g_dictParms ( L_SWITCH_PASSWORD )
if infeed.Password <> "" OR infeed.AccountName <> "" then
infeed.AuthenticationType = 10
end if
infeed.FeedInterval = g_dictParms ( L_SWITCH_INBOUND_INTERVAL )
infeed.MaxConnectionAttempts = g_dictParms ( L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS )
infeed.AllowControlMessages = BooleanToBOOL ( g_dictParms ( L_SWITCH_INBOUND_PROCESS_CTRL_MSGS ) )
infeed.AutoCreate = BooleanToBOOL ( g_dictParms ( L_SWITCH_INBOUND_AUTO_CREATE ) )
infeed.PullNewsDate = g_dictParms ( L_SWITCH_INBOUND_PULL_TIME )
infeed.NewsgroupsVariant = SemicolonListToArray ( strNewsgroups )
infeed.OutgoingPort = g_dictParms ( L_SWITCH_INBOUND_PORT )
infeed.TempDirectory = g_dictParms ( L_SWITCH_INBOUND_TEMPDIR )
feedpair.InboundFeedDispatch = infeed
end if
if nOutAction <> NNTP_FEED_ACTION_NONE then
strNewsgroups = g_dictParms ( L_SWITCH_OUTBOUND_NEWSGROUPS )
if strNewsgroups = "" then
WScript.Echo L_ERR_EMPTY_NEWSGROUPS
WScript.Quit 0
end if
outfeed.Default
outfeed.FeedAction = nOutAction
outfeed.Enabled = BooleanToBOOL ( g_dictParms ( L_SWITCH_ENABLED ) )
outfeed.UucpName = g_dictParms ( L_SWITCH_UUCPNAME )
outfeed.AccountName = g_dictParms ( L_SWITCH_ACCOUNT )
outfeed.Password = g_dictParms ( L_SWITCH_PASSWORD )
if outfeed.Password <> "" OR outfeed.AccountName <> "" then
outfeed.AuthenticationType = 10
end if
outfeed.FeedInterval = g_dictParms ( L_SWITCH_OUTBOUND_INTERVAL )
outfeed.MaxConnectionAttempts = g_dictParms ( L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS )
outfeed.AllowControlMessages = BooleanToBOOL ( g_dictParms ( L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS ) )
outfeed.AutoCreate = BooleanToBOOL ( g_dictParms ( L_SWITCH_OUTBOUND_AUTO_CREATE ) )
outfeed.NewsgroupsVariant = SemicolonListToArray ( strNewsgroups )
outfeed.OutgoingPort = g_dictParms ( L_SWITCH_OUTBOUND_PORT )
outfeed.TempDirectory = g_dictParms ( L_SWITCH_OUTBOUND_TEMPDIR )
feedpair.OutboundFeedDispatch = outfeed
end if
On Error Resume Next
g_admin.AddDispatch feedpair
if ( Err.Number <> 0 ) then
WScript.echo " Error Add Dispatch Feedpair: " + Err.Description + "(" + Err.Number + ")"
else
WScript.Echo L_STR_ADDED_FEED
PrintFeed g_admin
PrintFeed feedpair
end if
rem PrintFeed g_admin
case L_OP_DELETE
REM
REM Delete an feed
REM
if id = "" OR NOT IsNumeric (id) then
WScript.Echo L_ERR_MUST_ENTER_ID
WScript.Quit
end if
index = g_admin.FindID ( id )
if index = -1 then
WScript.Echo L_ERR_FEED_ID_NOT_FOUND
WScript.Quit 0
end if
On Error Resume Next
g_admin.Remove index
if ( Err.Number <> 0 ) then
WScript.echo " Error Removing Feed: " + Err.Description + "(" + Err.Number + ")"
else
PrintFeed g_admin
end if
case L_OP_GET
REM
REM Get a specific feed:
REM
if id = "" OR NOT IsNumeric (id) then
WScript.Echo L_ERR_MUST_ENTER_ID
WScript.Quit
end if
index = g_admin.FindID(id)
if index = -1 then
WScript.Echo L_ERR_FEED_ID_NOT_FOUND
WScript.Quit 0
end if
set feedpair = g_admin.item ( index )
WScript.Echo
PrintFeed feedpair
case L_OP_SET
REM
REM Change an existing feed:
REM
if id = "" OR NOT IsNumeric (id) then
WScript.Echo L_ERR_MUST_ENTER_ID
WScript.Quit
end if
index = g_admin.FindID(id)
if index = -1 then
WScript.Echo L_ERR_FEED_ID_NOT_FOUND
WScript.Quit 0
end if
set feedpair = g_admin.item ( index )
if g_dictParms ( L_SWITCH_FEED_SERVER ) <> "" then
feedpair.RemoteServer = g_dictParms ( L_SWITCH_FEED_SERVER )
end if
if feedpair.HasInbound then
set infeed = feedpair.InboundFeedDispatch
if g_dictParms ( L_SWITCH_UUCPNAME ) <> "" then
infeed.UucpName = g_dictParms ( L_SWITCH_UUCPNAME )
end if
if g_dictParms ( L_SWITCH_ACCOUNT ) <> "" then
infeed.AccountName = g_dictParms ( L_SWITCH_ACCOUNT )
infeed.AuthenticationType = 10
end if
if g_dictParms ( L_SWITCH_PASSWORD ) <> "" then
infeed.Password = g_dictParms ( L_SWITCH_PASSWORD )
infeed.AuthenticationType = 10
end if
if g_dictParms ( L_SWITCH_ENABLED ) <> "" then
infeed.Enabled = BooleanToBOOL ( g_dictParms ( L_SWITCH_ENABLED ) )
end if
if g_dictParms ( L_SWITCH_INBOUND_NEWSGROUPS ) <> "" then
infeed.NewsgroupsVariant = SemiColonListToArray ( g_dictParms ( L_SWITCH_INBOUND_NEWSGROUPS ) )
end if
if g_dictParms ( L_SWITCH_INBOUND_AUTO_CREATE ) <> "" then
infeed.AutoCreate = BooleanToBOOL ( g_dictParms ( L_SWITCH_INBOUND_AUTO_CREATE ) )
end if
if g_dictParms ( L_SWITCH_INBOUND_INTERVAL ) <> "" then
infeed.FeedInterval = g_dictParms ( L_SWITCH_INBOUND_INTERVAL )
end if
if g_dictParms ( L_SWITCH_INBOUND_PROCESS_CTRL_MSGS ) <> "" then
infeed.AllowControlMessages = BooleanToBOOL ( g_dictParms ( L_SWITCH_INBOUND_PROCESS_CTRL_MSGS ) )
end if
if g_dictParms ( L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS ) <> "" then
infeed.MaxConnectionAttempts = g_dictParms ( L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS )
end if
if g_dictParms ( L_SWITCH_INBOUND_PORT ) <> "" then
infeed.OutgoingPort = g_dictParms ( L_SWITCH_INBOUND_PORT )
end if
if g_dictParms ( L_SWITCH_INBOUND_TEMPDIR ) <> "" then
infeed.TempDirectory = g_dictParms ( L_SWITCH_INBOUND_TEMPDIR )
end if
end if
if feedpair.HasOutbound then
set outfeed = feedpair.OutboundFeedDispatch
if g_dictParms ( L_SWITCH_UUCPNAME ) <> "" then
outfeed.UucpName = g_dictParms ( L_SWITCH_UUCPNAME )
end if
if g_dictParms ( L_SWITCH_ACCOUNT ) <> "" then
outfeed.AccountName = g_dictParms ( L_SWITCH_ACCOUNT )
outfeed.AuthenticationType = 10
end if
if g_dictParms ( L_SWITCH_PASSWORD ) <> "" then
outfeed.Password = g_dictParms ( L_SWITCH_PASSWORD )
outfeed.AuthenticationType = 10
end if
if g_dictParms ( L_SWITCH_ENABLED ) <> "" then
outfeed.Enabled = BooleanToBOOL ( g_dictParms ( L_SWITCH_ENABLED ) )
end if
if g_dictParms ( L_SWITCH_OUTBOUND_NEWSGROUPS ) <> "" then
outfeed.NewsgroupsVariant = SemiColonListToArray ( g_dictParms ( L_SWITCH_OUTBOUND_NEWSGROUPS ) )
end if
if g_dictParms ( L_SWITCH_OUTBOUND_INTERVAL ) <> "" then
outfeed.FeedInterval = g_dictParms ( L_SWITCH_OUTBOUND_INTERVAL )
end if
if g_dictParms ( L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS ) <> "" then
outfeed.AllowControlMessages = BooleanToBOOL ( g_dictParms ( L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS ) )
end if
if g_dictParms ( L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS ) <> "" then
outfeed.MaxConnectionAttempts = g_dictParms ( L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS )
end if
if g_dictParms ( L_SWITCH_OUTBOUND_PORT ) <> "" then
outfeed.OutgoingPort = g_dictParms ( L_SWITCH_OUTBOUND_PORT )
end if
if g_dictParms ( L_SWITCH_OUTBOUND_TEMPDIR ) <> "" then
outfeed.TempDirectory = g_dictParms ( L_SWITCH_OUTBOUND_TEMPDIR )
end if
end if
On Error Resume Next
g_admin.Set index, feedpair
if ( Err.Number <> 0 ) then
WScript.echo " Error Setting Feed ID: " + Err.Description + "(" + Err.Number + ")"
else
PrintFeed g_admin
PrintFeed feedpair
end if
case else
usage
end select
WScript.Quit 0
REM
REM --- End Main Program ---
REM
REM
REM ParseCommandLine ( dictParameters, cmdline )
REM Parses the command line parameters into the given dictionary
REM
REM Arguments:
REM dictParameters - A dictionary containing the global parameters
REM cmdline - Collection of command line arguments
REM
REM Returns - Success code
REM
Function ParseCommandLine ( dictParameters, cmdline )
dim fRet
dim cArgs
dim i
dim strSwitch
dim strArgument
fRet = TRUE
cArgs = cmdline.Count
i = 0
do while (i < cArgs)
REM
REM Parse the switch and its argument
REM
if i + 1 >= cArgs then
REM
REM Not enough command line arguments - Fail
REM
fRet = FALSE
exit do
end if
strSwitch = cmdline(i)
i = i + 1
strArgument = cmdline(i)
i = i + 1
REM
REM Add the switch,argument pair to the dictionary
REM
if NOT dictParameters.Exists ( strSwitch ) then
REM
REM Bad switch - Fail
REM
fRet = FALSE
exit do
end if
dictParameters(strSwitch) = strArgument
loop
ParseCommandLine = fRet
end function
REM
REM --- End Main Program ---
REM
REM
REM ParseCommandLine2 ( dictParameters, cmdline )
REM Parses the command line parameters into the given dictionary
REM
REM Arguments:
REM dictParameters - A dictionary containing the global parameters
REM cmdline - Collection of command line arguments
REM
REM Returns - Success code
REM
Function ParseCommandLine2 ( dictParameters, cmdline )
dim fRet
dim cArgs
dim i
dim strSwitch
dim strArgument
fRet = TRUE
cArgs = cmdline.Count
i = 0
do while (i < cArgs)
REM
REM Parse the switch and its argument
REM
if i + 1 >= cArgs then
REM
REM Not enough command line arguments - Fail
REM
fRet = FALSE
exit do
end if
strSwitch = cmdline(i)
i = i + 1
strArgument = cmdline(i)
i = i + 1
REM
REM Add the switch,argument pair to the dictionary
REM
dictParameters(strSwitch) = strArgument
loop
ParseCommandLine2 = fRet
end function
REM
REM SemicolonListToArray ( strList )
REM Converts a semi colon delimited list to an array of strings
REM
REM eg. str1;str2;str3;str4 -> ["str1", "str2", "str3", "str4"]
REM
Function SemicolonListToArray ( strListIn )
dim rgItems
dim strItem
dim strList
dim index
dim i
ReDim rgItems ( 10 )
strList = strListIn
i = 0
do until strList = ""
REM
REM Debug: print out newsgroup list as we go:
REM WScript.Echo strList
REM
index = InStr ( strList, ";" )
if index = 0 then
REM No trailing ";", so use the whole string
strItem = strList
strList = ""
else
REM Use the string up to the ";"
strItem = Left ( strList, index - 1 )
strList = Right ( strList, Len ( strList ) - index )
end if
ReDim preserve rgItems ( i )
rgItems ( i ) = strItem
i = i + 1
loop
REM return the array
SemicolonListToArray = rgItems
end function
REM
REM Usage ()
REM prints out the description of the command line arguments
REM
Sub Usage
WScript.Echo L_DESC_PROGRAM
WScript.Echo vbTab & L_SWITCH_OPERATION & " " & L_DESC_OPERATIONS
WScript.Echo vbTab & vbTab & L_OP_ADD & vbTab & L_DESC_ADD
WScript.Echo vbTab & vbTab & L_OP_DELETE & vbTab & L_DESC_DELETE
WScript.Echo vbTab & vbTab & L_OP_GET & vbTab & L_DESC_GET
WScript.Echo vbTab & vbTab & L_OP_SET & vbTab & L_DESC_SET
WScript.Echo vbTab & vbTab & L_OP_ENUMERATE & vbTab & L_DESC_ENUMERATE
WScript.Echo vbTab & L_SWITCH_SERVER & " " & L_DESC_SERVER
WScript.Echo vbTab & L_SWITCH_INSTANCE_ID & " " & L_DESC_INSTANCE_ID
WScript.Echo vbTab & L_SWITCH_FEED_SERVER & " " & L_DESC_FEED_SERVER
WScript.Echo vbTab & L_SWITCH_TYPE & " " & L_DESC_TYPE
WScript.Echo vbTab & L_SWITCH_UUCPNAME & " " & L_DESC_UUCPNAME
WScript.Echo vbTab & L_SWITCH_ACCOUNT & " " & L_DESC_ACCOUNT
WScript.Echo vbTab & L_SWITCH_PASSWORD & " " & L_DESC_PASSWORD
WScript.Echo vbTab & L_SWITCH_ENABLED & " " & L_DESC_ENABLED
WScript.Echo vbTab & L_SWITCH_FEED_ID & " " & L_DESC_FEED_ID
WScript.Echo
WScript.Echo vbTab & L_DESC_INBOUND
WScript.Echo vbTab & L_SWITCH_INBOUND_ACTION & " " & L_DESC_INBOUND_ACTION
WScript.Echo vbTab & L_SWITCH_INBOUND_NEWSGROUPS & " " & L_DESC_NEWSGROUPS
WScript.Echo vbTab & L_SWITCH_INBOUND_INTERVAL & " " & L_DESC_INTERVAL
WScript.Echo vbTab & L_SWITCH_INBOUND_PROCESS_CTRL_MSGS & " " & L_DESC_PROCESS_CTRL_MSGS
WScript.Echo vbTab & L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS & " " & L_DESC_MAX_CONNECTION_ATTEMPTS
WScript.Echo vbTab & L_SWITCH_INBOUND_PULL_TIME & " " & L_DESC_PULL_TIME
WScript.Echo vbTab & L_SWITCH_INBOUND_AUTO_CREATE & " " & L_DESC_AUTO_CREATE
WScript.Echo vbTab & L_SWITCH_INBOUND_PORT & " " & L_DESC_OUTBOUND_PORT
WScript.Echo vbTab & L_SWITCH_INBOUND_TEMPDIR & " " & L_DESC_TEMPDIR
WScript.Echo
WScript.Echo vbTab & L_DESC_OUTBOUND
WScript.Echo vbTab & L_SWITCH_OUTBOUND_ACTION & " " & L_DESC_OUTBOUND_ACTION
WScript.Echo vbTab & L_SWITCH_OUTBOUND_NEWSGROUPS & " " & L_DESC_NEWSGROUPS
WScript.Echo vbTab & L_SWITCH_OUTBOUND_INTERVAL & " " & L_DESC_INTERVAL
WScript.Echo vbTab & L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS & " " & L_DESC_PROCESS_CTRL_MSGS
WScript.Echo vbTab & L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS & " " & L_DESC_MAX_CONNECTION_ATTEMPTS
WScript.Echo vbTab & L_SWITCH_OUTBOUND_PORT & " " & L_DESC_OUTBOUND_PORT
WScript.Echo vbTab & L_SWITCH_OUTBOUND_TEMPDIR & " " & L_DESC_TEMPDIR
WScript.Echo
WScript.Echo L_DESC_EXAMPLES
WScript.Echo L_DESC_EXAMPLE1
WScript.Echo L_DESC_EXAMPLE2
WScript.Echo L_DESC_EXAMPLE3
WScript.Echo L_DESC_EXAMPLE4
end sub
Sub PrintFeed ( feedobj )
WScript.Echo L_STR_FEED_SERVER & " " & feedobj.RemoteServer
WScript.Echo L_STR_TYPE & " " & rgstrFeedType (feedobj.FeedType)
if feedobj.HasInbound then
WScript.Echo L_STR_INBOUND_FEED
PrintOneWayFeed feedobj.InboundFeedDispatch
end if
if feedobj.HasOutbound then
WScript.Echo L_STR_OUTBOUND_FEED
PrintOneWayFeed feedobj.OutboundFeedDispatch
end if
end sub
sub PrintOneWayFeed ( feedobj )
dim newsgroups
dim cGroups
dim i
dim bAccept
dim bPush
dim bPull
bPull = (feedobj.FeedAction = NNTP_FEED_ACTION_PULL)
bPush = (feedobj.FeedAction = NNTP_FEED_ACTION_PUSH)
bAccept = (feedobj.FeedAction = NNTP_FEED_ACTION_ACCEPT)
WScript.Echo vbTab & L_STR_FEED_ID & " " & feedobj.FeedId
WScript.Echo vbTab & L_STR_ACTION & " " & rgstrFeedAction (feedobj.FeedAction)
WScript.Echo vbTab & L_STR_ENABLED & " " & BOOLToBoolean (feedobj.Enabled)
WScript.Echo vbTab & L_STR_UUCPNAME & " " & feedobj.UucpName
WScript.Echo vbTab & L_STR_PROCESS_CTRL_MSGS & " " & BOOLToBoolean (feedobj.AllowControlMessages)
WScript.Echo vbTab & L_STR_ACCOUNT & " " & feedobj.AccountName
if feedobj.MaxConnectionAttempts = 0 OR feedobj.MaxConnectionAttempts = -1 then
WScript.Echo vbTab & L_STR_MAX_CONNECTION_ATTEMPTS & " " & L_STR_UNLIMITED
else
WScript.Echo vbTab & L_STR_MAX_CONNECTION_ATTEMPTS & " " & feedobj.MaxConnectionAttempts
end if
if bPull then
WScript.Echo vbTab & L_STR_AUTO_CREATE & " " & BOOLToBoolean ( feedobj.AutoCreate )
WScript.Echo vbTab & L_STR_PULL_TIME & " " & feedobj.PullNewsDate
end if
if NOT bAccept then
WScript.Echo vbTab & L_STR_INTERVAL & " " & feedobj.FeedInterval
WScript.Echo vbTab & L_STR_OUTGOING_PORT & " " & feedobj.OutgoingPort
end if
WScript.Echo vbTab & L_STR_TEMPDIR & " " & feedobj.TempDirectory
newsgroups = feedobj.NewsgroupsVariant
cGroups = UBound ( newsgroups )
for i = 0 to cGroups
WScript.Echo vbTab & L_STR_NEWSGROUPS & " " & newsgroups(i)
next
end sub
Function StringToFeedType ( strFeedType )
dim strUcaseType
strUcaseType = UCase ( strFeedType )
if strUcaseType = UCase ( L_STR_FEED_TYPE_PEER ) then
StringToFeedType = NNTP_FEED_TYPE_PEER
elseif strUcaseType = UCase ( L_STR_FEED_TYPE_MASTER ) then
StringToFeedType = NNTP_FEED_TYPE_MASTER
elseif strUcaseType = UCase ( L_STR_FEED_TYPE_SLAVE ) then
StringToFeedType = NNTP_FEED_TYPE_SLAVE
else
StringToFeedType = NNTP_FEED_TYPE_PEER
end if
end function
Function StringToFeedAction ( strFeedAction )
dim strUcaseAction
strUcaseAction = UCase ( strFeedAction )
if strUcaseAction = UCase ( L_STR_FEED_ACTION_PULL ) then
StringToFeedAction = NNTP_FEED_ACTION_PULL
elseif strUcaseAction = UCase ( L_STR_FEED_ACTION_PUSH ) then
StringToFeedAction = NNTP_FEED_ACTION_PUSH
elseif strUcaseAction = UCase ( L_STR_FEED_ACTION_ACCEPT ) then
StringToFeedAction = NNTP_FEED_ACTION_ACCEPT
else
StringToFeedAction = NNTP_FEED_ACTION_NONE
end if
end function
Function BooleanToBOOL ( b )
if b then
BooleanToBOOL = 1
else
BooleanToBOOL = 0
end if
end function
Function BOOLToBoolean ( b )
BOOLToBoolean = (b = 1)
end function
|
<filename>drivers/storage/wmiprov/vss/test/scripts/createshadow.vbs<gh_stars>10-100
strNamespace = "winmgmts://./root/cimv2"
set dateTime = CreateObject("WbemScripting.SWbemDateTime")
set objArgs = wscript.Arguments
if objArgs.count < 1 then
wscript.echo "Usage shadow volume"
wscript.quit(1)
end if
strVolume = Replace(objArgs(0), "\", "\\")
'// Get the volume
strQuery = "select * from Win32_Volume where Name = '" & strVolume & "'"
set VolumeSet = GetObject("winmgmts:").ExecQuery(strQuery)
for each obj in VolumeSet
set Volume = obj
exit for
next
wscript.echo "Volume Name: " & Volume.DeviceID
'// Pick a shadow context
set ContextSet = GetObject(strNamespace).ExecQuery(_
"select * from Win32_ShadowContext where Name='ClientAccessible'")
for each obj in ContextSet
set Context = obj
exit for
next
wscript.echo "Context Name: " & Context.Name
'// Create a new shadow
set Shadow = GetObject(strNamespace & ":Win32_ShadowCopy")
dateTime.SetVarDate(CDate(Now))
Result = Shadow.Create(Volume.Name,_
Context.Name,_
strShadowID)
strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
wscript.echo "Shadow.Create returned: " & Result & " : " & strMessage
if Result = 0 then
wscript.echo "Shadow.ID: " & strShadowID
strShadow = "Win32_ShadowCopy.ID='" & strShadowID & "'"
wscript.echo strShadow
set objShadow = GetObject(strNamespace).Get(strShadow)
wscript.echo "Shadow.Create started at: " & dateTime.GetVarDate(True)
dateTime.Value = objShadow.InstallDate
wscript.echo "Shadow.InstallDate: " & dateTime.GetVarDate(True)
end if
Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode)
set objClass = GetObject("winmgmts:").Get(strClass, &h20000)
set objMethod = objClass.methods_(strMethod)
values = objMethod.qualifiers_("values")
if ubound(values) < intCode then
wscript.echo " FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod
f.writeline ("FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod)
MapErrorCode = ""
else
MapErrorCode = values(intCode)
end if
End Function
|
Function quicksort(arr,s,n)
l = s
r = s + n - 1
p = arr(Int((l + r)/2))
Do Until l > r
Do While arr(l) < p
l = l + 1
Loop
Do While arr(r) > p
r = r -1
Loop
If l <= r Then
tmp = arr(l)
arr(l) = arr(r)
arr(r) = tmp
l = l + 1
r = r - 1
End If
Loop
If s < r Then
Call quicksort(arr,s,r-s+1)
End If
If l < t Then
Call quicksort(arr,l,t-l+1)
End If
quicksort = arr
End Function
myarray=Array(9,8,7,6,5,5,4,3,2,1,0,-1)
m = quicksort(myarray,0,12)
WScript.Echo Join(m,",")
|
<reponame>LaudateCorpus1/RosettaCodeData
' Flatten the example array...
a = FlattenArray(Array(Array(1), 2, Array(Array(3,4), 5), Array(Array(Array())), Array(Array(Array(6))), 7, 8, Array()))
' Print the list, comma-separated...
WScript.Echo Join(a, ",")
Function FlattenArray(a)
If IsArray(a) Then DoFlatten a, FlattenArray: FlattenArray = Split(Trim(FlattenArray))
End Function
Sub DoFlatten(a, s)
For i = 0 To UBound(a)
If IsArray(a(i)) Then DoFlatten a(i), s Else s = s & a(i) & " "
Next
End Sub
|
<filename>admin/wmi/wbem/scripting/test/vbscript/stress/pathbuild.vbs
on error resume next
while true
Set ObjectPath = CreateObject("WbemScripting.SWbemObjectPath")
ObjectPath.Server = "hah"
ObjectPath.Class = "ho"
ObjectPath.Keys.Add "fred1", 10
ObjectPath.Keys.Add "fred2", -34
ObjectPath.Keys.Add "fred3", 65234654
ObjectPath.Keys.Add "fred4", "Wahaay"
ObjectPath.Keys.Add "fred5", -786186777
if err <> 0 then
WScript.Echo err.number
end if
WScript.Echo ObjectPath.Path
wend
|
Dim lookupTable(170), returnTable(170), currentPosition, input
currentPosition = 0
Do While True
input = InputBox("Please type a number (-1 to quit):")
MsgBox "The factorial of " & input & " is " & factorial(CDbl(input))
Loop
Function factorial (x)
If x = -1 Then
WScript.Quit 0
End If
Dim temp
temp = lookup(x)
If x <= 1 Then
factorial = 1
ElseIf temp <> 0 Then
factorial = temp
Else
temp = factorial(x - 1) * x
store x, temp
factorial = temp
End If
End Function
Function lookup (x)
Dim i
For i = 0 To currentPosition - 1
If lookupTable(i) = x Then
lookup = returnTable(i)
Exit Function
End If
Next
lookup = 0
End Function
Function store (x, y)
lookupTable(currentPosition) = x
returnTable(currentPosition) = y
currentPosition = currentPosition + 1
End Function
|
Public Sub roots_of_unity()
For n = 2 To 9
Debug.Print n; "th roots of 1:"
For r00t = 0 To n - 1
Debug.Print " Root "; r00t & ": "; WorksheetFunction.Complex(Cos(2 * WorksheetFunction.Pi() * r00t / n), _
Sin(2 * WorksheetFunction.Pi() * r00t / n))
Next r00t
Debug.Print
Next n
End Sub
|
<gh_stars>10-100
VERSION 5.00
Begin VB.Form frmTerminal
Caption = "Terminal"
ClientHeight = 5070
ClientLeft = 7065
ClientTop = 345
ClientWidth = 9840
LinkTopic = "Form1"
ScaleHeight = 5070
ScaleWidth = 9840
Begin VB.TextBox Text1
Height = 5055
Left = 0
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Top = 0
Width = 9855
End
End
Attribute VB_Name = "frmTerminal"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Me.Left = GetSetting(App.Title, "Settings", "TerminalLeft", 8000)
Me.Top = GetSetting(App.Title, "Settings", "TerminalTop", 1000)
Me.Height = GetSetting(App.Title, "Settings", "TerminalHeight", 5000)
Me.Width = GetSetting(App.Title, "Settings", "TerminalWidth", 3000)
End Sub
Private Sub Form_Resize()
If Me.WindowState <> vbMinimized Then
Text1.Width = frmTerminal.Width - 100
Text1.Height = frmTerminal.Height - 400
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, "Settings", "TerminalLeft", Me.Left
SaveSetting App.Title, "Settings", "TerminalTop", Me.Top
SaveSetting App.Title, "Settings", "TerminalHeight", Me.Height
SaveSetting App.Title, "Settings", "TerminalWidth", Me.Width
End If
If frmStart.MSComm1.PortOpen = True Then
frmStart.MSComm1.PortOpen = False ' Close the serial port.
End If
Unload frmTerminal
Unload frmStart
End Sub
|
<filename>admin/pchealth/authtools/prodtools/common/timer.bas
Attribute VB_Name = "Timer"
Option Explicit
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
Function HighResTimer() As Double
Static secFreq As Currency, secStart As Currency
If (secFreq = 0) Then QueryPerformanceFrequency secFreq
QueryPerformanceCounter secStart
If (secFreq <> 0) Then HighResTimer = secStart / secFreq
' Else Timer = 0 if no high resolution timer
End Function
|
<reponame>npocmaka/Windows-Server-2003<gh_stars>10-100
'----------------------------------------------------------------------
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
' Abstract:
' prnmngr.vbs - printer script for WMI on Whistler
' used to add, delete, and list printers and connections
' also for getting and setting the default printer
'
' Usage:
' prnmngr [-adxgtl?][co] [-s server][-p printer][-m driver model][-r port]
' [-u user name][-w password]
'
' Examples:
' prnmngr -a -p "printer" -m "driver" -r "lpt1:"
' prnmngr -d -p "printer" -s server
' prnmngr -ac -p "\\server\printer"
' prnmngr -d -p "\\server\printer"
' prnmngr -x -s server
' prnmngr -l -s server
' prnmngr -g
' prnmngr -t -p "printer"
'
'----------------------------------------------------------------------
option explicit
'
' Debugging trace flags, to enable debug output trace message
' change gDebugFlag to true.
'
const kDebugTrace = 1
const kDebugError = 2
dim gDebugFlag
gDebugFlag = false
'
' Operation action values.
'
const kActionUnknown = 0
const kActionAdd = 1
const kActionAddConn = 2
const kActionDel = 3
const kActionDelAll = 4
const kActionDelAllCon = 5
const kActionDelAllLocal = 6
const kActionList = 7
const kActionGetDefaultPrinter = 8
const kActionSetDefaultPrinter = 9
const kErrorSuccess = 0
const KErrorFailure = 1
const kFlagCreateOnly = 2
const kNameSpace = "root\cimv2"
'
' Generic strings
'
const L_Empty_Text = ""
const L_Space_Text = " "
const L_Error_Text = "Error"
const L_Success_Text = "Success"
const L_Failed_Text = "Failed"
const L_Hex_Text = "0x"
const L_Printer_Text = "Printer"
const L_Operation_Text = "Operation"
const L_Provider_Text = "Provider"
const L_Description_Text = "Description"
const L_Debug_Text = "Debug:"
const L_Connection_Text = "connection"
'
' General usage messages
'
const L_Help_Help_General01_Text = "Usage: prnmngr [-adxgtl?][c] [-s server][-p printer][-m driver model]"
const L_Help_Help_General02_Text = " [-r port][-u user name][-w password]"
const L_Help_Help_General03_Text = "Arguments:"
const L_Help_Help_General04_Text = "-a - add local printer"
const L_Help_Help_General05_Text = "-ac - add printer connection"
const L_Help_Help_General06_Text = "-d - delete printer"
const L_Help_Help_General07_Text = "-g - get the default printer"
const L_Help_Help_General08_Text = "-l - list printers"
const L_Help_Help_General09_Text = "-m - driver model"
const L_Help_Help_General10_Text = "-p - printer name"
const L_Help_Help_General11_Text = "-r - port name"
const L_Help_Help_General12_Text = "-s - server name"
const L_Help_Help_General13_Text = "-t - set the default printer"
const L_Help_Help_General14_Text = "-u - user name"
const L_Help_Help_General15_Text = "-w - password"
const L_Help_Help_General16_Text = "-x - delete all printers"
const L_Help_Help_General17_Text = "-xc - delete all printer connections"
const L_Help_Help_General18_Text = "-xo - delete all local printers"
const L_Help_Help_General19_Text = "-? - display command usage"
const L_Help_Help_General20_Text = "Examples:"
const L_Help_Help_General21_Text = "prnmngr -a -p ""printer"" -m ""driver"" -r ""lpt1:"""
const L_Help_Help_General22_Text = "prnmngr -d -p ""printer"" -s server"
const L_Help_Help_General23_Text = "prnmngr -ac -p ""\\server\printer"""
const L_Help_Help_General24_Text = "prnmngr -d -p ""\\server\printer"""
const L_Help_Help_General25_Text = "prnmngr -x -s server"
const L_Help_Help_General26_Text = "prnmngr -xo"
const L_Help_Help_General27_Text = "prnmngr -l -s server"
const L_Help_Help_General28_Text = "prnmngr -g"
const L_Help_Help_General29_Text = "prnmngr -t -p ""\\server\printer"""
'
' Messages to be displayed if the scripting host is not cscript
'
const L_Help_Help_Host01_Text = "Please run this script using CScript."
const L_Help_Help_Host02_Text = "This can be achieved by"
const L_Help_Help_Host03_Text = "1. Using ""CScript script.vbs arguments"" or"
const L_Help_Help_Host04_Text = "2. Changing the default Windows Scripting Host to CScript"
const L_Help_Help_Host05_Text = " using ""CScript //H:CScript //S"" and running the script "
const L_Help_Help_Host06_Text = " ""script.vbs arguments""."
'
' General error messages
'
const L_Text_Error_General01_Text = "The scripting host could not be determined."
const L_Text_Error_General02_Text = "Unable to parse command line."
const L_Text_Error_General03_Text = "Win32 error code"
'
' Miscellaneous messages
'
const L_Text_Msg_General01_Text = "Added printer"
const L_Text_Msg_General02_Text = "Unable to add printer"
const L_Text_Msg_General03_Text = "Added printer connection"
const L_Text_Msg_General04_Text = "Unable to add printer connection"
const L_Text_Msg_General05_Text = "Deleted printer"
const L_Text_Msg_General06_Text = "Unable to delete printer"
const L_Text_Msg_General07_Text = "Attempting to delete printer"
const L_Text_Msg_General08_Text = "Unable to delete printers"
const L_Text_Msg_General09_Text = "Number of local printers and connections enumerated"
const L_Text_Msg_General10_Text = "Number of local printers and connections deleted"
const L_Text_Msg_General11_Text = "Unable to enumerate printers"
const L_Text_Msg_General12_Text = "The default printer is"
const L_Text_Msg_General13_Text = "Unable to get the default printer"
const L_Text_Msg_General14_Text = "Unable to set the default printer"
const L_Text_Msg_General15_Text = "The default printer is now"
const L_Text_Msg_General16_Text = "Number of printer connections enumerated"
const L_Text_Msg_General17_Text = "Number of printer connections deleted"
const L_Text_Msg_General18_Text = "Number of local printers enumerated"
const L_Text_Msg_General19_Text = "Number of local printers deleted"
'
' Printer properties
'
const L_Text_Msg_Printer01_Text = "Server name"
const L_Text_Msg_Printer02_Text = "Printer name"
const L_Text_Msg_Printer03_Text = "Share name"
const L_Text_Msg_Printer04_Text = "Driver name"
const L_Text_Msg_Printer05_Text = "Port name"
const L_Text_Msg_Printer06_Text = "Comment"
const L_Text_Msg_Printer07_Text = "Location"
const L_Text_Msg_Printer08_Text = "Separator file"
const L_Text_Msg_Printer09_Text = "Print processor"
const L_Text_Msg_Printer10_Text = "Data type"
const L_Text_Msg_Printer11_Text = "Parameters"
const L_Text_Msg_Printer12_Text = "Attributes"
const L_Text_Msg_Printer13_Text = "Priority"
const L_Text_Msg_Printer14_Text = "Default priority"
const L_Text_Msg_Printer15_Text = "Start time"
const L_Text_Msg_Printer16_Text = "Until time"
const L_Text_Msg_Printer17_Text = "Job count"
const L_Text_Msg_Printer18_Text = "Average pages per minute"
const L_Text_Msg_Printer19_Text = "Printer status"
const L_Text_Msg_Printer20_Text = "Extended printer status"
const L_Text_Msg_Printer21_Text = "Detected error state"
const L_Text_Msg_Printer22_Text = "Extended detected error state"
'
' Printer status
'
const L_Text_Msg_Status01_Text = "Other"
const L_Text_Msg_Status02_Text = "Unknown"
const L_Text_Msg_Status03_Text = "Idle"
const L_Text_Msg_Status04_Text = "Printing"
const L_Text_Msg_Status05_Text = "Warmup"
const L_Text_Msg_Status06_Text = "Stopped printing"
const L_Text_Msg_Status07_Text = "Offline"
const L_Text_Msg_Status08_Text = "Paused"
const L_Text_Msg_Status09_Text = "Error"
const L_Text_Msg_Status10_Text = "Busy"
const L_Text_Msg_Status11_Text = "Not available"
const L_Text_Msg_Status12_Text = "Waiting"
const L_Text_Msg_Status13_Text = "Processing"
const L_Text_Msg_Status14_Text = "Initializing"
const L_Text_Msg_Status15_Text = "Power save"
const L_Text_Msg_Status16_Text = "Pending deletion"
const L_Text_Msg_Status17_Text = "I/O active"
const L_Text_Msg_Status18_Text = "Manual feed"
const L_Text_Msg_Status19_Text = "No error"
const L_Text_Msg_Status20_Text = "Low paper"
const L_Text_Msg_Status21_Text = "No paper"
const L_Text_Msg_Status22_Text = "Low toner"
const L_Text_Msg_Status23_Text = "No toner"
const L_Text_Msg_Status24_Text = "Door open"
const L_Text_Msg_Status25_Text = "Jammed"
const L_Text_Msg_Status26_Text = "Service requested"
const L_Text_Msg_Status27_Text = "Output bin full"
const L_Text_Msg_Status28_Text = "Paper problem"
const L_Text_Msg_Status29_Text = "Cannot print page"
const L_Text_Msg_Status30_Text = "User intervention required"
const L_Text_Msg_Status31_Text = "Out of memory"
const L_Text_Msg_Status32_Text = "Server unknown"
'
' Debug messages
'
const L_Text_Dbg_Msg01_Text = "In function AddPrinter"
const L_Text_Dbg_Msg02_Text = "In function AddPrinterConnection"
const L_Text_Dbg_Msg03_Text = "In function DelPrinter"
const L_Text_Dbg_Msg04_Text = "In function DelAllPrinters"
const L_Text_Dbg_Msg05_Text = "In function ListPrinters"
const L_Text_Dbg_Msg06_Text = "In function GetDefaultPrinter"
const L_Text_Dbg_Msg07_Text = "In function SetDefaultPrinter"
const L_Text_Dbg_Msg08_Text = "In function ParseCommandLine"
main
'
' Main execution starts here
'
sub main
dim iAction
dim iRetval
dim strServer
dim strPrinter
dim strDriver
dim strPort
dim strUser
dim strPassword
'
' Abort if the host is not cscript
'
if not IsHostCscript() then
call wscript.echo(L_Help_Help_Host01_Text & vbCRLF & L_Help_Help_Host02_Text & vbCRLF & _
L_Help_Help_Host03_Text & vbCRLF & L_Help_Help_Host04_Text & vbCRLF & _
L_Help_Help_Host05_Text & vbCRLF & L_Help_Help_Host06_Text & vbCRLF)
wscript.quit
end if
'
' Get command line parameters
'
iRetval = ParseCommandLine(iAction, strServer, strPrinter, strDriver, strPort, strUser, strPassword)
if iRetval = kErrorSuccess then
select case iAction
case kActionAdd
iRetval = AddPrinter(strServer, strPrinter, strDriver, strPort, strUser, strPassword)
case kActionAddConn
iRetval = AddPrinterConnection(strPrinter, strUser, strPassword)
case kActionDel
iRetval = DelPrinter(strServer, strPrinter, strUser, strPassword)
case kActionDelAll
iRetval = DelAllPrinters(kActionDelAll, strServer, strUser, strPassword)
case kActionDelAllCon
iRetval = DelAllPrinters(kActionDelAllCon, strServer, strUser, strPassword)
case kActionDelAllLocal
iRetval = DelAllPrinters(kActionDelAllLocal, strServer, strUser, strPassword)
case kActionList
iRetval = ListPrinters(strServer, strUser, strPassword)
case kActionGetDefaultPrinter
iRetval = GetDefaultPrinter(strUser, strPassword)
case kActionSetDefaultPrinter
iRetval = SetDefaultPrinter(strPrinter, strUser, strPassword)
case kActionUnknown
Usage(true)
exit sub
case else
Usage(true)
exit sub
end select
end if
end sub
'
' Add a printer with minimum settings. Use prncnfg.vbs to
' set the complete configuration of a printer
'
function AddPrinter(strServer, strPrinter, strDriver, strPort, strUser, strPassword)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg01_Text
DebugPrint kDebugTrace, L_Text_Msg_Printer01_Text & L_Space_Text & strServer
DebugPrint kDebugTrace, L_Text_Msg_Printer02_Text & L_Space_Text & strPrinter
DebugPrint kDebugTrace, L_Text_Msg_Printer04_Text & L_Space_Text & strDriver
DebugPrint kDebugTrace, L_Text_Msg_Printer05_Text & L_Space_Text & strPort
dim oPrinter
dim oService
dim iRetval
if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then
set oPrinter = oService.Get("Win32_Printer").SpawnInstance_
else
AddPrinter = kErrorFailure
exit function
end if
oPrinter.DriverName = strDriver
oPrinter.PortName = strPort
oPrinter.DeviceID = strPrinter
oPrinter.Put_(kFlagCreateOnly)
if Err.Number = kErrorSuccess then
wscript.echo L_Text_Msg_General01_Text & L_Space_Text & strPrinter
iRetval = kErrorSuccess
else
wscript.echo L_Text_Msg_General02_Text & L_Space_Text & strPrinter & L_Space_Text & L_Error_Text _
& L_Space_Text & L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description
'
' Try getting extended error information
'
call LastError()
iRetval = kErrorFailure
end if
AddPrinter = iRetval
end function
'
' Add a printer connection
'
function AddPrinterConnection(strPrinter, strUser, strPassword)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg02_Text
dim oPrinter
dim oService
dim iRetval
dim uResult
'
' Initialize return value
'
iRetval = kErrorFailure
'
' We connect to the local server
'
if WmiConnect("", kNameSpace, strUser, strPassword, oService) then
set oPrinter = oService.Get("Win32_Printer")
else
AddPrinterConnection = kErrorFailure
exit function
end if
'
' Check if Get was successful
'
if Err.Number = kErrorSuccess then
'
' The Err object indicates whether the WMI provider reached the execution
' of the function that adds a printer connection. The uResult is the Win32
' error code returned by the static method that adds a printer connection
'
uResult = oPrinter.AddPrinterConnection(strPrinter)
if Err.Number = kErrorSuccess then
if uResult = kErrorSuccess then
wscript.echo L_Text_Msg_General03_Text & L_Space_Text & strPrinter
iRetval = kErrorSuccess
else
wscript.echo L_Text_Msg_General04_Text & L_Space_Text & L_Text_Error_General03_Text _
& L_Space_text & uResult
end if
else
wscript.echo L_Text_Msg_General04_Text & L_Space_Text & strPrinter & L_Space_Text _
& L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) & L_Space_Text _
& Err.Description
end if
else
wscript.echo L_Text_Msg_General04_Text & L_Space_Text & strPrinter & L_Space_Text _
& L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) & L_Space_Text _
& Err.Description
end if
AddPrinterConnection = iRetval
end function
'
' Delete a printer or a printer connection
'
function DelPrinter(strServer, strPrinter, strUser, strPassword)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg03_Text
DebugPrint kDebugTrace, L_Text_Msg_Printer01_Text & L_Space_Text & strServer
DebugPrint kDebugTrace, L_Text_Msg_Printer02_Text & L_Space_Text & strPrinter
dim oService
dim oPrinter
dim iRetval
iRetval = kErrorFailure
if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then
set oPrinter = oService.Get("Win32_Printer.DeviceID='" & strPrinter & "'")
else
DelPrinter = kErrorFailure
exit function
end if
'
' Check if Get was successful
'
if Err.Number = kErrorSuccess then
oPrinter.Delete_
if Err.Number = kErrorSuccess then
wscript.echo L_Text_Msg_General05_Text & L_Space_Text & strPrinter
iRetval = kErrorSuccess
else
wscript.echo L_Text_Msg_General06_Text & L_Space_Text & strPrinter & L_Space_Text _
& L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) _
& L_Space_Text & Err.Description
'
' Try getting extended error information
'
call LastError()
end if
else
wscript.echo L_Text_Msg_General06_Text & L_Space_Text & strPrinter & L_Space_Text _
& L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) _
& L_Space_Text & Err.Description
'
' Try getting extended error information
'
call LastError()
end if
DelPrinter = iRetval
end function
'
' Delete all local printers and connections on a machine
'
function DelAllPrinters(kAction, strServer, strUser, strPassword)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg04_Text
dim Printers
dim oPrinter
dim oService
dim iResult
dim iTotal
dim iTotalDeleted
dim strPrinterName
dim bDelete
dim bConnection
dim strTemp
if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then
set Printers = oService.InstancesOf("Win32_Printer")
else
DelAllPrinters = kErrorFailure
exit function
end if
if Err.Number <> kErrorSuccess then
wscript.echo L_Text_Msg_General11_Text & L_Space_Text & L_Error_Text & L_Space_Text _
& L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description
DelAllPrinters = kErrorFailure
exit function
end if
iTotal = 0
iTotalDeleted = 0
for each oPrinter in Printers
strPrinterName = oPrinter.DeviceID
bConnection = oPrinter.Network
if kAction = kActionDelAll then
bDelete = 1
iTotal = iTotal + 1
elseif kAction = kActionDelAllCon and bConnection then
bDelete = 1
iTotal = iTotal + 1
elseif kAction = kActionDelAllLocal and not bConnection then
bDelete = 1
iTotal = iTotal + 1
else
bDelete = 0
end if
if bDelete = 1 then
if bConnection then
strTemp = L_Space_Text & L_Connection_Text & L_Space_Text
else
strTemp = L_Space_Text
end if
'
' Delete printer instance
'
oPrinter.Delete_
if Err.Number = kErrorSuccess then
wscript.echo L_Text_Msg_General05_Text & strTemp & oPrinter.DeviceID
iTotalDeleted = iTotalDeleted + 1
else
wscript.echo L_Text_Msg_General06_Text & strTemp & strPrinterName _
& L_Space_Text & L_Error_Text & L_Space_Text & L_Hex_Text _
& hex(Err.Number) & L_Space_Text & Err.Description
'
' Try getting extended error information
'
call LastError()
'
' Continue deleting the rest of the printers despite this error
'
Err.Clear
end if
end if
next
wscript.echo L_Empty_Text
if kAction = kActionDelAll then
wscript.echo L_Text_Msg_General09_Text & L_Space_Text & iTotal
wscript.echo L_Text_Msg_General10_Text & L_Space_Text & iTotalDeleted
elseif kAction = kActionDelAllCon then
wscript.echo L_Text_Msg_General16_Text & L_Space_Text & iTotal
wscript.echo L_Text_Msg_General17_Text & L_Space_Text & iTotalDeleted
elseif kAction = kActionDelAllLocal then
wscript.echo L_Text_Msg_General18_Text & L_Space_Text & iTotal
wscript.echo L_Text_Msg_General19_Text & L_Space_Text & iTotalDeleted
else
end if
DelAllPrinters = kErrorSuccess
end function
'
' List the printers
'
function ListPrinters(strServer, strUser, strPassword)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg05_Text
dim Printers
dim oService
dim oPrinter
dim iTotal
if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then
set Printers = oService.InstancesOf("Win32_Printer")
else
ListPrinters = kErrorFailure
exit function
end if
if Err.Number <> kErrorSuccess then
wscript.echo L_Text_Msg_General11_Text & L_Space_Text & L_Error_Text & L_Space_Text _
& L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description
ListPrinters = kErrorFailure
exit function
end if
iTotal = 0
for each oPrinter in Printers
iTotal = iTotal + 1
wscript.echo L_Empty_Text
wscript.echo L_Text_Msg_Printer01_Text & L_Space_Text & strServer
wscript.echo L_Text_Msg_Printer02_Text & L_Space_Text & oPrinter.DeviceID
wscript.echo L_Text_Msg_Printer03_Text & L_Space_Text & oPrinter.ShareName
wscript.echo L_Text_Msg_Printer04_Text & L_Space_Text & oPrinter.DriverName
wscript.echo L_Text_Msg_Printer05_Text & L_Space_Text & oPrinter.PortName
wscript.echo L_Text_Msg_Printer06_Text & L_Space_Text & oPrinter.Comment
wscript.echo L_Text_Msg_Printer07_Text & L_Space_Text & oPrinter.Location
wscript.echo L_Text_Msg_Printer08_Text & L_Space_Text & oPrinter.SepFile
wscript.echo L_Text_Msg_Printer09_Text & L_Space_Text & oPrinter.PrintProcessor
wscript.echo L_Text_Msg_Printer10_Text & L_Space_Text & oPrinter.PrintJobDataType
wscript.echo L_Text_Msg_Printer11_Text & L_Space_Text & oPrinter.Parameters
wscript.echo L_Text_Msg_Printer12_Text & L_Space_Text & CSTR(oPrinter.Attributes)
wscript.echo L_Text_Msg_Printer13_Text & L_Space_Text & CSTR(oPrinter.Priority)
wscript.echo L_Text_Msg_Printer14_Text & L_Space_Text & CStr(oPrinter.DefaultPriority)
if CStr(oPrinter.StartTime) <> "" and CStr(oPrinter.UntilTime) <> "" then
wscript.echo L_Text_Msg_Printer15_Text & L_Space_Text & Mid(Mid(CStr(oPrinter.StartTime), 9, 4), 1, 2) & "h" & Mid(Mid(CStr(oPrinter.StartTime), 9, 4), 3, 2)
wscript.echo L_Text_Msg_Printer16_Text & L_Space_Text & Mid(Mid(CStr(oPrinter.UntilTime), 9, 4), 1, 2) & "h" & Mid(Mid(CStr(oPrinter.UntilTime), 9, 4), 3, 2)
end if
wscript.echo L_Text_Msg_Printer17_Text & L_Space_Text & CStr(oPrinter.Jobs)
wscript.echo L_Text_Msg_Printer18_Text & L_Space_Text & CStr(oPrinter.AveragePagesPerMinute)
wscript.echo L_Text_Msg_Printer19_Text & L_Space_Text & PrnStatusToString(oPrinter.PrinterStatus)
wscript.echo L_Text_Msg_Printer20_Text & L_Space_Text & ExtPrnStatusToString(oPrinter.ExtendedPrinterStatus)
wscript.echo L_Text_Msg_Printer21_Text & L_Space_Text & DetectedErrorStateToString(oPrinter.DetectedErrorState)
wscript.echo L_Text_Msg_Printer22_Text & L_Space_Text & ExtDetectedErrorStateToString(oPrinter.ExtendedDetectedErrorState)
Err.Clear
next
wscript.echo L_Empty_Text
wscript.echo L_Text_Msg_General09_Text & L_Space_Text & iTotal
ListPrinters = kErrorSuccess
end function
'
' Get the default printer
'
function GetDefaultPrinter(strUser, strPassword)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg06_Text
dim oService
dim oPrinter
dim iRetval
dim oEnum
iRetval = kErrorFailure
'
' We connect to the local server
'
if WmiConnect("", kNameSpace, strUser, strPassword, oService) then
set oEnum = oService.ExecQuery("select DeviceID from Win32_Printer where default=true")
else
SetDefaultPrinter = kErrorFailure
exit function
end if
if Err.Number = kErrorSuccess then
for each oPrinter in oEnum
wscript.echo L_Text_Msg_General12_Text & L_Space_Text & oPrinter.DeviceID
next
iRetval = kErrorSuccess
else
wscript.echo L_Text_Msg_General13_Text & L_Space_Text & L_Error_Text & L_Space_Text _
& L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description
end if
GetDefaultPrinter = iRetval
end function
'
' Set the default printer
'
function SetDefaultPrinter(strPrinter, strUser, strPassword)
'on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg07_Text
dim oService
dim oPrinter
dim iRetval
dim uResult
iRetval = kErrorFailure
'
' We connect to the local server
'
if WmiConnect("", kNameSpace, strUser, strPassword, oService) then
set oPrinter = oService.Get("Win32_Printer.DeviceID='" & strPrinter & "'")
else
SetDefaultPrinter = kErrorFailure
exit function
end if
'
' Check if Get was successful
'
if Err.Number = kErrorSuccess then
'
' The Err object indicates whether the WMI provider reached the execution
' of the function that sets the default printer. The uResult is the Win32
' error code of the spooler function that sets the default printer
'
uResult = oPrinter.SetDefaultPrinter
if Err.Number = kErrorSuccess then
if uResult = kErrorSuccess then
wscript.echo L_Text_Msg_General15_Text & L_Space_Text & strPrinter
iRetval = kErrorSuccess
else
wscript.echo L_Text_Msg_General14_Text & L_Space_Text _
& L_Text_Error_General03_Text& L_Space_Text & uResult
end if
else
wscript.echo L_Text_Msg_General14_Text & L_Space_Text & L_Error_Text & L_Space_Text _
& L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description
end if
else
wscript.echo L_Text_Msg_General14_Text & L_Space_Text & L_Error_Text & L_Space_Text _
& L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description
'
' Try getting extended error information
'
call LastError()
end if
SetDefaultPrinter = iRetval
end function
'
' Converts the printer status to a string
'
function PrnStatusToString(Status)
dim str
str = L_Empty_Text
select case Status
case 1
str = str + L_Text_Msg_Status01_Text + L_Space_Text
case 2
str = str + L_Text_Msg_Status02_Text + L_Space_Text
case 3
str = str + L_Text_Msg_Status03_Text + L_Space_Text
case 4
str = str + L_Text_Msg_Status04_Text + L_Space_Text
case 5
str = str + L_Text_Msg_Status05_Text + L_Space_Text
case 6
str = str + L_Text_Msg_Status06_Text + L_Space_Text
case 7
str = str + L_Text_Msg_Status07_Text + L_Space_Text
end select
PrnStatusToString = str
end function
'
' Converts the extended printer status to a string
'
function ExtPrnStatusToString(Status)
dim str
str = L_Empty_Text
select case Status
case 1
str = str + L_Text_Msg_Status01_Text + L_Space_Text
case 2
str = str + L_Text_Msg_Status02_Text + L_Space_Text
case 3
str = str + L_Text_Msg_Status03_Text + L_Space_Text
case 4
str = str + L_Text_Msg_Status04_Text + L_Space_Text
case 5
str = str + L_Text_Msg_Status05_Text + L_Space_Text
case 6
str = str + L_Text_Msg_Status06_Text + L_Space_Text
case 7
str = str + L_Text_Msg_Status07_Text + L_Space_Text
case 8
str = str + L_Text_Msg_Status08_Text + L_Space_Text
case 9
str = str + L_Text_Msg_Status09_Text + L_Space_Text
case 10
str = str + L_Text_Msg_Status10_Text + L_Space_Text
case 11
str = str + L_Text_Msg_Status11_Text + L_Space_Text
case 12
str = str + L_Text_Msg_Status12_Text + L_Space_Text
case 13
str = str + L_Text_Msg_Status13_Text + L_Space_Text
case 14
str = str + L_Text_Msg_Status14_Text + L_Space_Text
case 15
str = str + L_Text_Msg_Status15_Text + L_Space_Text
case 16
str = str + L_Text_Msg_Status16_Text + L_Space_Text
case 17
str = str + L_Text_Msg_Status17_Text + L_Space_Text
case 18
str = str + L_Text_Msg_Status18_Text + L_Space_Text
end select
ExtPrnStatusToString = str
end function
'
' Converts the detected error state to a string
'
function DetectedErrorStateToString(Status)
dim str
str = L_Empty_Text
select case Status
case 0
str = str + L_Text_Msg_Status02_Text + L_Space_Text
case 1
str = str + L_Text_Msg_Status01_Text + L_Space_Text
case 2
str = str + L_Text_Msg_Status01_Text + L_Space_Text
case 3
str = str + L_Text_Msg_Status20_Text + L_Space_Text
case 4
str = str + L_Text_Msg_Status21_Text + L_Space_Text
case 5
str = str + L_Text_Msg_Status22_Text + L_Space_Text
case 6
str = str + L_Text_Msg_Status23_Text + L_Space_Text
case 7
str = str + L_Text_Msg_Status24_Text + L_Space_Text
case 8
str = str + L_Text_Msg_Status25_Text + L_Space_Text
case 9
str = str + L_Text_Msg_Status07_Text + L_Space_Text
case 10
str = str + L_Text_Msg_Status26_Text + L_Space_Text
case 11
str = str + L_Text_Msg_Status27_Text + L_Space_Text
end select
DetectedErrorStateToString = str
end function
'
' Converts the extended detected error state to a string
'
function ExtDetectedErrorStateToString(Status)
dim str
str = L_Empty_Text
select case Status
case 0
str = str + L_Text_Msg_Status02_Text + L_Space_Text
case 1
str = str + L_Text_Msg_Status01_Text + L_Space_Text
case 2
str = str + L_Text_Msg_Status01_Text + L_Space_Text
case 3
str = str + L_Text_Msg_Status20_Text + L_Space_Text
case 4
str = str + L_Text_Msg_Status21_Text + L_Space_Text
case 5
str = str + L_Text_Msg_Status22_Text + L_Space_Text
case 6
str = str + L_Text_Msg_Status23_Text + L_Space_Text
case 7
str = str + L_Text_Msg_Status24_Text + L_Space_Text
case 8
str = str + L_Text_Msg_Status25_Text + L_Space_Text
case 9
str = str + L_Text_Msg_Status07_Text + L_Space_Text
case 10
str = str + L_Text_Msg_Status26_Text + L_Space_Text
case 11
str = str + L_Text_Msg_Status27_Text + L_Space_Text
case 12
str = str + L_Text_Msg_Status28_Text + L_Space_Text
case 13
str = str + L_Text_Msg_Status29_Text + L_Space_Text
case 14
str = str + L_Text_Msg_Status30_Text + L_Space_Text
case 15
str = str + L_Text_Msg_Status31_Text + L_Space_Text
case 16
str = str + L_Text_Msg_Status32_Text + L_Space_Text
end select
ExtDetectedErrorStateToString = str
end function
'
' Debug display helper function
'
sub DebugPrint(uFlags, strString)
if gDebugFlag = true then
if uFlags = kDebugTrace then
wscript.echo L_Debug_Text & L_Space_Text & strString
end if
if uFlags = kDebugError then
if Err <> 0 then
wscript.echo L_Debug_Text & L_Space_Text & strString & L_Space_Text _
& L_Error_Text & L_Space_Text & L_Hex_Text & hex(Err.Number) _
& L_Space_Text & Err.Description
end if
end if
end if
end sub
'
' Parse the command line into its components
'
function ParseCommandLine(iAction, strServer, strPrinter, strDriver, strPort, strUser, strPassword)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg08_Text
dim oArgs
dim iIndex
iAction = kActionUnknown
iIndex = 0
set oArgs = wscript.Arguments
while iIndex < oArgs.Count
select case oArgs(iIndex)
case "-a"
iAction = kActionAdd
case "-ac"
iAction = kActionAddConn
case "-d"
iAction = kActionDel
case "-x"
iAction = kActionDelAll
case "-xc"
iAction = kActionDelAllCon
case "-xo"
iAction = kActionDelAllLocal
case "-l"
iAction = kActionList
case "-g"
iAction = kActionGetDefaultPrinter
case "-t"
iAction = kActionSetDefaultPrinter
case "-s"
iIndex = iIndex + 1
strServer = RemoveBackslashes(oArgs(iIndex))
case "-p"
iIndex = iIndex + 1
strPrinter = oArgs(iIndex)
case "-m"
iIndex = iIndex + 1
strDriver = oArgs(iIndex)
case "-u"
iIndex = iIndex + 1
strUser = oArgs(iIndex)
case "-w"
iIndex = iIndex + 1
strPassword = oArgs(iIndex)
case "-r"
iIndex = iIndex + 1
strPort = oArgs(iIndex)
case "-?"
Usage(true)
exit function
case else
Usage(true)
exit function
end select
iIndex = iIndex + 1
wend
if Err = kErrorSuccess then
ParseCommandLine = kErrorSuccess
else
wscript.echo L_Text_Error_General02_Text & L_Space_Text & L_Error_Text & L_Space_Text _
& L_Hex_Text & hex(Err.Number) & L_Space_text & Err.Description
ParseCommandLine = kErrorFailure
end if
end function
'
' Display command usage.
'
sub Usage(bExit)
wscript.echo L_Help_Help_General01_Text
wscript.echo L_Help_Help_General02_Text
wscript.echo L_Help_Help_General03_Text
wscript.echo L_Help_Help_General04_Text
wscript.echo L_Help_Help_General05_Text
wscript.echo L_Help_Help_General06_Text
wscript.echo L_Help_Help_General07_Text
wscript.echo L_Help_Help_General08_Text
wscript.echo L_Help_Help_General09_Text
wscript.echo L_Help_Help_General10_Text
wscript.echo L_Help_Help_General11_Text
wscript.echo L_Help_Help_General12_Text
wscript.echo L_Help_Help_General13_Text
wscript.echo L_Help_Help_General14_Text
wscript.echo L_Help_Help_General15_Text
wscript.echo L_Help_Help_General16_Text
wscript.echo L_Help_Help_General17_Text
wscript.echo L_Help_Help_General18_Text
wscript.echo L_Help_Help_General19_Text
wscript.echo L_Empty_Text
wscript.echo L_Help_Help_General20_Text
wscript.echo L_Help_Help_General21_Text
wscript.echo L_Help_Help_General22_Text
wscript.echo L_Help_Help_General23_Text
wscript.echo L_Help_Help_General24_Text
wscript.echo L_Help_Help_General25_Text
wscript.echo L_Help_Help_General26_Text
wscript.echo L_Help_Help_General27_Text
wscript.echo L_Help_Help_General28_Text
wscript.echo L_Help_Help_General29_Text
if bExit then
wscript.quit(1)
end if
end sub
'
' Determines which program is being used to run this script.
' Returns true if the script host is cscript.exe
'
function IsHostCscript()
on error resume next
dim strFullName
dim strCommand
dim i, j
dim bReturn
bReturn = false
strFullName = WScript.FullName
i = InStr(1, strFullName, ".exe", 1)
if i <> 0 then
j = InStrRev(strFullName, "\", i, 1)
if j <> 0 then
strCommand = Mid(strFullName, j+1, i-j-1)
if LCase(strCommand) = "cscript" then
bReturn = true
end if
end if
end if
if Err <> 0 then
wscript.echo L_Text_Error_General01_Text & L_Space_Text & L_Error_Text & L_Space_Text _
& L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description
end if
IsHostCscript = bReturn
end function
'
' Retrieves extended information about the last error that occurred
' during a WBEM operation. The methods that set an SWbemLastError
' object are GetObject, PutInstance, DeleteInstance
'
sub LastError()
on error resume next
dim oError
set oError = CreateObject("WbemScripting.SWbemLastError")
if Err = kErrorSuccess then
wscript.echo L_Operation_Text & L_Space_Text & oError.Operation
wscript.echo L_Provider_Text & L_Space_Text & oError.ProviderName
wscript.echo L_Description_Text & L_Space_Text & oError.Description
wscript.echo L_Text_Error_General03_Text & L_Space_Text & oError.StatusCode
end if
end sub
'
' Connects to the WMI service on a server. oService is returned as a service
' object (SWbemServices)
'
function WmiConnect(strServer, strNameSpace, strUser, strPassword, oService)
on error resume next
dim oLocator
dim bResult
oService = null
bResult = false
set oLocator = CreateObject("WbemScripting.SWbemLocator")
if Err = kErrorSuccess then
set oService = oLocator.ConnectServer(strServer, strNameSpace, strUser, strPassword)
if Err = kErrorSuccess then
bResult = true
oService.Security_.impersonationlevel = 3
'
' Required to perform administrative tasks on the spooler service
'
oService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege"
Err.Clear
else
wscript.echo L_Text_Msg_General11_Text & L_Space_Text & L_Error_Text _
& L_Space_Text & L_Hex_Text & hex(Err.Number) & L_Space_Text _
& Err.Description
end if
else
wscript.echo L_Text_Msg_General10_Text & L_Space_Text & L_Error_Text _
& L_Space_Text & L_Hex_Text & hex(Err.Number) & L_Space_Text _
& Err.Description
end if
WmiConnect = bResult
end function
'
' Remove leading "\\" from server name
'
function RemoveBackslashes(strServer)
dim strRet
strRet = strServer
if Left(strServer, 2) = "\\" and Len(strServer) > 2 then
strRet = Mid(strServer, 3)
end if
RemoveBackslashes = strRet
end function
|
<gh_stars>1-10
Wscript.Echo "FullName:",Wscript.FullName
Wscript.Echo "Name:",Wscript.Name
Wscript.Echo "Path:",Wscript.Path
Wscript.Echo "ScriptFullName:",Wscript.ScriptFullName
Wscript.Echo "ScriptName:",Wscript.ScriptName
|
<filename>Task/Array-concatenation/VBA/array-concatenation.vba
Option Explicit
Sub MainConcat_Array()
Dim Aray_1() As Variant, Aray_2() As Variant
Dim Result() As Variant
Aray_1 = Array(1, 2, 3, 4, 5, #11/24/2017#, "azerty")
Aray_2 = Array("A", "B", "C", 18, "End")
Result = Concat_Array(Aray_1, Aray_2)
Debug.Print "With Array 1 : " & Join(Aray_1, ", ")
Debug.Print "And Array 2 : " & Join(Aray_2, ", ")
Debug.Print "The result is Array 3 : " & Join(Result, ", ")
End Sub
Function Concat_Array(A1() As Variant, A2() As Variant) As Variant()
Dim TmpA1() As Variant, N As Long, i As Long
N = UBound(A1) + 1
TmpA1 = A1
ReDim Preserve TmpA1(N + UBound(A2))
For i = N To UBound(TmpA1)
TmpA1(i) = A2(i - N)
Next
Concat_Array = TmpA1
End Function
|
'vigenere cypher
option explicit
const asca =65 'ascii(a)
function filter(s)
with new regexp
.pattern="[^A-Z]"
.global=1
filter=.replace(ucase(s),"")
end with
end function
function vigenere (s,k,sign)
dim s1,i,a,b
for i=0 to len(s)-1
a=asc(mid(s,i+1,1))-asca
b=sign * (asc(mid(k,(i mod len(k))+1,1))-asca)
s1=s1 & chr(((a+b+26) mod 26) +asca)
next
vigenere=s1
end function
function encrypt(s,k): encrypt=vigenere(s,k,1) :end function
function decrypt(s,k): decrypt=vigenere(s,k,-1) :end function
'test--------------------------
dim plaintext,filtered,key,encoded
key="VIGENERECYPHER"
plaintext = "Beware the Jabberwock, my son! The jaws that bite, the claws that catch!"
filtered= filter(plaintext)
wscript.echo filtered
encoded=encrypt(filtered,key)
wscript.echo encoded
wscript.echo decrypt(encoded,key)
|
'
L_Welcome_MsgBox_Message_Text = "This script demonstrates how to add/remove snapins from scriptable objects."
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample"
Call Welcome()
' ********************************************************************************
Dim mmc
Dim doc
Dim snapins
Dim frame
Dim views
Dim view
Dim scopenamespace
Dim rootnode
Dim Nodes
Dim scopenode
Dim SnapNode1
Dim Sample
Dim Cert
Dim Services
Dim MultiSel
Dim Eventlog
Dim Index
'get the various objects we'll need
Set mmc = wscript.CreateObject("MMC20.Application")
Set frame = mmc.Frame
Set doc = mmc.Document
Set namespace = doc.ScopeNamespace
Set rootnode = namespace.GetRoot
Set views = doc.views
Set view = views(1)
Set snapins = doc.snapins
Set Sample = snapins.Add("{18731372-1D79-11D0-A29B-00C04FD909DD}") ' Sample snapin
Set Cert = snapins.Add("{53D6AB1D-2488-11D1-A28C-00C04FB94F17}") ' Certificates s
Set Index = snapins.Add("{95AD72F0-44CE-11D0-AE29-00AA004B9986}") ' index snapin
Set Eventlog = snapins.Add("{975797FC-4E2A-11D0-B702-00C04FD8DBF7}") ' eventlog
Set Services = snapins.Add("{58221c66-ea27-11cf-adcf-00aa00a80033}") ' the services
snapins.Remove Cert
snapins.Remove Eventlog
Set scopenamespace = doc.scopenamespace
Set view = doc.ActiveView
Set Node = view.ActiveScopeNode
snapins.Remove Sample
snapins.Remove Services
Set mmc = Nothing
' ********************************************************************************
' *
' * Welcome
' *
Sub Welcome()
Dim intDoIt
intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
vbOKCancel + vbInformation, _
L_Welcome_MsgBox_Title_Text )
If intDoIt = vbCancel Then
WScript.Quit
End If
End Sub
|
Sub Rosetta_100Doors()
Dim Door(100) As Boolean, i As Integer, j As Integer
For i = 1 To 100 Step 1
For j = i To 100 Step i
Door(j) = Not Door(j)
Next j
If Door(i) = True Then
Debug.Print "Door " & i & " is Open"
Else
Debug.Print "Door " & i & " is Closed"
End If
Next i
End Sub
<!-- /lang -->
*** USE THIS ONE, SEE COMMENTED LINES, DONT KNOW WHY EVERYBODY FOLLOWED OTHERS ANSWERS AND CODED THE PROBLEM DIFFERENTLY ***
*** ALWAYS USE AND TEST A READABLE, EASY TO COMPREHEND CODING BEFORE 'OPTIMIZING' YOUR CODE AND TEST THE 'OPTIMIZED' CODE AGAINST THE 'READABLE' ONE.
<NAME>.
Sub Rosetta_100Doors2()
Dim Door(100) As Boolean, i As Integer, j As Integer
Dim strAns As String
' There are 100 doors in a row that are all initially closed.
' You make 100 passes by the doors.
For j = 1 To 100
' The first time through, visit every door and toggle the door
' (if the door is closed, open it; if it is open, close it).
For i = 1 To 100 Step 1
Door(i) = Not Door(i)
Next i
' The second time, only visit every 2nd door (door #2, #4, #6, ...), and toggle it.
For i = 2 To 100 Step 2
Door(i) = Not Door(i)
Next i
' The third time, visit every 3rd door (door #3, #6, #9, ...), etc, until you only visit the 100th door.
For i = 3 To 100 Step 3
Door(i) = Not Door(i)
Next i
Next j
For j = 1 To 100
If Door(j) = True Then
strAns = j & strAns & ", "
End If
Next j
If Right(strAns, 2) = ", " Then strAns = Left(strAns, Len(strAns) - 2)
If Len(strAns) = 0 Then strAns = "0"
Debug.Print "Doors [" & strAns & "] are open, the rest are closed."
' Doors [0] are open, the rest are closed., AKA ZERO DOORS OPEN
End Sub
|
<filename>base/pnp/tools/devcon2/scripts/test3.vbs
'
' test3.vbs
'
' enumerate class and devices of class
'
DIM WshSHell
DIM DevCon
DIM SetupClasses
DIM SetupClass
DIM Devices
DIM Device
SET WshShell = WScript.CreateObject("WScript.Shell")
SET DevCon = WScript.CreateObject("DevCon.DeviceConsole")
WScript.Echo "Enumerate HDC"
WScript.Echo ""
'
' a class name may be used by more than one GUID
' so DevCon.GetSetupClasses may generate a list of more than one element
'
SET SetupClasses = DevCon.SetupClasses("hdc")
Count = SetupClasses.Count
Wscript.Echo "Count="+CStr(Count)
FOR EACH SetupClass IN SetupClasses
WScript.Echo "Class " + SetupClass + " = " + SetupClass.Guid
SET Devices = SetupClass.Devices()
FOR EACH Device IN Devices
WScript.Echo " "+Device
NEXT
NEXT
WScript.Echo ""
WScript.Echo "Enumerate {4D36E96A-E325-11CE-BFC1-08002BE10318}"
WScript.Echo ""
'
' an empty list can be created
'
SET SetupClasses = DevCon.CreateEmptySetupClassList()
'
' adding a GUID adds a single item. adding a name may add multiple items
'
SetupClasses.Add "{4D36E96A-E325-11CE-BFC1-08002BE10318}"
SET Devices = SetupClasses(1).Devices()
FOR EACH Device IN Devices
WScript.Echo " "+Device
NEXT
WScript.Echo ""
WScript.Echo "Enumerate HDC method 2"
WScript.Echo ""
'
' device list from classes collection
'
SET SetupClasses = DevCon.SetupClasses("hdc")
SET Devices = SetupClasses.Devices()
FOR EACH Device IN Devices
WScript.Echo " "+Device
NEXT
WScript.Echo ""
WScript.Echo "Enumerate HDC method 3"
WScript.Echo ""
'
' device list from class name directly
'
SET Devices = DevCon.DevicesBySetupClasses("hdc")
FOR EACH Device IN Devices
WScript.Echo " "+Device
NEXT
|
<gh_stars>1-10
Public Sub Main()
Dim c As VBA.Collection
' initial state: Nothing
Debug.Assert c Is Nothing
' create an instance
Set c = New VBA.Collection
Debug.Assert Not c Is Nothing
' release the instance
Set c = Nothing
Debug.Assert c Is Nothing
End Sub
|
Public Sub Quick(a() As Variant, last As Integer)
' quicksort a Variant array (1-based, numbers or strings)
Dim aLess() As Variant
Dim aEq() As Variant
Dim aGreater() As Variant
Dim pivot As Variant
Dim naLess As Integer
Dim naEq As Integer
Dim naGreater As Integer
If last > 1 Then
'choose pivot in the middle of the array
pivot = a(Int((last + 1) / 2))
'construct arrays
naLess = 0
naEq = 0
naGreater = 0
For Each el In a()
If el > pivot Then
naGreater = naGreater + 1
ReDim Preserve aGreater(1 To naGreater)
aGreater(naGreater) = el
ElseIf el < pivot Then
naLess = naLess + 1
ReDim Preserve aLess(1 To naLess)
aLess(naLess) = el
Else
naEq = naEq + 1
ReDim Preserve aEq(1 To naEq)
aEq(naEq) = el
End If
Next
'sort arrays "less" and "greater"
Quick aLess(), naLess
Quick aGreater(), naGreater
'concatenate
P = 1
For i = 1 To naLess
a(P) = aLess(i): P = P + 1
Next
For i = 1 To naEq
a(P) = aEq(i): P = P + 1
Next
For i = 1 To naGreater
a(P) = aGreater(i): P = P + 1
Next
End If
End Sub
Public Sub QuicksortTest()
Dim a(1 To 26) As Variant
'populate a with numbers in descending order, then sort
For i = 1 To 26: a(i) = 26 - i: Next
Quick a(), 26
For i = 1 To 26: Debug.Print a(i);: Next
Debug.Print
'now populate a with strings in descending order, then sort
For i = 1 To 26: a(i) = Chr$(Asc("z") + 1 - i) & "-stuff": Next
Quick a(), 26
For i = 1 To 26: Debug.Print a(i); " ";: Next
Debug.Print
End Sub
|
<reponame>npocmaka/Windows-Server-2003<filename>admin/wmi/wbem/scripting/test/vbscript/stress/arraycon.vbs<gh_stars>10-100
'***************************************************************************
'This script tests the manipulation of context values, in the case that the
'context value is an array type
'***************************************************************************
On Error Resume Next
while true
Set Context = CreateObject("WbemScripting.SWbemNamedValueSet")
Context.Add "n1", Array (1, 2, 3)
str = "The initial value of n1 is {"
for x=LBound(Context("n1")) to UBound(Context("n1"))
str = str & Context("n1")(x)
if x <> UBound(Context("n1")) Then
str = str & ", "
End if
next
str = str & "}"
WScript.Echo str
WScript.Echo ""
'Verify we can report the value of an element of the context value
v = Context("n1")
WScript.Echo "By indirection the first element of n1 has value:",v(0)
'Verify we can report the value directly
WScript.Echo "By direct access the first element of n1 has value:", Context("n1")(0)
'Verify we can set the value of a single named value element
Context("n1")(1) = 11
WScript.Echo "After direct assignment the first element of n1 has value:", Context("n1")(1)
'Verify we can set the value of a single named value element
Set v = Context("n1")
v(1) = 345
WScript.Echo "After indirect assignment the first element of n1 has value:", Context("n1")(1)
'Verify we can set the value of an entire context value
Context("n1") = Array (5, 34, 178871)
WScript.Echo "After direct array assignment the first element of n1 has value:", Context("n1")(1)
str = "After direct assignment the entire value of n1 is {"
for x=LBound(Context("n1")) to UBound(Context("n1"))
str = str & Context("n1")(x)
if x <> UBound(Context("n1")) Then
str = str & ", "
End if
next
str = str & "}"
WScript.Echo str
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
wend
|
<filename>examples/FreeBASIC.bas<gh_stars>10-100
Cls
Print "Hello World!"
Sleep
End
|
<filename>sdktools/debuggers/oca/webv3/tools/replacetext.vbs<gh_stars>10-100
dim CommandLine
dim SourceFileContents(50000)
dim counter
dim TargetFile
set CommandLine=wscript.arguments
if CommandLine.Count < 2 then
Usage
else
doMain CommandLine(0), CommandLine(1), CommandLine(2)
end if
sub Usage
wscript.stdout.write "USAGE: ReplaceText.vbs <fileName> <Serach String> <Replace Value>"
end sub
sub doMain ( strFileName, strSearchString, strReplaceValue )
OpenSourceFile strFileName
OpenTargetFile strFileName
FindAndReplace strSearchString, strReplaceValue
end sub
sub FindAndReplace( strSearchString, strReplaceValue )
Println "Searching for: " & strSearchString & " and will replace with: " & strReplaceValue
println "Total lines: " & Counter
for i = 1 to counter
if instr( 1, SourceFileContents(i), strSearchString ) then
PrintLn "Found at line: " & i
TargetFile.WriteLine strReplaceValue
else
TargetFile.WriteLine SourceFileContents(i)
end if
next
end sub
sub OpenSourceFile ( strFileName )
set FileSystemObject=CreateObject("Scripting.FileSystemObject")
set SourceFile=FileSystemObject.OpenTextFile( strFileName )
counter=1
do while SourceFile.AtEndOfStream <> true
SourceFileContents(counter)= SourceFile.ReadLine
counter=counter+1
loop
SourceFile.close()
end sub
sub OpenTargetFile ( strFileName )
set FileSystemObject=CreateObject("Scripting.FileSystemObject")
set TargetFile=FileSystemObject.CreateTextFile( strFileName, true )
end sub
'*****************************************************************************************************
' Helper Routines
'*****************************************************************************************************
sub PrintLn( Text )
wScript.StdOut.Write Text & vbLf
end sub
sub Print( Text )
wScript.StdOut.Write Text
end sub
|
<filename>admin/wmi/wbem/scripting/test/whistler/refresh/vb1.frm
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Dim x As SWbemObjectEx
Set x = GetObject("wmi:win32_logicaldisk")
x.Refresh_ Array("Foo", "Bar")
j = 1
End Sub
|
<gh_stars>1-10
'mung.vbs
option explicit
dim c
if wscript.arguments.count = 1 then
c = wscript.arguments(0)
c = c + 1
else
c = 0
end if
wscript.echo "[Depth",c & "] Mung until no good."
CreateObject("WScript.Shell").Run "cscript Mung.vbs " & c, 1, true
wscript.echo "[Depth",c & "] no good."
|
<gh_stars>10-100
Attribute VB_Name = "Main"
Option Explicit
Private Const FIRST_C As Long = 0
Private Const SECOND_C As Long = 1
Private p_dictStopWords(1) As Scripting.Dictionary
Private p_dictHelpImage(1) As Scripting.Dictionary
Private p_dictScopes(1) As Scripting.Dictionary
Private p_dictFTS(1) As Scripting.Dictionary
Private p_dictOperators(1) As Scripting.Dictionary
Private p_dictStopSigns(1) As Scripting.Dictionary
Private p_dictIndex(1) As Scripting.Dictionary
Private p_dictSynTable(1) As Scripting.Dictionary
Private p_dictTaxonomy(1) As Scripting.Dictionary
Private p_intNumNodesAdd(1) As Long
Private p_intNumNodesDel(1) As Long
Private p_intNumTopicsAdd(1) As Long
Private p_intNumTopicsDel(1) As Long
Private p_intNumKeywords(1) As Long
Private p_intNumKW As Long
Private p_strCab1 As String
Private p_strCab2 As String
Private p_strHTMReport As String
Public Sub MainFunction( _
ByVal i_strCab1 As String, _
ByVal i_strCab2 As String, _
ByVal i_strHTMReport As String _
)
On Error GoTo LError
Dim strFolder1 As String
Dim strFolder2 As String
Dim intErrorNumber As Long
p_strCab1 = i_strCab1
p_strCab2 = i_strCab2
p_strHTMReport = i_strHTMReport
strFolder1 = Cab2Folder(i_strCab1)
strFolder2 = Cab2Folder(i_strCab2)
p_GatherData FIRST_C, strFolder1
p_GatherData SECOND_C, strFolder2
p_Report
LEnd:
DeleteCabFolder strFolder1
DeleteCabFolder strFolder2
Exit Sub
LError:
frmMain.Output Err.Description, LOGGING_TYPE_ERROR_E
intErrorNumber = Err.Number
DeleteCabFolder strFolder1
DeleteCabFolder strFolder2
Err.Raise intErrorNumber
End Sub
Private Sub p_GatherData( _
ByVal i_intIndex As Long, _
ByVal i_strFolder As String _
)
Dim DOMDocPkgDesc As MSXML2.DOMDocument
Dim intNumHHTs As Long
Dim intIndex As Long
Dim strFile As String
Set p_dictStopWords(i_intIndex) = New Scripting.Dictionary
Set p_dictHelpImage(i_intIndex) = New Scripting.Dictionary
Set p_dictScopes(i_intIndex) = New Scripting.Dictionary
Set p_dictFTS(i_intIndex) = New Scripting.Dictionary
Set p_dictOperators(i_intIndex) = New Scripting.Dictionary
Set p_dictStopSigns(i_intIndex) = New Scripting.Dictionary
Set p_dictIndex(i_intIndex) = New Scripting.Dictionary
Set p_dictSynTable(i_intIndex) = New Scripting.Dictionary
Set p_dictTaxonomy(i_intIndex) = New Scripting.Dictionary
p_intNumNodesAdd(i_intIndex) = 0
p_intNumNodesDel(i_intIndex) = 0
p_intNumTopicsAdd(i_intIndex) = 0
p_intNumTopicsDel(i_intIndex) = 0
p_intNumKeywords(i_intIndex) = 0
p_intNumKW = 0
Set DOMDocPkgDesc = GetPackageDescription(i_strFolder)
intNumHHTs = GetNumberOfHHTsListedInPackageDescription(DOMDocPkgDesc)
For intIndex = 1 To intNumHHTs
strFile = GetNthHHTListedInPackageDescription(DOMDocPkgDesc, intIndex)
p_ReadFile i_intIndex, i_strFolder, strFile
Next
End Sub
Private Sub p_ReadFile( _
ByVal i_intIndex As Long, _
ByVal i_strFolder As String, _
ByVal i_strFile As String _
)
Dim strLocation As String
Dim strPath As String
Dim DOMDoc As MSXML2.DOMDocument
If (i_intIndex = FIRST_C) Then
strLocation = " in first CAB"
Else
strLocation = " in second CAB"
End If
frmMain.Output "Processing " & i_strFile & strLocation & "...", LOGGING_TYPE_NORMAL_E
strPath = i_strFolder & "\" & i_strFile
Set DOMDoc = GetFileAsDomDocument(strPath)
p_GetNumNodesTopicsKeywords i_intIndex, DOMDoc
p_ReadStopWords i_intIndex, DOMDoc
p_ReadHelpImage i_intIndex, DOMDoc
p_ReadScopes i_intIndex, DOMDoc
p_ReadFTS i_intIndex, DOMDoc
p_ReadOperators i_intIndex, DOMDoc
p_ReadStopSigns i_intIndex, DOMDoc
p_ReadIndex i_intIndex, DOMDoc
p_ReadSynTable i_intIndex, DOMDoc
p_ReadTaxonomy i_intIndex, DOMDoc
End Sub
Private Sub p_GetNumNodesTopicsKeywords( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
i_DOMDoc.setProperty "SelectionLanguage", "XPath"
Set DOMNodeList = i_DOMDoc.selectNodes("//TAXONOMY_ENTRY[@ENTRY and @ACTION='ADD']")
p_intNumNodesAdd(i_intIndex) = p_intNumNodesAdd(i_intIndex) + DOMNodeList.length
Set DOMNodeList = i_DOMDoc.selectNodes("//TAXONOMY_ENTRY[@ENTRY and @ACTION='DEL']")
p_intNumNodesDel(i_intIndex) = p_intNumNodesDel(i_intIndex) + DOMNodeList.length
Set DOMNodeList = i_DOMDoc.selectNodes("//TAXONOMY_ENTRY[not(@ENTRY) and @ACTION='ADD']")
p_intNumTopicsAdd(i_intIndex) = p_intNumTopicsAdd(i_intIndex) + DOMNodeList.length
Set DOMNodeList = i_DOMDoc.selectNodes("//TAXONOMY_ENTRY[not(@ENTRY) and @ACTION='DEL']")
p_intNumTopicsDel(i_intIndex) = p_intNumTopicsDel(i_intIndex) + DOMNodeList.length
Set DOMNodeList = i_DOMDoc.selectNodes("//TAXONOMY_ENTRY[not(@ENTRY) and @ACTION='ADD']/KEYWORD")
p_intNumKeywords(i_intIndex) = p_intNumKeywords(i_intIndex) + DOMNodeList.length
End Sub
Private Sub p_ReadStopWords( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strStopWord As String
Dim strAction As String
Dim strOldAction As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/STOPWORD_ENTRIES/STOPWORD")
For Each DOMNode In DOMNodeList
DoEvents
strAction = UCase$(p_GetAttribute(DOMNode, "ACTION"))
strStopWord = UCase$(p_GetAttribute(DOMNode, "STOPWORD"))
p_CheckAction "StopWord " & strStopWord, strAction
If (Not p_dictStopWords(i_intIndex).Exists(strStopWord)) Then
p_dictStopWords(i_intIndex).Add strStopWord, strAction
Else
strOldAction = p_dictStopWords(i_intIndex)(strStopWord)
If (strOldAction <> strAction) Then
Err.Raise E_FAIL, , _
"StopWord " & strStopWord & " has incompatible actions: " & _
strOldAction & " & " & strAction
End If
End If
Next
End Sub
Private Sub p_ReadHelpImage( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strChm As String
Dim strAction As String
Dim strOldAction As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/HELPIMAGE/HELPFILE")
For Each DOMNode In DOMNodeList
DoEvents
strAction = UCase$(p_GetAttribute(DOMNode, "ACTION"))
strChm = UCase$(p_GetAttribute(DOMNode, "CHM"))
p_CheckAction "HelpFile " & strChm, strAction
If (Not p_dictHelpImage(i_intIndex).Exists(strChm)) Then
p_dictHelpImage(i_intIndex).Add strChm, strAction
Else
strOldAction = p_dictHelpImage(i_intIndex)(strChm)
If (strOldAction <> strAction) Then
Err.Raise E_FAIL, , _
"HelpFile " & strChm & " has incompatible actions: " & _
strOldAction & " & " & strAction
End If
End If
Next
End Sub
Private Sub p_ReadScopes( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strId As String
Dim strAction As String
Dim strOldAction As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/SCOPE_DEFINITION/SCOPE")
For Each DOMNode In DOMNodeList
DoEvents
strAction = UCase$(p_GetAttribute(DOMNode, "ACTION"))
strId = UCase$(p_GetAttribute(DOMNode, "ID"))
p_CheckAction "Scope " & strId, strAction
If (Not p_dictScopes(i_intIndex).Exists(strId)) Then
p_dictScopes(i_intIndex).Add strId, strAction
Else
strOldAction = p_dictScopes(i_intIndex)(strId)
If (strOldAction <> strAction) Then
Err.Raise E_FAIL, , _
"Scope " & strId & " has incompatible actions: " & _
strOldAction & " & " & strAction
End If
End If
Next
End Sub
Private Sub p_ReadFTS( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strAction As String
Dim strChm As String
Dim strChq As String
Dim strKey As String
Dim strOldAction As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/FTS/HELPFILE")
For Each DOMNode In DOMNodeList
DoEvents
strAction = UCase$(p_GetAttribute(DOMNode, "ACTION"))
strChm = UCase$(p_GetAttribute(DOMNode, "CHM"))
strChq = UCase$(p_GetAttribute(DOMNode, "CHQ", False))
strKey = strChm & "/" & strChq
p_CheckAction "FTS file " & strKey, strAction
If (Not p_dictFTS(i_intIndex).Exists(strKey)) Then
p_dictFTS(i_intIndex).Add strKey, strAction
Else
strOldAction = p_dictFTS(i_intIndex)(strKey)
If (strOldAction <> strAction) Then
Err.Raise E_FAIL, , _
"FTS file " & strKey & " has incompatible actions: " & _
strOldAction & " & " & strAction
End If
End If
Next
End Sub
Private Sub p_ReadOperators( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strOperator As String
Dim strAction As String
Dim strOperation As String
Dim strItem As String
Dim strOldItem As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/OPERATOR_ENTRIES/OPERATOR")
For Each DOMNode In DOMNodeList
DoEvents
strAction = UCase$(p_GetAttribute(DOMNode, "ACTION"))
strOperation = UCase$(p_GetAttribute(DOMNode, "OPERATION"))
strOperator = UCase$(p_GetAttribute(DOMNode, "OPERATOR"))
strItem = strAction & "/" & strOperation
p_CheckAction "Operator " & strOperator, strAction
p_CheckOperation "Operator " & strOperator, strOperation
If (Not p_dictOperators(i_intIndex).Exists(strOperator)) Then
p_dictOperators(i_intIndex).Add strOperator, strItem
Else
strOldItem = p_dictOperators(i_intIndex)(strOperator)
If (strOldItem <> strItem) Then
Err.Raise E_FAIL, , _
"Operator " & strOperator & " has incompatible definitions: " & _
strOldItem & " and " & strItem
End If
End If
Next
End Sub
Private Sub p_ReadStopSigns( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strAction As String
Dim strContext As String
Dim strStopSign As String
Dim strItem As String
Dim strOldItem As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/STOPSIGN_ENTRIES/STOPSIGN")
For Each DOMNode In DOMNodeList
DoEvents
strAction = UCase$(p_GetAttribute(DOMNode, "ACTION"))
strContext = UCase$(p_GetAttribute(DOMNode, "CONTEXT"))
strStopSign = UCase$(p_GetAttribute(DOMNode, "STOPSIGN"))
strItem = strAction & "/" & strContext
p_CheckAction "StopSign " & strStopSign, strAction
p_CheckContext "StopSign " & strStopSign, strContext
If (Not p_dictStopSigns(i_intIndex).Exists(strStopSign)) Then
p_dictStopSigns(i_intIndex).Add strStopSign, strItem
Else
strOldItem = p_dictStopSigns(i_intIndex)(strStopSign)
If (strOldItem <> strItem) Then
Err.Raise E_FAIL, , _
"StopSign " & strStopSign & " has incompatible definitions: " & _
strOldItem & " and " & strItem
End If
End If
Next
End Sub
Private Sub p_ReadIndex( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strAction As String
Dim strChm As String
Dim strHhk As String
Dim strScope As String
Dim strKey As String
Dim strItem As String
Dim strOldItem As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/INDEX/HELPFILE")
For Each DOMNode In DOMNodeList
DoEvents
strAction = UCase$(p_GetAttribute(DOMNode, "ACTION"))
strChm = UCase$(p_GetAttribute(DOMNode, "CHM"))
strHhk = UCase$(p_GetAttribute(DOMNode, "HHK"))
strScope = UCase$(p_GetAttribute(DOMNode, "SCOPE", False))
strKey = strChm & strHhk
strItem = strAction & "/" & strScope
p_CheckAction "Index " & strKey, strAction
If (Not p_dictIndex(i_intIndex).Exists(strKey)) Then
p_dictIndex(i_intIndex).Add strKey, strItem
Else
strOldItem = p_dictIndex(i_intIndex)(strKey)
If (strOldItem <> strItem) Then
Err.Raise E_FAIL, , _
"Index " & strKey & " has incompatible definitions: " & _
strOldItem & " and " & strItem
End If
End If
Next
End Sub
Private Sub p_ReadSynTable( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeSynSetList As MSXML2.IXMLDOMNodeList
Dim DOMNodeSynonymList As MSXML2.IXMLDOMNodeList
Dim DOMNodeSynSet As MSXML2.IXMLDOMNode
Dim DOMNodeSynonym As MSXML2.IXMLDOMNode
Dim dict As Scripting.Dictionary
Dim strId As String
Dim strSynonym As String
Dim strAction As String
Dim strOldAction As String
Set DOMNodeSynSetList = i_DOMDoc.selectNodes("METADATA/SYNTABLE/SYNSET")
For Each DOMNodeSynSet In DOMNodeSynSetList
DoEvents
strId = UCase$(p_GetAttribute(DOMNodeSynSet, "ID"))
If (p_dictSynTable(i_intIndex).Exists(strId)) Then
Set dict = p_dictSynTable(i_intIndex)(strId)
Else
Set dict = New Scripting.Dictionary
p_dictSynTable(i_intIndex).Add strId, dict
End If
Set DOMNodeSynonymList = DOMNodeSynSet.selectNodes("SYNONYM")
For Each DOMNodeSynonym In DOMNodeSynonymList
DoEvents
strSynonym = UCase$(DOMNodeSynonym.Text)
strAction = UCase$(p_GetAttribute(DOMNodeSynonym, "ACTION"))
p_CheckAction "SynSet " & strId & ": " & "Synonym " & strSynonym, strAction
If (Not dict.Exists(strSynonym)) Then
dict.Add strSynonym, strAction
Else
strOldAction = dict(strSynonym)
If (strOldAction <> strAction) Then
Err.Raise E_FAIL, , _
"SynSet " & strId & ": " & "Synonym " & strSynonym & " has incompatible actions: " & _
strOldAction & " & " & strAction
End If
End If
Next
Next
End Sub
Private Sub p_ReadTaxonomy( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMNodeListKW As MSXML2.IXMLDOMNodeList
Dim DOMNodeKW As MSXML2.IXMLDOMNode
Dim strCategory As String
Dim strEntry As String
Dim strURI As String
Dim strKey As String
Dim intNumKW As Long
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/TAXONOMY_ENTRIES/TAXONOMY_ENTRY")
For Each DOMNode In DOMNodeList
DoEvents
strCategory = UCase$(p_GetAttribute(DOMNode, "CATEGORY"))
strEntry = UCase$(p_GetAttribute(DOMNode, "ENTRY", False))
strURI = UCase$(p_GetAttribute(DOMNode, "URI", False))
strKey = "CATEGORY: " & strCategory & ";" & _
"ENTRY: " & strEntry & ";" & _
"URI: " & strURI & ";"
Set DOMNodeListKW = DOMNode.selectNodes("KEYWORD")
intNumKW = DOMNodeListKW.length
For Each DOMNodeKW In DOMNodeListKW
DOMNode.removeChild DOMNodeKW
Next
If (Not p_dictTaxonomy(i_intIndex).Exists(strKey)) Then
p_dictTaxonomy(i_intIndex).Add strKey, DOMNode
p_intNumKW = p_intNumKW + intNumKW
Else
Err.Raise E_FAIL, , "Taxonomy entry """ & strKey & """ is defined twice"
End If
Next
End Sub
Private Sub p_Report()
Dim intSet1 As Long
Dim intAdd1 As Long
Dim intDel1 As Long
Dim intSet2 As Long
Dim intAdd2 As Long
Dim intDel2 As Long
Dim str As String
Dim strHTM As String
Dim bln As Boolean
Dim intExtraHHKsInFirstCab As Long
strHTM = "<html><head><title>LocDiff report of " & Date & " " & Time & "</title></head><body>"
frmMain.Output vbCrLf & "1st CAB: " & p_strCab1, LOGGING_TYPE_NORMAL_E
frmMain.Output "2nd CAB: " & p_strCab2 & vbCrLf, LOGGING_TYPE_NORMAL_E
strHTM = strHTM & "Reference (1st) CAB: " & p_strCab1 & "<BR>"
strHTM = strHTM & "Localized (2nd) CAB: " & p_strCab2 & "<BR><BR>"
strHTM = strHTM & "<table border='1'>" & _
"<tr><td> </td><td> </td><td>Reference CAB</font></td><td>Localized CAB</td></tr>"
frmMain.Output "StopWords:", LOGGING_TYPE_NORMAL_E
p_GetActionStats p_dictStopWords(FIRST_C), intAdd1, intDel1, p_dictStopWords(SECOND_C), intAdd2, intDel2
frmMain.Output vbTab & "1st CAB: ADDs: " & intAdd1 & "; DELs: " & intDel1, LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "2nd CAB: ADDs: " & intAdd2 & "; DELs: " & intDel2, LOGGING_TYPE_NORMAL_E
strHTM = strHTM & "<tr>" & _
p_GetHTMRow("StopWords", "ADDs", intAdd1, intAdd2) & _
"</tr><tr>" & _
p_GetHTMRow(" ", "DELs", intDel1, intDel2) & _
"</tr>"
frmMain.Output "StopSigns:", LOGGING_TYPE_NORMAL_E
p_GetActionStats p_dictStopSigns(FIRST_C), intAdd1, intDel1, p_dictStopSigns(SECOND_C), intAdd2, intDel2
frmMain.Output vbTab & "1st CAB: ADDs: " & intAdd1 & "; DELs: " & intDel1, LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "2nd CAB: ADDs: " & intAdd2 & "; DELs: " & intDel2, LOGGING_TYPE_NORMAL_E
strHTM = strHTM & "<tr>" & _
p_GetHTMRow("StopSigns", "ADDs", intAdd1, intAdd2) & _
"</tr><tr>" & _
p_GetHTMRow(" ", "DELs", intDel1, intDel2) & _
"</tr>"
frmMain.Output "Operators:", LOGGING_TYPE_NORMAL_E
p_GetActionStats p_dictOperators(FIRST_C), intAdd1, intDel1, p_dictOperators(SECOND_C), intAdd2, intDel2
frmMain.Output vbTab & "1st CAB: ADDs: " & intAdd1 & "; DELs: " & intDel1, LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "2nd CAB: ADDs: " & intAdd2 & "; DELs: " & intDel2, LOGGING_TYPE_NORMAL_E
strHTM = strHTM & "<tr>" & _
p_GetHTMRow("Operators", "ADDs", intAdd1, intAdd2) & _
"</tr><tr>" & _
p_GetHTMRow(" ", "DELs", intDel1, intDel2) & _
"</tr>"
frmMain.Output "Synonym Table:", LOGGING_TYPE_NORMAL_E
p_GetSynonymStats p_dictSynTable(FIRST_C), intSet1, intAdd1, intDel1, p_dictSynTable(SECOND_C), intSet2, intAdd2, intDel2
frmMain.Output vbTab & "1st CAB: Keyword ADDs: " & intAdd1 & "; Keyword DELs: " & intDel1 & "; sets: " & intSet1, LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "2nd CAB: Keyword ADDs: " & intAdd2 & "; Keyword DELs: " & intDel2 & "; sets: " & intSet2, LOGGING_TYPE_NORMAL_E
strHTM = strHTM & "<tr>" & _
p_GetHTMRow("Synonym Table", "Sets", intSet1, intSet2) & _
"</tr><tr>" & _
p_GetHTMRow(" ", "Keyword ADDs", intAdd1, intAdd2) & _
"</tr><tr>" & _
p_GetHTMRow(" ", "Keyword DELs", intDel1, intDel2) & _
"</tr>"
frmMain.Output "Nodes:", LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "1st CAB: ADDs: " & p_intNumNodesAdd(FIRST_C) & "; DELs: " & p_intNumNodesDel(FIRST_C), LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "2nd CAB: ADDs: " & p_intNumNodesAdd(SECOND_C) & "; DELs: " & p_intNumNodesDel(SECOND_C), LOGGING_TYPE_NORMAL_E
strHTM = strHTM & "<tr>" & _
p_GetHTMRow("Nodes", "ADDs", p_intNumNodesAdd(FIRST_C), p_intNumNodesAdd(SECOND_C)) & _
"</tr><tr>" & _
p_GetHTMRow(" ", "DELs", p_intNumNodesDel(FIRST_C), p_intNumNodesDel(SECOND_C)) & _
"</tr>"
frmMain.Output "Topics:", LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "1st CAB: ADDs: " & p_intNumTopicsAdd(FIRST_C) & "; DELs: " & p_intNumTopicsDel(FIRST_C), LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "2nd CAB: ADDs: " & p_intNumTopicsAdd(SECOND_C) & "; DELs: " & p_intNumTopicsDel(SECOND_C), LOGGING_TYPE_NORMAL_E
strHTM = strHTM & "<tr>" & _
p_GetHTMRow("Topics", "ADDs", p_intNumTopicsAdd(FIRST_C), p_intNumTopicsAdd(SECOND_C)) & _
"</tr><tr>" & _
p_GetHTMRow(" ", "DELs", p_intNumTopicsDel(FIRST_C), p_intNumTopicsDel(SECOND_C)) & _
"</tr>"
frmMain.Output "Keywords:", LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "1st CAB: ADDs: " & p_intNumKeywords(FIRST_C), LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & "2nd CAB: ADDs: " & p_intNumKeywords(SECOND_C), LOGGING_TYPE_NORMAL_E
strHTM = strHTM & "<tr>" & _
p_GetHTMRow("Keywords", "ADDs", p_intNumKeywords(FIRST_C), p_intNumKeywords(SECOND_C)) & _
"</tr>"
strHTM = strHTM & "</table>"
frmMain.Output "HelpImage:", LOGGING_TYPE_NORMAL_E
bln = p_Identical("HelpImage", p_dictHelpImage(FIRST_C), p_dictHelpImage(SECOND_C), str)
If (Not bln) Then
frmMain.Output vbTab & "!!!Comparison failed!!!", LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & p_InsertTabs(str), LOGGING_TYPE_NORMAL_E
Else
frmMain.Output vbTab & "Identical", LOGGING_TYPE_NORMAL_E
End If
strHTM = strHTM & "<br>" & p_GetHTMTable("HelpImage", bln, str)
frmMain.Output "Scopes:", LOGGING_TYPE_NORMAL_E
bln = p_Identical("Scope", p_dictScopes(FIRST_C), p_dictScopes(SECOND_C), str)
If (Not bln) Then
frmMain.Output vbTab & "!!!Comparison failed!!!", LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & p_InsertTabs(str), LOGGING_TYPE_NORMAL_E
Else
frmMain.Output vbTab & "Identical", LOGGING_TYPE_NORMAL_E
End If
strHTM = strHTM & "<br>" & p_GetHTMTable("Scopes", bln, str)
frmMain.Output "Index:", LOGGING_TYPE_NORMAL_E
bln = p_Identical("Index", p_dictIndex(FIRST_C), p_dictIndex(SECOND_C), str)
If (Not bln) Then
frmMain.Output vbTab & "!!!Comparison failed!!!", LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & p_InsertTabs(str), LOGGING_TYPE_NORMAL_E
Else
frmMain.Output vbTab & "Identical", LOGGING_TYPE_NORMAL_E
End If
strHTM = strHTM & "<br>" & p_GetHTMTable("Index", bln, str)
frmMain.Output "FTS:", LOGGING_TYPE_NORMAL_E
bln = p_Identical("FTS", p_dictFTS(FIRST_C), p_dictFTS(SECOND_C), str)
If (Not bln) Then
frmMain.Output vbTab & "!!!Comparison failed!!!", LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & p_InsertTabs(str), LOGGING_TYPE_NORMAL_E
Else
frmMain.Output vbTab & "Identical", LOGGING_TYPE_NORMAL_E
End If
strHTM = strHTM & "<br>" & p_GetHTMTable("FTS", bln, str)
frmMain.Output "Taxonomy:", LOGGING_TYPE_NORMAL_E
bln = p_IdenticalTaxonomy(str, intExtraHHKsInFirstCab)
If (Not bln) Then
frmMain.Output vbTab & "!!!Comparison failed!!!", LOGGING_TYPE_NORMAL_E
frmMain.Output vbTab & p_InsertTabs(str), LOGGING_TYPE_NORMAL_E
Else
frmMain.Output vbTab & "Identical", LOGGING_TYPE_NORMAL_E
If (intExtraHHKsInFirstCab > 0) Then
str = "The 1st CAB has " & intExtraHHKsInFirstCab & " extra HHK entries"
ElseIf (intExtraHHKsInFirstCab < 0) Then
str = "The 2nd CAB has " & intExtraHHKsInFirstCab * (-1) & " extra HHK entries"
Else
str = "The 2 CABs have the same number of HHK entries"
End If
frmMain.Output vbTab & str, LOGGING_TYPE_NORMAL_E
End If
strHTM = strHTM & "<br>" & p_GetHTMTable("Taxonomy", bln, str)
strHTM = strHTM & "</body></html>"
If (p_strHTMReport <> "") Then
FileWrite p_strHTMReport, strHTM, , True
End If
End Sub
Private Function p_GetHTMRow( _
ByVal i_str1 As String, _
ByVal i_str2 As String, _
ByVal i_str3 As String, _
ByVal i_str4 As String _
) As String
p_GetHTMRow = "" & _
"<td>" & i_str1 & "</td>" & _
"<td>" & i_str2 & "</td>" & _
"<td><p align='right'>" & i_str3 & "</td>" & _
"<td><p align='right'>" & i_str4 & "</td>"
End Function
Private Function p_GetHTMTable( _
ByVal i_strName As String, _
ByVal i_blnSuccess As Boolean, _
ByVal i_strNotes As String _
) As String
Dim str As String
If (i_blnSuccess) Then
str = "" & _
"<table border='1'>" & _
"<tr>" & _
"<td>" & i_strName & ": <font color='#00FF00'><b>Identical</b></font></td>" & _
"</tr>"
If (i_strNotes <> "") Then
str = str & _
"<tr>" & _
"<td><ul><li>" & Replace$(i_strNotes, vbCrLf, "</li><li>") & "</li></ul></td>" & _
"</tr>"
End If
str = str & _
"</table>"
Else
str = "" & _
"<table border='1'>" & _
"<tr>" & _
"<td>" & i_strName & ": <font color='#FF0000'><b>!!!Comparison failed!!!</b></font></td>" & _
"</tr>" & _
"<tr>" & _
"<td><ul><li>" & Replace$(i_strNotes, vbCrLf, "</li><li>") & "</li></ul></td>" & _
"</tr>" & _
"</table>"
End If
p_GetHTMTable = str
End Function
Private Sub p_CheckAction( _
ByVal i_strPrefix As String, _
ByVal i_strAction As String _
)
If ((i_strAction <> "ADD") And (i_strAction <> "DEL")) Then
Err.Raise E_FAIL, , i_strPrefix & ": Bad ACTION: " & i_strAction
End If
End Sub
Private Sub p_CheckOperation( _
ByVal i_strPrefix As String, _
ByVal i_strOperation As String _
)
If ((i_strOperation <> "AND") And (i_strOperation <> "OR") And (i_strOperation <> "NOT")) Then
Err.Raise E_FAIL, , i_strPrefix & ": Bad OPERATION: " & i_strOperation
End If
End Sub
Private Sub p_CheckContext( _
ByVal i_strPrefix As String, _
ByVal i_strContext As String _
)
If ((i_strContext <> "ANYWHERE") And (i_strContext <> "ENDOFWORD")) Then
Err.Raise E_FAIL, , i_strPrefix & ": Bad CONTEXT: " & i_strContext
End If
End Sub
Private Function p_GetAttribute( _
ByVal i_DOMNode As MSXML2.IXMLDOMNode, _
ByVal i_strAttributeName As String, _
Optional ByVal i_blnRequired As Boolean = True _
) As String
Dim DOMAttribute As MSXML2.IXMLDOMAttribute
Set DOMAttribute = i_DOMNode.Attributes.getNamedItem(i_strAttributeName)
If (DOMAttribute Is Nothing) Then
If (Not i_blnRequired) Then
Exit Function
Else
Err.Raise E_FAIL, , "Attribute " & i_strAttributeName & " is missing in: " & i_DOMNode.xml
End If
End If
p_GetAttribute = Replace$(DOMAttribute.Text, "\", "\\")
End Function
Private Function p_ExtractAttribute( _
ByVal i_DOMElement As MSXML2.IXMLDOMElement, _
ByVal i_strAttributeName As String _
) As String
Dim DOMAttribute As MSXML2.IXMLDOMAttribute
Set DOMAttribute = i_DOMElement.Attributes.getNamedItem(i_strAttributeName)
If (Not (DOMAttribute Is Nothing)) Then
p_ExtractAttribute = DOMAttribute.Text
i_DOMElement.Attributes.removeNamedItem (i_strAttributeName)
End If
End Function
Private Sub p_AppendStr( _
ByRef u_str As String, _
ByVal i_str As String _
)
If (u_str = "") Then
u_str = i_str
Else
u_str = u_str & vbCrLf & i_str
End If
End Sub
Private Function p_InsertTabs( _
ByVal i_str As String _
) As String
p_InsertTabs = Replace$(i_str, vbCrLf, vbCrLf & vbTab)
End Function
Private Sub p_GetActionStats( _
ByRef i_dict1 As Scripting.Dictionary, _
ByRef o_intAdd1 As Long, _
ByRef o_intDel1 As Long, _
ByRef i_dict2 As Scripting.Dictionary, _
ByRef o_intAdd2 As Long, _
ByRef o_intDel2 As Long _
)
Dim vntKey As Variant
Dim strAction As String
o_intAdd1 = 0
o_intDel1 = 0
o_intAdd2 = 0
o_intDel2 = 0
For Each vntKey In i_dict1.Keys
DoEvents
strAction = Mid$(i_dict1(vntKey), 1, 3)
If (strAction = "ADD") Then
o_intAdd1 = o_intAdd1 + 1
ElseIf (strAction = "DEL") Then
o_intDel1 = o_intDel1 + 1
Else
Err.Raise E_FAIL, , "Bad ACTION: " & strAction
End If
Next
For Each vntKey In i_dict2.Keys
DoEvents
strAction = Mid$(i_dict2(vntKey), 1, 3)
If (strAction = "ADD") Then
o_intAdd2 = o_intAdd2 + 1
ElseIf (strAction = "DEL") Then
o_intDel2 = o_intDel2 + 1
Else
Err.Raise E_FAIL, , "Bad ACTION: " & strAction
End If
Next
End Sub
Private Sub p_GetSynonymStats( _
ByRef i_dict1 As Scripting.Dictionary, _
ByRef o_intSet1 As Long, _
ByRef o_intAdd1 As Long, _
ByRef o_intDel1 As Long, _
ByRef i_dict2 As Scripting.Dictionary, _
ByRef o_intSet2 As Long, _
ByRef o_intAdd2 As Long, _
ByRef o_intDel2 As Long _
)
Dim vntKey1 As Variant
Dim vntKey2 As Variant
Dim strAction As String
o_intSet1 = i_dict1.Count
o_intAdd1 = 0
o_intDel1 = 0
o_intSet2 = i_dict2.Count
o_intAdd2 = 0
o_intDel2 = 0
For Each vntKey1 In i_dict1.Keys
DoEvents
For Each vntKey2 In i_dict1(vntKey1).Keys
strAction = Mid$(i_dict1(vntKey1)(vntKey2), 1, 3)
If (strAction = "ADD") Then
o_intAdd1 = o_intAdd1 + 1
ElseIf (strAction = "DEL") Then
o_intDel1 = o_intDel1 + 1
Else
Err.Raise E_FAIL, , "Bad ACTION: " & strAction
End If
Next
Next
For Each vntKey1 In i_dict2.Keys
DoEvents
For Each vntKey2 In i_dict2(vntKey1).Keys
strAction = Mid$(i_dict2(vntKey1)(vntKey2), 1, 3)
If (strAction = "ADD") Then
o_intAdd2 = o_intAdd2 + 1
ElseIf (strAction = "DEL") Then
o_intDel2 = o_intDel2 + 1
Else
Err.Raise E_FAIL, , "Bad ACTION: " & strAction
End If
Next
Next
End Sub
Private Function p_Identical( _
ByRef i_strName As String, _
ByRef u_dict1 As Scripting.Dictionary, _
ByRef u_dict2 As Scripting.Dictionary, _
ByRef o_strOutput As String _
) As Boolean
Dim vntKey As Variant
Dim strItem1 As String
Dim strItem2 As String
Dim blnFailed As Boolean
o_strOutput = ""
For Each vntKey In u_dict1.Keys
DoEvents
If (Not u_dict2.Exists(vntKey)) Then
p_AppendStr o_strOutput, i_strName & " " & vntKey & " exists only in the 1st CAB"
blnFailed = True
Else
strItem1 = u_dict1(vntKey)
strItem2 = u_dict2(vntKey)
u_dict1.Remove vntKey
u_dict2.Remove vntKey
If (strItem1 <> strItem2) Then
p_AppendStr o_strOutput, "Values of " & i_strName & " " & vntKey & " differ: " & _
strItem1 & " & " & strItem2
blnFailed = True
End If
End If
Next
For Each vntKey In u_dict2.Keys
DoEvents
If (Not u_dict1.Exists(vntKey)) Then
p_AppendStr o_strOutput, i_strName & " " & vntKey & " exists only in the 2nd CAB"
blnFailed = True
End If
Next
p_Identical = Not blnFailed
End Function
Private Function p_IdenticalTaxonomy( _
ByRef o_strOutput As String, _
ByRef o_intExtraHHKsInFirstCab As Long _
) As Boolean
Dim vntKey As Variant
Dim DOMNodeItem1 As MSXML2.IXMLDOMNode
Dim DOMNodeItem2 As MSXML2.IXMLDOMNode
Dim blnFailed As Boolean
Dim strCategory As String
Dim str As String
Dim intExtraHHKsInFirstCab As Long
o_strOutput = ""
For Each vntKey In p_dictTaxonomy(FIRST_C).Keys
DoEvents
Set DOMNodeItem1 = p_dictTaxonomy(FIRST_C)(vntKey)
If (Not p_dictTaxonomy(SECOND_C).Exists(vntKey)) Then
strCategory = p_GetAttribute(DOMNodeItem1, "CATEGORY", True)
If (UCase$(Mid$(strCategory, 1, 4)) = "HHKS") Then
intExtraHHKsInFirstCab = intExtraHHKsInFirstCab + 1
Else
p_AppendStr o_strOutput, "Taxonomy entry " & vntKey & " exists only in the 1st CAB"
blnFailed = True
End If
Else
Set DOMNodeItem2 = p_dictTaxonomy(SECOND_C)(vntKey)
p_dictTaxonomy(FIRST_C).Remove vntKey
p_dictTaxonomy(SECOND_C).Remove vntKey
If (Not p_IdenticalTaxonomyEntries(DOMNodeItem1, DOMNodeItem2, str)) Then
p_AppendStr o_strOutput, "Values of Taxonomy entry " & vntKey & " differ: " & str
blnFailed = True
End If
End If
Next
For Each vntKey In p_dictTaxonomy(SECOND_C).Keys
DoEvents
Set DOMNodeItem2 = p_dictTaxonomy(SECOND_C)(vntKey)
If (Not p_dictTaxonomy(FIRST_C).Exists(vntKey)) Then
strCategory = p_GetAttribute(DOMNodeItem2, "CATEGORY", True)
If (UCase$(Mid$(strCategory, 1, 4)) = "HHKS") Then
intExtraHHKsInFirstCab = intExtraHHKsInFirstCab - 1
Else
p_AppendStr o_strOutput, "Taxonomy entry " & vntKey & " exists only in the 2nd CAB"
blnFailed = True
End If
End If
Next
p_IdenticalTaxonomy = Not blnFailed
o_intExtraHHKsInFirstCab = intExtraHHKsInFirstCab
End Function
Private Function p_IdenticalTaxonomyEntries( _
ByVal u_DOMNode1 As MSXML2.IXMLDOMNode, _
ByVal u_DOMNode2 As MSXML2.IXMLDOMNode, _
ByRef o_strOutput As String _
) As Boolean
' Discard these localizable attributes
p_ExtractAttribute u_DOMNode1, "TITLE"
p_ExtractAttribute u_DOMNode2, "TITLE"
p_ExtractAttribute u_DOMNode1, "DESCRIPTION"
p_ExtractAttribute u_DOMNode2, "DESCRIPTION"
' Discard these attributes that form the key
p_ExtractAttribute u_DOMNode1, "CATEGORY"
p_ExtractAttribute u_DOMNode2, "CATEGORY"
p_ExtractAttribute u_DOMNode1, "ENTRY"
p_ExtractAttribute u_DOMNode2, "ENTRY"
p_ExtractAttribute u_DOMNode1, "URI"
p_ExtractAttribute u_DOMNode2, "URI"
If (Not p_IdenticalAttributes("ICONURI", u_DOMNode1, u_DOMNode2, o_strOutput)) Then
Exit Function
End If
If (Not p_IdenticalAttributes("TYPE", u_DOMNode1, u_DOMNode2, o_strOutput)) Then
Exit Function
End If
If (Not p_IdenticalAttributes("VISIBLE", u_DOMNode1, u_DOMNode2, o_strOutput)) Then
Exit Function
End If
If (Not p_IdenticalAttributes("ACTION", u_DOMNode1, u_DOMNode2, o_strOutput)) Then
Exit Function
End If
If (Not p_IdenticalAttributes("INSERTMODE", u_DOMNode1, u_DOMNode2, o_strOutput)) Then
Exit Function
End If
If (Not p_IdenticalAttributes("INSERTLOCATION", u_DOMNode1, u_DOMNode2, o_strOutput)) Then
Exit Function
End If
If (Not p_IdenticalAttributes("SUBSITE", u_DOMNode1, u_DOMNode2, o_strOutput)) Then
Exit Function
End If
If (Not p_IdenticalAttributes("NAVIGATIONMODEL", u_DOMNode1, u_DOMNode2, o_strOutput)) Then
Exit Function
End If
If (u_DOMNode1.xml <> u_DOMNode2.xml) Then
o_strOutput = "XML: " & u_DOMNode1.xml & " & " & u_DOMNode2.xml
Exit Function
End If
p_IdenticalTaxonomyEntries = True
End Function
Private Function p_IdenticalAttributes( _
ByVal i_strAttributeName As String, _
ByVal u_DOMNode1 As MSXML2.IXMLDOMNode, _
ByVal u_DOMNode2 As MSXML2.IXMLDOMNode, _
ByRef o_strOutput As String _
) As Boolean
Dim strAttribute1 As String
Dim strAttribute2 As String
strAttribute1 = p_ExtractAttribute(u_DOMNode1, i_strAttributeName)
strAttribute2 = p_ExtractAttribute(u_DOMNode2, i_strAttributeName)
If (strAttribute1 <> strAttribute2) Then
o_strOutput = "Attribute " & i_strAttributeName & ": " & strAttribute1 & " & " & strAttribute2
Exit Function
End If
p_IdenticalAttributes = True
End Function
|
Function IsPerfect(n)
IsPerfect = False
i = n - 1
sum = 0
Do While i > 0
If n Mod i = 0 Then
sum = sum + i
End If
i = i - 1
Loop
If sum = n Then
IsPerfect = True
End If
End Function
WScript.StdOut.Write IsPerfect(CInt(WScript.Arguments(0)))
WScript.StdOut.WriteLine
|
Set FSO = CreateObject("Scripting.FileSystemObject")
Function FileExists(strFile)
If FSO.FileExists(strFile) Then
FileExists = True
Else
FileExists = False
End If
End Function
Function FolderExists(strFolder)
If FSO.FolderExists(strFolder) Then
FolderExists = True
Else
Folderexists = False
End If
End Function
'''''Usage (apostrophes indicate comments-this section will not be run)'''''
'If FileExists("C:\test.txt") Then
' MsgBox "It Exists!"
'Else
' Msgbox "awww"
'End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Shorter version
If CreateObject("Scripting.FileSystemObject").FileExists("d:\test.txt") Then
Wscript.Echo "File Exists"
Else
Wscript.Echo "File Does Not Exist")
End If
|
Dim s
Dim sink
Sub MYSINK_OnCompleted(iHResult, objErrorObject, objAsyncContext)
WScript.Echo "Done"
End Sub
Sub MYSINK_OnObjectReady(objObject, objAsyncContext)
WScript.Echo (objObject.Name)
End Sub
Set s = GetObject("winmgmts:")
Set sink = WScript.CreateObject("WbemScripting.SWbemSink", "MYSINK_")
s.Security_.ImpersonationLevel = 3
s.InstancesOfAsync sink, "Win32_process"
WScript.Echo "Hanging"
|
<filename>Task/Sudoku/VBScript/sudoku.vb
Dim grid(9, 9)
Dim gridSolved(9, 9)
Public Sub Solve(i, j)
If i > 9 Then
'exit with gridSolved = Grid
For r = 1 To 9
For c = 1 To 9
gridSolved(r, c) = grid(r, c)
Next 'c
Next 'r
Exit Sub
End If
For n = 1 To 9
If isSafe(i, j, n) Then
nTmp = grid(i, j)
grid(i, j) = n
If j = 9 Then
Solve i + 1, 1
Else
Solve i, j + 1
End If
grid(i, j) = nTmp
End If
Next 'n
End Sub 'Solve
Public Function isSafe(i, j, n)
If grid(i, j) <> 0 Then
isSafe = (grid(i, j) = n)
Exit Function
End If
'grid(i,j) is an empty cell. Check if n is OK
'first check the row i
For c = 1 To 9
If grid(i, c) = n Then
isSafe = False
Exit Function
End If
Next 'c
'now check the column j
For r = 1 To 9
If grid(r, j) = n Then
isSafe = False
Exit Function
End If
Next 'r
'finally, check the 3x3 subsquare containing grid(i,j)
iMin = 1 + 3 * Int((i - 1) / 3)
jMin = 1 + 3 * Int((j - 1) / 3)
For r = iMin To iMin + 2
For c = jMin To jMin + 2
If grid(r, c) = n Then
isSafe = False
Exit Function
End If
Next 'c
Next 'r
'all tests were OK
isSafe = True
End Function 'isSafe
Public Sub Sudoku()
'main routine
Dim s(9)
s(1) = "001005070"
s(2) = "920600000"
s(3) = "008000600"
s(4) = "090020401"
s(5) = "000000000"
s(6) = "304080090"
s(7) = "007000300"
s(8) = "000007069"
s(9) = "010800700"
For i = 1 To 9
For j = 1 To 9
grid(i, j) = Int(Mid(s(i), j, 1))
Next 'j
Next 'j
'print problem
Wscript.echo "Problem:"
For i = 1 To 9
c=""
For j = 1 To 9
c=c & grid(i, j) & " "
Next 'j
Wscript.echo c
Next 'i
'solve it!
Solve 1, 1
'print solution
Wscript.echo "Solution:"
For i = 1 To 9
c=""
For j = 1 To 9
c=c & gridSolved(i, j) & " "
Next 'j
Wscript.echo c
Next 'i
End Sub 'Sudoku
Call sudoku
|
<filename>Task/Include-a-file/VBScript/include-a-file-1.vb
Include "D:\include\pad.vbs"
Wscript.Echo lpad(12,14,"-")
Sub Include (file)
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(file) then ExecuteGlobal fso.OpenTextFile(file).ReadAll
End Sub
|
Option Explicit
Sub test()
Dim Encryp As String
Encryp = Vigenere("Beware the Jabberwock, my son! The jaws that bite, the claws that catch!", "vigenerecipher", True)
Debug.Print "Encrypt:= """ & Encryp & """"
Debug.Print "Decrypt:= """ & Vigenere(Encryp, "vigenerecipher", False) & """"
End Sub
Private Function Vigenere(sWord As String, sKey As String, Enc As Boolean) As String
Dim bw() As Byte, bk() As Byte, i As Long, c As Long
Const sW As String = "ÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ"
Const sWo As String = "AAAAACEEEEIIIINOOOOOUUUUY"
Const A As Long = 65
Const N As Long = 26
c = Len(sKey)
i = Len(sWord)
sKey = Left(IIf(c < i, StrRept(sKey, (i / c) + 1), sKey), i)
sKey = StrConv(sKey, vbUpperCase) 'Upper case
sWord = StrConv(sWord, vbUpperCase)
sKey = StrReplace(sKey, sW, sWo) 'Replace accented characters
sWord = StrReplace(sWord, sW, sWo)
sKey = RemoveChars(sKey) 'Remove characters (numerics, spaces, comas, ...)
sWord = RemoveChars(sWord)
bk = CharToAscii(sKey) 'To work with Bytes instead of String
bw = CharToAscii(sWord)
For i = LBound(bw) To UBound(bw)
Vigenere = Vigenere & Chr((IIf(Enc, ((bw(i) - A) + (bk(i) - A)), ((bw(i) - A) - (bk(i) - A)) + N) Mod N) + A)
Next i
End Function
Private Function StrRept(s As String, N As Long) As String
Dim j As Long, c As String
For j = 1 To N
c = c & s
Next
StrRept = c
End Function
Private Function StrReplace(s As String, What As String, By As String) As String
Dim t() As String, u() As String, i As Long
t = SplitString(What)
u = SplitString(By)
StrReplace = s
For i = LBound(t) To UBound(t)
StrReplace = Replace(StrReplace, t(i), u(i))
Next i
End Function
Private Function SplitString(s As String) As String()
SplitString = Split(StrConv(s, vbUnicode), Chr(0))
End Function
Private Function RemoveChars(str As String) As String
Dim b() As Byte, i As Long
b = CharToAscii(str)
For i = LBound(b) To UBound(b)
If b(i) >= 65 And b(i) <= 90 Then RemoveChars = RemoveChars & Chr(b(i))
Next i
End Function
Private Function CharToAscii(s As String) As Byte()
CharToAscii = StrConv(s, vbFromUnicode)
End Function
|
<reponame>npocmaka/Windows-Server-2003
' MAKEBLDNUM.VBS
' This script generates a file to be included with in setver.h, setting the build number
' based on the current date. If the build is running in 2000, 12 will be added to the
' month (the January builds will be 13xx); if in 2001, 24 is added, and so forth.
' This section does the date calculations to come up with the number.
On Error Resume Next
BuildMonth = Month(Date) + ((Year(Date) - 1999) * 12)
BuildDay = Day(Date)
BuildNum = ""
if BuildMonth <= 9 then
BuildNum = BuildNum & "0"
end if
BuildNum = BuildNum & BuildMonth
if BuildDay <= 9 then
BuildNum = BuildNum & "0"
end if
BuildNum = BuildNum & BuildDay
' This section sets the third node of the build number to '00' if this script is run by
' the official builder, or '01' if this is a private build.
set WshShell = CreateObject("WScript.Shell")
domain = WshShell.ExpandEnvironmentStrings("%USERDOMAIN%")
if domain <> "REDMOND" then
BuildNum = 2328
end if
BuildType = "00"
' This section creates the include file.
set oFS = CreateObject("Scripting.FileSystemObject")
set file = oFS.CreateTextFile("setup\installer\currver.inc", True)
file.WriteLine "// This file is generated, DO NOT EDIT"
lineout = "#define VERSION ""5.0." & BuildNum & "." & BuildType & """"
file.WriteLine(lineout)
lineout = "#define VER_FILEVERSION_STR ""5.0." & BuildNum & "." & BuildType & " """
file.WriteLine(lineout)
lineout = "#define VER_FILEVERSION 5,0," & BuildNum & "," & BuildType
file.WriteLine(lineout)
lineout = "#define VER_PRODUCTVERSION_STR ""5.0." & BuildNum & "." & BuildType & " """
file.WriteLine(lineout)
lineout = "#define VER_PRODUCTVERSION 5,0," & BuildNum & "," & BuildType
file.WriteLine(lineout)
file.Close
if err.number = 0 then
wscript.echo "Updated version with build number " & BuildNum & "."
if BuildType = "01" then
wscript.echo "NOTE: This is a private build and will not be copied to the buildshare."
end if
else
wscript.echo "makebldnum.vbs completed with ERRORS!"
end if
if err.number = 0 then
wscript.quit BuildNum
else
wscript.quit -1
end if
|
<gh_stars>1000+
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Source-code of the "Back to The BASICs" CrackMe (Google CTF 2018 Quals).
# Author: <NAME> (<EMAIL>)
#
# This file needs to be compiled by CrackBASIC (see crackbasic.py file).
#
# Some fun facts:
# - C64 BASIC V2 tries to "repair" loaded BASIC programs when loading them by
# making sure the linked list doesn't have any 'weird' pointers. Such pointers
# are replaced by whatever is the result of:
# addr_of_prev_line + strlen(line) + 1
# Where "strlen" is basically a standard ASCIIZ (PETSCIIZ?) strlen.
# To bypass this we're slashing ("ending") the list just before stuff gets
# funny. The list has to be "re-attached" at runtime due to this.
# - There are 19 chunks using line numbers 2000-2999. I'm switching between them
# at runtime by changing the "next" pointers in the linked list. These chunks
# at rest, and when not used (before executions, after execution) are
# "encrypted" (well, XORed).
# - Most of the time when checking the password the linked list has a cycle/loop
# at line 2000, so if anyone pauses the execution and runs LIST command, they
# will get an infinite listing.
# - C64 BASIC uses 40-bit floats. The math in this crackme abuses that fact and
# basically does bitwise operations using "weird looking" 40-bit floats (well,
# in binary form these floats don't look weird at all). The math / values from
# this listing cannot be directly used in x86 floats (32-, 64-, 80-bits) as
# the fraction part has a different size and (due to the values I've chosen)
# will yield different results.
1 rem ======================
2 rem === back to basics ===
3 rem ======================
# Some colors.
# Useful link: https://www.c64-wiki.com/wiki/Color
10 ?chr$(155):?chr$(147)
20 poke &D020, 6:poke &D021, 6:
25 ?"loading..."
30 data &02,&01,&03,&0b,&20,&20,&51,&51,&51,&20,&20,&20,&20,&51,&20,&20,&20,&20,&51,&51,&51,&51,&20,&51,&51,&51,&51,&51,&20,&20,&51,&51,&51,&51,&20,&20,&57,&57,&57,&57
31 data &20,&20,&20,&20,&20,&20,&51,&20,&20,&51,&20,&20,&51,&20,&51,&20,&20,&51,&20,&20,&20,&20,&20,&20,&20,&51,&20,&20,&20,&51,&20,&20,&20,&20,&20,&57,&20,&20,&20,&20
32 data &14,&0f,&20,&20,&20,&20,&51,&51,&51,&20,&20,&51,&20,&20,&20,&51,&20,&20,&51,&51,&51,&20,&20,&20,&20,&51,&20,&20,&20,&51,&20,&20,&20,&20,&20,&20,&57,&57,&57,&20
33 data &20,&20,&20,&20,&20,&20,&51,&20,&20,&51,&20,&51,&51,&51,&51,&51,&20,&20,&20,&20,&20,&51,&20,&20,&20,&51,&20,&20,&20,&51,&20,&20,&20,&20,&20,&20,&20,&20,&20,&57
34 data &14,&08,&05,&20,&20,&20,&51,&51,&51,&20,&20,&51,&20,&20,&20,&51,&20,&51,&51,&51,&51,&20,&20,&51,&51,&51,&51,&51,&20,&20,&51,&51,&51,&51,&20,&57,&57,&57,&57,&20
40 for i = 0 to 39: poke 55296 + i, 1: next i
41 for i = 40 to 79: poke 55296 + i, 15: next i
42 for i = 80 to 119: poke 55296 + i, 12: next i
43 for i = 120 to 159: poke 55296 + i, 11: next i
44 for i = 160 to 199: poke 55296 + i, 0: next i
50 for i = 0 to 199
51 read c : poke 1024 + i, c
52 next i
60 ?:?:?:?:?
70 poke 19,1: ?"password please?" chr$(5): input ""; p$: poke 19,0
80 ?:?:?chr$(155) "processing... (this might take a while)":?"[ ]"
90 chkoff = 11 * 40 + 1
# Check length.
200 if len(p$) = 30 then goto 250
210 poke 1024 + chkoff + 0, 86:poke 55296 + chkoff + 0, 10
220 goto 31337
250 poke 1024 + chkoff + 0, 83:poke 55296 + chkoff + 0, 5
# Re-attach the slashed list around here.
2000 rem never gonna give you up
2001 rem
# Attach the first checker.
2010 poke {rawaddr 2000 0 W __default}, {rawaddr 2001 0 L check0} : poke {rawaddr 2000 1 W __default}, {rawaddr 2001 0 H check0} : goto 2001
31337 ?:?"verdict: nope":goto 31345
31345 goto 31345
# Slash the list after next line.
.slash_list
31346 rem
# Run "genprog.py > CHECKERS.BAS" to (re-)generate this part.
.include CHECKERS.BAS
.label checkend
2000 rem
2001 rem
# Attach the final check code.
# Do the final check.
31337 t = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + ta + tb + tc + td + te + tf + tg + th + tj
31338 if t = -19 then goto 31340
31339 ?:?"verdict: nope":goto 31345
31340 ?:?"verdict: correct"
31345 goto 31345
# Slash the list after next line.
.slash_list
31346 rem
|
<reponame>LaudateCorpus1/RosettaCodeData
Private Function root_mean_square(s() As Variant) As Double
For i = 1 To UBound(s)
s(i) = s(i) ^ 2
Next i
root_mean_square = Sqr(WorksheetFunction.sum(s) / UBound(s))
End Function
Public Sub pythagorean_means()
Dim s() As Variant
s = [{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]
Debug.Print root_mean_square(s)
End Sub
|
<filename>admin/wmi/wbem/scripting/test/whistler/locator/vb1.frm
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim WithEvents sink As SWbemSink
Attribute sink.VB_VarHelpID = -1
Private Sub Form_Load()
Dim l As New SWbemLocatorEx
Set sink = New SWbemSink
l.OpenAsync sink, "//./root/cimv2"
End Sub
Private Sub sink_OnCompleted(ByVal iHResult As WbemScripting.WbemErrorEnum, ByVal objWbemErrorObject As WbemScripting.ISWbemObject, ByVal objWbemAsyncContext As WbemScripting.ISWbemNamedValueSet)
Debug.Print "done"
End Sub
Private Sub sink_OnConnectionReady(ByVal objWbemServices As WbemScripting.ISWbemServicesEx, ByVal objecWbemAsyncContext As WbemScripting.ISWbemNamedValueSetEx)
Debug.Print "Hello"
End Sub
Private Sub sink_OnObjectReady(ByVal objWbemObject As WbemScripting.ISWbemObject, ByVal objWbemAsyncContext As WbemScripting.ISWbemNamedValueSet)
Debug.Print "Goodbye"
End Sub
|
<reponame>mullikine/RosettaCodeData<filename>Task/Conditional-structures/Visual-Basic/conditional-structures-5.vb
myName = 2
Debug.Print IIf(myName = 1, "John", "Jack")
'return : "Jack")
|
Sub PrintOutMode(stringtoprint)
'check if /Q quiet flag was set
if Not gRunMode and 1 then
WScript.StdOut.WriteLine stringtoprint
end if
End Sub
Sub PrintCustomError(strtoprint, whichstyleflag)
'if build flag is set /b then print build style
if gRunMode and 2 then
if whichstyleflag = 1 then
WScript.StdErr.WriteLine "BUILDMSG: XML Manifest error:" + sourceFile + ":" + strtoprint
else
WScript.StdErr.WriteLine "BUILDMSG: XML ManifestChk Error:" + strtoprint
end if
else
if whichstyleflag = 1 then
'print normal output style
PrintOutMode vbTab + "XML Manifest error:" + sourceFile + ":" + strtoprint
else
PrintOutMode "XML ManifestChk Error:" + strtoprint
end if
end if
End Sub
Sub PrintXMLError(byRef pXmlParseError)
PrintOutMode vbTab + "XML Error Info: "
PrintOutMode vbTab + " line: " + CStr(pXmlParseError.line)
PrintOutMode vbTab + " linepos: " + CStr(pXmlParseError.linepos)
PrintOutMode vbTab + " url: " + pXmlParseError.url
PrintOutMode vbTab + " errCode: " + Hex(pXmlParseError.errorCode)
PrintOutMode vbTab + " srcText: " + pXmlParseError.srcText
if Hex(pXmlParseError.errorCode) = "800C0006" then
PrintOutMode vbTab + " reason: " + "File not found."
else
PrintOutMode vbTab + " reason: " + pXmlParseError.reason
end if
End Sub
Sub PrintErrorDuringBuildProcess( byRef pXmlParseError )
Dim sFileUrl
if pXmlParseError.url = "" then
sFileUrl = sourceFile
else
sFileUrl = pXmlParseError.url
end if
WScript.StdErr.Write "NMAKE : error XML" + Hex(pXmlParseError.errorCode) + ": " + sFileUrl
if Hex(pXmlParseError.errorCode) = "800C0006" then
WScript.StdErr.WriteLine "(" + CStr(pXmlParseError.line) + ") : " + "File not found."
else
WScript.StdErr.WriteLine "(" + CStr(pXmlParseError.line) + ") : " + pXmlParseError.reason
end if
End Sub
Sub PrintSchemaError( byRef pErrObj )
if Hex(pErrObj.Number) = "800C0006" then
PrintOutMode vbTab + "Schema Error Info: " + Hex(pErrObj.Number) + vbCrLf + vbTab + "File:" + schemaname + " ( not found )"
else
PrintOutMode vbTab + "Schema Error Info: " + Hex(pErrObj.Number) + vbCrLf + vbTab + pErrobj.Description + vbCrLf + vbTab + "Error with:" + schemaname
end if
End Sub
Sub PrintSchemaErrorDuringBuildProcess( byRef pErrObj )
Dim sFileSource
sFileSource = schemaname
if Hex(pErrObj.Number) = "800C0006" then
WScript.StdErr.Write "NMAKE : error XMLSchema" + Hex(pErrObj.Number) + ": " + sFileSource
WScript.StdErr.WriteLine "( file not found )"
else
WScript.StdErr.Write "NMAKE : error XMLSchema" + Hex(pErrObj.Number) + ": " + sFileSource
WScript.StdErr.WriteLine "(" + pErrObj.Description + ")"
end if
End Sub
Sub PrintUsage()
WScript.StdOut.WriteLine vbTab + vbCrLf
WScript.StdOut.WriteLine "Validates Fusion Win32 Manifest files using a schema."
WScript.StdOut.WriteLine vbTab + vbCrLf
WScript.StdOut.WriteLine "Usage:"
WScript.StdOut.WriteLine vbTab + "cscript manifestchk.vbs /S:[drive:][path]schema_filename /M:[drive:][path]xml_manifest_filename /T:type [/Q]"
WScript.StdOut.WriteLine vbTab + "/S: Specify schema filename used to validate manifest"
WScript.StdOut.WriteLine vbTab + "/M: Specify manifest filename to validate"
WScript.StdOut.WriteLine vbTab + "/T: Specify manifest type value"
WScript.StdOut.WriteLine vbTab + "/Q Quiet mode - suppresses output to console"
WScript.StdOut.WriteLine vbTab + vbCrLf
WScript.StdOut.WriteLine vbTab + " Valid manifest type values are: "
WScript.StdOut.WriteLine vbTab + " AM for Assembly or Application Manifest"
WScript.StdOut.WriteLine vbTab + " PC for Publisher Configuration"
WScript.StdOut.WriteLine vbTab + " AC for Application Configuration"
WScript.StdOut.WriteLine vbTab + vbCrLf
WScript.StdOut.WriteLine vbTab + " The tool without /Q displays details of first encountered error"
WScript.StdOut.WriteLine vbTab + " (if errors are present in manifest), and displays Pass or Fail"
WScript.StdOut.WriteLine vbTab + " of the validation result. The application returns 0 for Pass,"
WScript.StdOut.WriteLine vbTab + " 1 for Fail, and returns 2 for bad command line argument."
End Sub
Function ChkProcessor(byRef rootdocobj, byRef strerr)
Dim retVal
Dim procArchChkList
retVal = True
set procArchChkList = rootdocobj.selectNodes("//assembly/*// @processorArchitecture[nodeType() = '2']")
rootlen = 0
rootlen = procArchChkList.length
if rootlen > 0 then
For counter = 0 To rootlen-1 Step 1
MyVar = UCase (CStr(procArchChkList.item(counter).text))
Select Case MyVar
Case "X86" retVal = True
Case "IA64" retVal = True
Case "*" retVal = True
Case Else strerr = "Attribute processorArchitecture contains invalid value: " + MyVar
retVal = False
End Select
Next
end if
ChkProcessor = retVal
End Function
Function Chklanguage(byRef rootdocobj, byRef strerr)
Dim retVal
Dim languageChkList
retVal = True
set languageChkList = rootdocobj.selectNodes("//assembly/*// @language[nodeType() = '2']")
rootlen = 0
rootlen = languageChkList.length
if rootlen > 0 then
For counter = 0 To rootlen-1 Step 1
MyVar = UCase (CStr(languageChkList.item(counter).text))
if MyVar = "*" then
retVal = True
else
'then check by length and format
LenMyVar = Len(MyVar)
IF LenMyVar > 5 then
strerr = "Attribute language contains invalid value: length too long:" + MyVar
retVal = False
elseif LenMyVar = 5 then
if RegExpTest("[A-Za-z][A-Za-z]-[A-Za-z][A-Za-z]", MyVar) then
retVal = True
else
strerr = "Attribute language contains invalid value: incorrect format(ie. en-us):" + MyVar
retVal = False
end if
elseif LenMyVar = 2 then
if RegExpTest("[A-Za-z][A-Za-z]", MyVar) then
retVal = True
else
strerr = "Attribute language contains invalid value:" + MyVar
retVal = False
end if
else
strerr = "Attribute language contains invalid value:" + MyVar
retVal = False
End If
end if
Next
end if
Chklanguage = retVal
End Function
Function ChkAllversion(byRef rootdocobj, byRef strerr)
Dim retVal
Dim versionChkList
Dim MyVar
Dim strVersionErr
Dim strValFound
retVal = True
strVersionErr = "Attribute version contains invalid value:"
Dim versionregexp
versionregexp = "^[0-9]{1,5}\.[0-9]{1,5}\.[0-9]{1,5}\.[0-9]{1,5}$"
'create a string array of the two element levels to search the version attribute
'the first element searches the manifest at the assembly/assemblyIdentity level
'and the second searches for the version attribute starting from the:
'assembly/dependency level and all its child elements
Dim arrayofelementstosearch
arrayofelementstosearch = Array("/assembly/assemblyIdentity/ @version[nodeType() = '2']", _
"/assembly/dependency/*// @version[nodeType() = '2']")
'Now loop through earch array string item and do the search and validation check
'note: the array is zero based
For i = 0 To 1 Step 1
'First check version at the /assembly/assemblyIdentity level
set versionChkList = rootdocobj.selectNodes(arrayofelementstosearch(i))
if versionChkList.length > 0 then
For counter = 0 To versionChkList.length-1 Step 1
MyVar = UCase (CStr(versionChkList.item(counter).text))
if RegExpTest(versionregexp, MyVar) then
retVal = True
else
strerr = strVersionErr + MyVar
retVal = False
Exit For
end if
Next
if retVal = False then
Exit For
end if
end if
Next
ChkAllversion = retVal
End Function
Function ChkAllGuidtypes(byRef rootdocobj, byRef strerr)
Dim retVal
Dim guidtypeChkList
Dim strVersionErr
Dim strValFound
Dim MyVar
Dim MyVarRegExpIndex
retVal = True
strVersionErr = " attribute contains invalid value:"
Dim strpreelementtosearch
Dim strpostelementtosearch
Dim strFullelementAttributetosearch
strpreelementtosearch = "/assembly/file/*// @"
strpostelementtosearch = "[nodeType() = '2']"
'needed 4 different regexpressions to test for 4 acceptable formats
'created an array of these
'the format validations in the guidregexpr array are indexed as follows:
' 0 = "{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}"
' 1 = "{AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA}"
' 2 = "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA"
' 3 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
Dim guidregexpr
guidregexpr = Array("^\{[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}\}", _
"^\{[A-Fa-f0-9]{32}\}", _
"^[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}", _
"^[A-Fa-f0-9]{32}")
Dim arrAttribsToChk
Dim numberofarrAttribsToChk
numberofarrAttribsToChk = 3 'because VBScipt doesnt have a way to dynamically get the size of an array you must keep track yourself
arrAttribsToChk = Array("clsid", "tlbid", "iid")
'Now loop through earch arrAttribsToChk string attribute and do the search and validation check
For i = 0 To numberofarrAttribsToChk-1 Step 1
'First check guid attribute at the /assembly/file level so build full string
strFullelementAttributetosearch = strpreelementtosearch + arrAttribsToChk(i) + strpostelementtosearch
set guidtypeChkList = rootdocobj.selectNodes(strFullelementAttributetosearch)
if guidtypeChkList.length > 0 then
For counter = 0 To guidtypeChkList.length-1 Step 1
'Extract the text value from the attribute
MyVar = UCase (CStr(guidtypeChkList.item(counter).text))
'Based on length, determine which regular expression string to use
if Len(MyVar) = 38 then 'must use guidregexpr(0)
MyVarRegExpIndex = 0
elseif Len(MyVar) = 34 then 'must use guidregexpr(1)
MyVarRegExpIndex = 1
elseif Len(MyVar) = 36 then 'must use guidregexpr(2)
MyVarRegExpIndex = 2
elseif Len(MyVar) = 32 then 'must use guidregexpr(3)
MyVarRegExpIndex = 3
else
retVal = False
strerr = arrAttribsToChk(i) + strVersionErr + MyVar
Exit For
end if
'Do actual regular expression validation search
if RegExpTest(guidregexpr(MyVarRegExpIndex), MyVar) then
retVal = True
else
retVal = False
strerr = arrAttribsToChk(i) + strVersionErr + MyVar
Exit For
end if
Next
end if
If retVal = False then
Exit For
End if
Next
ChkAllGuidtypes = retVal
End Function
Function ChkthreadingModel(byRef rootdocobj, byRef strerr)
Dim retVal
Dim threadingModelChkList
retVal = True
set threadingModelChkList = rootdocobj.selectNodes("//assembly/*// @threadingModel[nodeType() = '2']")
rootlen = 0
rootlen = threadingModelChkList.length
if rootlen > 0 then
For counter = 0 To rootlen-1 Step 1
MyVar = UCase (CStr(threadingModelChkList.item(counter).text))
Select Case MyVar
Case UCase ("Apartment") retVal = True
Case UCase ("Free") retVal = True
Case UCase ("Single") retVal = True
Case UCase ("Both") retVal = True
Case UCase ("Neutral") retVal = True
Case Else strerr = "Attribute threadingModel contains invalid value: " + MyVar
retVal = False
End Select
Next
end if
ChkthreadingModel = retVal
End Function
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
RetStr = "TTL Matches: " & CStr(Matches.Count) & vbCRLF
For Each Match in Matches ' Iterate Matches collection.
RetStr = RetStr & "Match found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
RetStr = RetStr & Match.Value & "'." & vbCRLF
Next
if Matches.Count = 1 then
RegExpTest = True
else
RegExpTest = False
end if
End Function
Function IsMSXML3Installed()
Dim retVal
Dim XmlDoc
Dim strFailed
retVal = True
strFailed = "MSXML version 3.0 not installed. Please install to run Manifestchk validator."
On Error resume next
set XmlDoc = CreateObject("Msxml2.DOMDocument.3.0")
if Err.Number <> 0 then
If Err.Number = 429 then
PrintCustomError strFailed, 2
else
strFailed = Hex(Err.Number) + ": " + Err.Description
PrintCustomError strFailed, 2
end if
retVal = False
end if
IsMSXML3Installed = retVal
End Function
Function IsValidCommandLine()
Dim objArgs
Dim retVal
Dim retValT
Dim nOnlyAllowFirstTimeReadFlag
'nOnlyAllowFirstTimeReadFlag values: Manifest = 0x01 Schema = 0x02 Quiet = 0x04 InBuildProcess = 0x08 ManifestType = 0x16
nOnlyAllowFirstTimeReadFlag = 0
retVal = True
Set objArgs = WScript.Arguments
if objArgs.Count < 2 then
retVal = False
IsValidCommandLine = retVal
Exit function
end if
For I = 0 to objArgs.Count - 1
if Len(objArgs(I)) >= 2 then
if Mid(objArgs(I),1,1)="/" then
Select Case UCase(Mid(objArgs(I),2,1))
Case "?"
retVal = False
IsValidCommandLine = retVal
Exit function
Case "Q"
if Len(objArgs(I)) = 2 then
if 4 and nOnlyAllowFirstTimeReadFlag then
retVal = False
IsValidCommandLine = retVal
Exit function
else
gRunMode = gRunMode + 1
nOnlyAllowFirstTimeReadFlag = nOnlyAllowFirstTimeReadFlag + 4
end if
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
Case "B"
if Len(objArgs(I)) = 2 then
if 8 and nOnlyAllowFirstTimeReadFlag then
retVal = False
IsValidCommandLine = retVal
Exit function
else
gRunMode = gRunMode + 2
nOnlyAllowFirstTimeReadFlag = nOnlyAllowFirstTimeReadFlag + 8
end if
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
Case "M"
if Mid(objArgs(I),3,1)=":" then
if Len(objArgs(I)) > 3 then
if 1 and nOnlyAllowFirstTimeReadFlag then
retVal = False
IsValidCommandLine = retVal
Exit function
else
sourceFile = Mid(objArgs(I),4)
nOnlyAllowFirstTimeReadFlag = nOnlyAllowFirstTimeReadFlag + 1
end if
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
Case "S"
if Mid(objArgs(I),3,1)=":" then
if Len(objArgs(I)) > 3 then
if 2 and nOnlyAllowFirstTimeReadFlag then
retVal = False
IsValidCommandLine = retVal
Exit function
else
schemaname = Mid(objArgs(I),4)
nOnlyAllowFirstTimeReadFlag = nOnlyAllowFirstTimeReadFlag + 2
end if
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
Case "T"
if Mid(objArgs(I),3,1)=":" then
if Len(objArgs(I)) > 3 then
if 16 and nOnlyAllowFirstTimeReadFlag then
retVal = False
IsValidCommandLine = retVal
Exit function
else
TVar = UCase (CStr(Mid(objArgs(I),4)))
Select Case TVar
Case "AM"
gRunMode = gRunMode + 8
retValT = True
Case "PC"
gRunMode = gRunMode + 16
retValT = True
Case "AC"
gRunMode = gRunMode + 32
retValT = True
Case Else strerr = "Argument 'type' contains invalid value: " + TVar
retValT = False
End Select
if retValT = False then
retVal = False
IsValidCommandLine = retVal
Exit function
End if
nOnlyAllowFirstTimeReadFlag = nOnlyAllowFirstTimeReadFlag + 16
end if
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
Case Else
retVal = False
IsValidCommandLine = retVal
Exit function
End Select
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
else
retVal = False
IsValidCommandLine = retVal
Exit function
end if
Next
'now check to make sure at minimum a manifest, schema, and manifest type was set
Dim bschema_manifest_set
bschema_manifest_set = False
if 1 and nOnlyAllowFirstTimeReadFlag then
if 2 and nOnlyAllowFirstTimeReadFlag then
if 16 and nOnlyAllowFirstTimeReadFlag then
bschema_manifest_set = True
else
retVal = False
end if
else
retVal = False
end if
else
retVal = False
end if
IsValidCommandLine = retVal
End Function
Function IsWellFormedXML(sourceFile)
Dim XmlDoc
Dim bRet
Dim pXmlParseError
Dim retVal
Dim strPassed
Dim strFailed
strPassed = "Well Formed XML Validation: PASSED"
strFailed = "Well Formed XML Validation: FAILED"
retVal = True
set XmlDoc = CreateObject("Msxml2.DOMDocument.3.0")
XmlDoc.async = False
XmlDoc.validateOnParse = False
XmlDoc.resolveExternals = False
bRet = XmlDoc.load(sourceFile)
if not bRet then
PrintOutMode strFailed
set pXmlParseError = XmlDoc.parseError
if gRunMode and 2 then
PrintErrorDuringBuildProcess(pXmlParseError)
else
PrintXMLError(pXmlParseError)
end if
retVal = False
else
PrintOutMode strPassed
end if
set XmlDoc = Nothing
IsWellFormedXML = retVal
End Function
Function IsValidAgainstSchema(sourceFile, schemaname)
Dim XmlDoc
Dim bRet
Dim pXmlParseError
Dim retVal
Dim SchemaCacheObj
Dim objXMLDOMSchemaCollection
Dim strPassed
Dim strFailed
strPassed = "XML Schema Validation: PASSED"
strFailed = "XML Schema Validation: FAILED"
retVal = True
set XmlDoc = CreateObject("Msxml2.DOMDocument.3.0")
XmlDoc.async = False
XmlDoc.validateOnParse = True
XmlDoc.resolveExternals = False
set SchemaCacheObj = CreateObject("Msxml2.XMLSchemaCache.3.0")
On Error Resume Next
SchemaCacheObj.add "urn:schemas-microsoft-com:asm.v1", schemaname
if Err.Number <> 0 then
PrintOutMode strFailed
if gRunMode and 2 then
PrintSchemaErrorDuringBuildProcess(Err)
else
PrintSchemaError(Err)
end if
set SchemaCacheObj = Nothing
set XmlDoc = Nothing
retVal = False
IsValidAgainstSchema = retVal
Exit Function
end if
XmlDoc.schemas = SchemaCacheObj
bRet = XmlDoc.load(sourceFile)
if not bRet then
PrintOutMode strFailed
set pXmlParseError = XmlDoc.parseError
if gRunMode and 2 then
PrintErrorDuringBuildProcess(pXmlParseError)
else
PrintXMLError(pXmlParseError)
end if
retVal = False
else
PrintOutMode strPassed
end if
set SchemaCacheObj = Nothing
set pXmlParseError = Nothing
set XmlDoc = Nothing
IsValidAgainstSchema = retVal
End Function
Function ChkAssemblyID(byRef rootdocobj, byRef strerr)
'this function validates a special check for Ref Context Assembly Identity: Type=win32-policy
Dim retVal
Dim AssemblyID
Dim strSelectNode
retVal = True
strSelectNode = "//assembly/dependency/dependentAssembly/assemblyIdentity/*// @version[nodeType() = '2']"
set AssemblyID = rootdocobj.selectNodes(strSelectNode)
rootlen = 0
rootlen = AssemblyID.length
if rootlen > 0 then
For counter = 0 To rootlen-1 Step 1
MyVar = CStr(AssemblyID.item(counter).text)
Select Case MyVar
Case "win32-policy" retVal = True
Case Else strerr = "Attribute type contains invalid value: " + MyVar
retVal = False
End Select
Next
else
retVal = False
end if
ChkAssemblyID = retVal
End Function
Function ChkAssemblyIDNoversion(byRef rootdocobj, chkType)
'this function validates that no Version attribute is present at the below strSelectNode string elements.
Dim retVal
Dim AssemblyIDNoversion
Dim strSelectNode
retVal = True
if chkType = "p" then
strSelectNode = "//assembly/dependency/dependentAssembly/*// @version[nodeType() = '2']"
else
strSelectNode = "//configuration/windows/assemblyBinding/dependentAssembly/*// @version[nodeType() = '2']"
end if
set AssemblyIDNoversion = rootdocobj.selectNodes(strSelectNode)
rootlen = 0
rootlen = AssemblyIDNoversion.length
if rootlen > 0 then
WScript.Echo "strSelectNode:" & strSelectNode
retVal = False
end if
ChkAssemblyIDNoversion = retVal
End Function
Function ChkCFGversion(byRef rootdocobj, byRef strerr, chkType)
Dim retVal
Dim versionChkList
Dim MyVar
Dim strVersionErr
Dim strValFound
retVal = True
strVersionErr = "Attribute version contains invalid value:"
Dim versionregexp
versionregexp = "^[0-9]{1,5}\.[0-9]{1,5}\.[0-9]{1,5}\.[0-9]{1,5}$"
'create a string array of the two element levels to search the version attribute
'the first element searches the manifest at the assembly/assemblyIdentity level
'and the second searches for the version attribute starting from the:
'assembly/dependency level and all its child elements
Dim arrayofelementstosearch
if chkType = "p" then
'check as publisher policy
arrayofelementstosearch = Array("/assembly/dependency/dependentAssembly/*// @oldVersion[nodeType() = '2']", _
"/assembly/dependency/dependentAssembly/*// @newVersion[nodeType() = '2']")
else
'check as application policy
arrayofelementstosearch = Array("/configuration/windows/assemblyBinding/dependentAssembly/*// @oldVersion[nodeType() = '2']", _
"/configuration/windows/assemblyBinding/dependentAssembly/*// @newVersion[nodeType() = '2']")
end if
'Now loop through earch array string item and do the search and validation check
'note: the array is zero based
For i = 0 To 1 Step 1
'First check version at the /assembly/assemblyIdentity level
set versionChkList = rootdocobj.selectNodes(arrayofelementstosearch(i))
if versionChkList.length > 0 then
For counter = 0 To versionChkList.length-1 Step 1
MyVar = UCase (CStr(versionChkList.item(counter).text))
if RegExpTest(versionregexp, MyVar) then
retVal = True
else
if i = 0 then
strVersionErr = "Attribute oldVersion contains invalid value:"
else
strVersionErr = "Attribute newVersion contains invalid value:"
end if
strerr = strVersionErr + MyVar
retVal = False
Exit For
end if
Next
if retVal = False then
Exit For
end if
end if
Next
ChkCFGversion = retVal
End Function
Function ChkCustomCfg(byRef rootdocobj, byRef strerr, chkType)
Dim retVal
retVal = True
if Not ChkAssemblyIDNoversion(rootdocobj, chkType) then
strerr = "assemblyidentity should not contain version attribute at this level"
retVal = False
end if
if Not ChkCFGversion(rootdocobj, strerr, chkType) then
retVal = False
end if
ChkCustomCfg = retVal
End Function
Function CustomChk(sourceFile)
Dim root
Dim XmlDoc
Dim retVal
retVal = True
Dim strPassed
Dim strFailed
Dim strErrOut
strPassed = "XML Last Validation: PASSED"
strFailed = "XML Last Validation: FAILED"
set XmlDoc = CreateObject("Msxml2.DOMDocument.3.0")
XmlDoc.validateOnParse = False
XmlDoc.resolveExternals = False
XmlDoc.async = False
XmlDoc.load(sourceFile)
set root = XmlDoc.documentElement
Do
'validate processorArchitecture attribute
if Not ChkProcessor(root, strErrOut) then
retVal = False
Exit Do
end if
'validate threadingModel attribute
if Not ChkthreadingModel(root, strErrOut) then
retVal = False
Exit Do
end if
'validate language attribute
if Not Chklanguage(root, strErrOut) then
retVal = False
Exit Do
end if
'validate version attribute
if Not ChkAllversion(root, strErrOut) then
retVal = False
Exit Do
end if
'validate AllGuidtype attribute
if Not ChkAllGuidtypes(root, strErrOut) then
retVal = False
Exit Do
end if
'validate custom check for Publisher Configuration
if 16 and gRunMode then
if Not ChkCustomCfg(root, strErrOut,"p") then
retVal = False
Exit Do
end if
end if
'validate custom check for Application Configuration
if 32 and gRunMode then
if Not ChkCustomCfg(root, strErrOut,"a") then
retVal = False
Exit Do
end if
end if
Exit Do
Loop
if retVal then
PrintOutMode strPassed
else
PrintOutMode strFailed
PrintCustomError strErrOut, 1
end if
set XmlDoc = Nothing
CustomChk = retVal
End Function
'global run code starts here
'global vars
Dim sourceFile
Dim schemaname
'mainRetVal is returned value that cscript.exe returns
'value 0 = validation passed with no errors, 1 = error in validation process, 2 = commandline arg error
Dim mainRetVal
'gRunMode - flag that determines whether to run in quiet mode, if in build process, and manifest Type to check
'value 1 - means run quiet, value 2 means in build process, value
Dim gRunMode
'Initialize variables
sourceFile = ""
schemaname = ""
gRunMode = 0
mainRetVal = 0
Do
'First Check just for valid commandline
If Not IsValidCommandLine() then
PrintUsage()
mainRetVal = 2
Exit Do
End If
'Check to make sure MSXML version 3 is installed on machine
If Not IsMSXML3Installed() then
mainRetVal = 1
Exit Do
End If
'Now First pass is to check just for Well Formed XML
If Not IsWellFormedXML(sourceFile) then
mainRetVal = 1
Exit Do
End If
'Second... pass checks against schema for correct Win32 Fusion structure
If Not IsValidAgainstSchema(sourceFile,schemaname) then
mainRetVal = 1
Exit Do
End If
'Last... add custom validation to check for various values that the schema could not handle
If Not CustomChk(sourceFile) then
mainRetVal = 1
Exit Do
End If
Exit Do
Loop
'WScript.Echo "gRunMode: " + CStr(gRunMode)
'WScript.Echo "mainRetVal: " + CStr(mainRetVal)
WScript.Quit mainRetVal
|
<reponame>kmalhan/fpga_microprocessor
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.btnInit = New System.Windows.Forms.Button()
Me.btnClose = New System.Windows.Forms.Button()
Me.btnWrite = New System.Windows.Forms.Button()
Me.txtOutput = New System.Windows.Forms.RichTextBox()
Me.lblOutput = New System.Windows.Forms.Label()
Me.cbxCOM = New System.Windows.Forms.ComboBox()
Me.cbxSpeed = New System.Windows.Forms.ComboBox()
Me.lblCOM = New System.Windows.Forms.Label()
Me.lblSpeed = New System.Windows.Forms.Label()
Me.SerialPort1 = New System.IO.Ports.SerialPort(Me.components)
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.txtNumIn = New System.Windows.Forms.TextBox()
Me.op0 = New System.Windows.Forms.RadioButton()
Me.op1 = New System.Windows.Forms.RadioButton()
Me.op2 = New System.Windows.Forms.RadioButton()
Me.op3 = New System.Windows.Forms.RadioButton()
Me.op4 = New System.Windows.Forms.RadioButton()
Me.op5 = New System.Windows.Forms.RadioButton()
Me.op6 = New System.Windows.Forms.RadioButton()
Me.op7 = New System.Windows.Forms.RadioButton()
Me.op8 = New System.Windows.Forms.RadioButton()
Me.op9 = New System.Windows.Forms.RadioButton()
Me.op10 = New System.Windows.Forms.RadioButton()
Me.op12 = New System.Windows.Forms.RadioButton()
Me.op13 = New System.Windows.Forms.RadioButton()
Me.op14 = New System.Windows.Forms.RadioButton()
Me.op15 = New System.Windows.Forms.RadioButton()
Me.op16 = New System.Windows.Forms.RadioButton()
Me.op17 = New System.Windows.Forms.RadioButton()
Me.op18 = New System.Windows.Forms.RadioButton()
Me.op19 = New System.Windows.Forms.RadioButton()
Me.op20 = New System.Windows.Forms.RadioButton()
Me.op21 = New System.Windows.Forms.RadioButton()
Me.op22 = New System.Windows.Forms.RadioButton()
Me.op23 = New System.Windows.Forms.RadioButton()
Me.op24 = New System.Windows.Forms.RadioButton()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.op11 = New System.Windows.Forms.RadioButton()
Me.op25 = New System.Windows.Forms.RadioButton()
Me.Label5 = New System.Windows.Forms.Label()
Me.Panel2 = New System.Windows.Forms.Panel()
Me.rx3 = New System.Windows.Forms.RadioButton()
Me.rx2 = New System.Windows.Forms.RadioButton()
Me.rx1 = New System.Windows.Forms.RadioButton()
Me.rx0 = New System.Windows.Forms.RadioButton()
Me.Panel3 = New System.Windows.Forms.Panel()
Me.ry3 = New System.Windows.Forms.RadioButton()
Me.ry2 = New System.Windows.Forms.RadioButton()
Me.ry1 = New System.Windows.Forms.RadioButton()
Me.ry0 = New System.Windows.Forms.RadioButton()
Me.Label6 = New System.Windows.Forms.Label()
Me.txtBE = New System.Windows.Forms.TextBox()
Me.Label7 = New System.Windows.Forms.Label()
Me.op26 = New System.Windows.Forms.RadioButton()
Me.Panel1.SuspendLayout()
Me.Panel2.SuspendLayout()
Me.Panel3.SuspendLayout()
Me.SuspendLayout()
'
'btnInit
'
Me.btnInit.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnInit.Location = New System.Drawing.Point(308, 41)
Me.btnInit.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.btnInit.Name = "btnInit"
Me.btnInit.Size = New System.Drawing.Size(92, 41)
Me.btnInit.TabIndex = 3
Me.btnInit.Text = "Initialize"
Me.btnInit.UseVisualStyleBackColor = True
'
'btnClose
'
Me.btnClose.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnClose.Location = New System.Drawing.Point(653, 41)
Me.btnClose.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.btnClose.Name = "btnClose"
Me.btnClose.Size = New System.Drawing.Size(92, 43)
Me.btnClose.TabIndex = 40
Me.btnClose.Text = "Close"
Me.btnClose.UseVisualStyleBackColor = True
'
'btnWrite
'
Me.btnWrite.Font = New System.Drawing.Font("Bookman Old Style", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnWrite.Location = New System.Drawing.Point(270, 522)
Me.btnWrite.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.btnWrite.Name = "btnWrite"
Me.btnWrite.Size = New System.Drawing.Size(122, 57)
Me.btnWrite.TabIndex = 39
Me.btnWrite.Text = "Write"
Me.btnWrite.UseVisualStyleBackColor = True
'
'txtOutput
'
Me.txtOutput.BackColor = System.Drawing.Color.White
Me.txtOutput.Font = New System.Drawing.Font("Bookman Old Style", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtOutput.Location = New System.Drawing.Point(457, 394)
Me.txtOutput.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.txtOutput.Name = "txtOutput"
Me.txtOutput.ReadOnly = True
Me.txtOutput.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical
Me.txtOutput.Size = New System.Drawing.Size(302, 170)
Me.txtOutput.TabIndex = 4
Me.txtOutput.Text = ""
'
'lblOutput
'
Me.lblOutput.AutoSize = True
Me.lblOutput.Font = New System.Drawing.Font("Bookman Old Style", 15.75!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblOutput.Location = New System.Drawing.Point(559, 361)
Me.lblOutput.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
Me.lblOutput.Name = "lblOutput"
Me.lblOutput.Size = New System.Drawing.Size(80, 24)
Me.lblOutput.TabIndex = 6
Me.lblOutput.Text = "Result"
'
'cbxCOM
'
Me.cbxCOM.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cbxCOM.Font = New System.Drawing.Font("MS UI Gothic", 12.0!)
Me.cbxCOM.FormattingEnabled = True
Me.cbxCOM.Location = New System.Drawing.Point(12, 56)
Me.cbxCOM.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.cbxCOM.Name = "cbxCOM"
Me.cbxCOM.Size = New System.Drawing.Size(120, 24)
Me.cbxCOM.TabIndex = 1
'
'cbxSpeed
'
Me.cbxSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cbxSpeed.Font = New System.Drawing.Font("MS UI Gothic", 12.0!)
Me.cbxSpeed.FormattingEnabled = True
Me.cbxSpeed.Items.AddRange(New Object() {"9600"})
Me.cbxSpeed.Location = New System.Drawing.Point(157, 56)
Me.cbxSpeed.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.cbxSpeed.Name = "cbxSpeed"
Me.cbxSpeed.Size = New System.Drawing.Size(120, 24)
Me.cbxSpeed.TabIndex = 2
'
'lblCOM
'
Me.lblCOM.AutoSize = True
Me.lblCOM.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblCOM.Location = New System.Drawing.Point(12, 37)
Me.lblCOM.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
Me.lblCOM.Name = "lblCOM"
Me.lblCOM.Size = New System.Drawing.Size(80, 18)
Me.lblCOM.TabIndex = 9
Me.lblCOM.Text = "COM Port"
'
'lblSpeed
'
Me.lblSpeed.AutoSize = True
Me.lblSpeed.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblSpeed.Location = New System.Drawing.Point(158, 37)
Me.lblSpeed.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
Me.lblSpeed.Name = "lblSpeed"
Me.lblSpeed.Size = New System.Drawing.Size(56, 18)
Me.lblSpeed.TabIndex = 10
Me.lblSpeed.Text = "Speed"
'
'SerialPort1
'
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(12, 13)
Me.Label1.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(239, 18)
Me.Label1.TabIndex = 11
Me.Label1.Text = "1. Select COM port and Speed"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(13, 349)
Me.Label2.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(147, 18)
Me.Label2.TabIndex = 12
Me.Label2.Text = "3. Select Registers"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(13, 101)
Me.Label3.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(154, 18)
Me.Label3.TabIndex = 17
Me.Label3.Text = "2. Select Operation"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(13, 504)
Me.Label4.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(170, 18)
Me.Label4.TabIndex = 50
Me.Label4.Text = "4. Type 7 bit number"
'
'txtNumIn
'
Me.txtNumIn.Font = New System.Drawing.Font("Bookman Old Style", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtNumIn.Location = New System.Drawing.Point(77, 536)
Me.txtNumIn.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.txtNumIn.MaxLength = 7
Me.txtNumIn.Name = "txtNumIn"
Me.txtNumIn.Size = New System.Drawing.Size(124, 32)
Me.txtNumIn.TabIndex = 38
'
'op0
'
Me.op0.Appearance = System.Windows.Forms.Appearance.Button
Me.op0.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op0.Location = New System.Drawing.Point(7, 9)
Me.op0.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op0.Name = "op0"
Me.op0.Size = New System.Drawing.Size(90, 46)
Me.op0.TabIndex = 4
Me.op0.TabStop = True
Me.op0.Text = "Load, IN"
Me.op0.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op0.UseVisualStyleBackColor = True
'
'op1
'
Me.op1.Appearance = System.Windows.Forms.Appearance.Button
Me.op1.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op1.Location = New System.Drawing.Point(103, 9)
Me.op1.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op1.Name = "op1"
Me.op1.Size = New System.Drawing.Size(90, 46)
Me.op1.TabIndex = 5
Me.op1.TabStop = True
Me.op1.Text = "Load Rx, IN"
Me.op1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op1.UseVisualStyleBackColor = True
'
'op2
'
Me.op2.Appearance = System.Windows.Forms.Appearance.Button
Me.op2.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op2.Location = New System.Drawing.Point(199, 9)
Me.op2.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op2.Name = "op2"
Me.op2.Size = New System.Drawing.Size(90, 46)
Me.op2.TabIndex = 6
Me.op2.TabStop = True
Me.op2.Text = "Load OUT"
Me.op2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op2.UseVisualStyleBackColor = True
'
'op3
'
Me.op3.Appearance = System.Windows.Forms.Appearance.Button
Me.op3.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op3.Location = New System.Drawing.Point(295, 10)
Me.op3.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op3.Name = "op3"
Me.op3.Size = New System.Drawing.Size(90, 46)
Me.op3.TabIndex = 7
Me.op3.TabStop = True
Me.op3.Text = "Copy"
Me.op3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op3.UseVisualStyleBackColor = True
'
'op4
'
Me.op4.Appearance = System.Windows.Forms.Appearance.Button
Me.op4.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op4.Location = New System.Drawing.Point(391, 10)
Me.op4.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op4.Name = "op4"
Me.op4.Size = New System.Drawing.Size(90, 46)
Me.op4.TabIndex = 8
Me.op4.TabStop = True
Me.op4.Text = "Add"
Me.op4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op4.UseVisualStyleBackColor = True
'
'op5
'
Me.op5.Appearance = System.Windows.Forms.Appearance.Button
Me.op5.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op5.Location = New System.Drawing.Point(486, 10)
Me.op5.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op5.Name = "op5"
Me.op5.Size = New System.Drawing.Size(90, 46)
Me.op5.TabIndex = 9
Me.op5.TabStop = True
Me.op5.Text = "Increment"
Me.op5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op5.UseVisualStyleBackColor = True
'
'op6
'
Me.op6.Appearance = System.Windows.Forms.Appearance.Button
Me.op6.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op6.Location = New System.Drawing.Point(582, 10)
Me.op6.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op6.Name = "op6"
Me.op6.Size = New System.Drawing.Size(90, 46)
Me.op6.TabIndex = 10
Me.op6.TabStop = True
Me.op6.Text = "Subtract"
Me.op6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op6.UseVisualStyleBackColor = True
'
'op7
'
Me.op7.Appearance = System.Windows.Forms.Appearance.Button
Me.op7.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op7.Location = New System.Drawing.Point(7, 62)
Me.op7.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op7.Name = "op7"
Me.op7.Size = New System.Drawing.Size(90, 46)
Me.op7.TabIndex = 11
Me.op7.TabStop = True
Me.op7.Text = "Decrement"
Me.op7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op7.UseVisualStyleBackColor = True
'
'op8
'
Me.op8.Appearance = System.Windows.Forms.Appearance.Button
Me.op8.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op8.Location = New System.Drawing.Point(103, 62)
Me.op8.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op8.Name = "op8"
Me.op8.Size = New System.Drawing.Size(90, 46)
Me.op8.TabIndex = 12
Me.op8.TabStop = True
Me.op8.Text = "| Subtract |"
Me.op8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op8.UseVisualStyleBackColor = True
'
'op9
'
Me.op9.Appearance = System.Windows.Forms.Appearance.Button
Me.op9.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op9.Location = New System.Drawing.Point(199, 62)
Me.op9.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op9.Name = "op9"
Me.op9.Size = New System.Drawing.Size(90, 46)
Me.op9.TabIndex = 13
Me.op9.TabStop = True
Me.op9.Text = "Multiply"
Me.op9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op9.UseVisualStyleBackColor = True
'
'op10
'
Me.op10.Appearance = System.Windows.Forms.Appearance.Button
Me.op10.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op10.Location = New System.Drawing.Point(294, 62)
Me.op10.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op10.Name = "op10"
Me.op10.Size = New System.Drawing.Size(90, 46)
Me.op10.TabIndex = 14
Me.op10.TabStop = True
Me.op10.Text = "Divide"
Me.op10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op10.UseVisualStyleBackColor = True
'
'op12
'
Me.op12.Appearance = System.Windows.Forms.Appearance.Button
Me.op12.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op12.Location = New System.Drawing.Point(487, 62)
Me.op12.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op12.Name = "op12"
Me.op12.Size = New System.Drawing.Size(90, 46)
Me.op12.TabIndex = 16
Me.op12.TabStop = True
Me.op12.Text = "Right Shift"
Me.op12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op12.UseVisualStyleBackColor = True
'
'op13
'
Me.op13.Appearance = System.Windows.Forms.Appearance.Button
Me.op13.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op13.Location = New System.Drawing.Point(582, 62)
Me.op13.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op13.Name = "op13"
Me.op13.Size = New System.Drawing.Size(90, 46)
Me.op13.TabIndex = 17
Me.op13.TabStop = True
Me.op13.Text = "Left Shift"
Me.op13.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op13.UseVisualStyleBackColor = True
'
'op14
'
Me.op14.Appearance = System.Windows.Forms.Appearance.Button
Me.op14.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op14.Location = New System.Drawing.Point(7, 115)
Me.op14.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op14.Name = "op14"
Me.op14.Size = New System.Drawing.Size(90, 46)
Me.op14.TabIndex = 18
Me.op14.TabStop = True
Me.op14.Text = "AND"
Me.op14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op14.UseVisualStyleBackColor = True
'
'op15
'
Me.op15.Appearance = System.Windows.Forms.Appearance.Button
Me.op15.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op15.Location = New System.Drawing.Point(103, 115)
Me.op15.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op15.Name = "op15"
Me.op15.Size = New System.Drawing.Size(90, 46)
Me.op15.TabIndex = 19
Me.op15.TabStop = True
Me.op15.Text = "OR"
Me.op15.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op15.UseVisualStyleBackColor = True
'
'op16
'
Me.op16.Appearance = System.Windows.Forms.Appearance.Button
Me.op16.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op16.Location = New System.Drawing.Point(199, 115)
Me.op16.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op16.Name = "op16"
Me.op16.Size = New System.Drawing.Size(90, 46)
Me.op16.TabIndex = 20
Me.op16.TabStop = True
Me.op16.Text = "NAND"
Me.op16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op16.UseVisualStyleBackColor = True
'
'op17
'
Me.op17.Appearance = System.Windows.Forms.Appearance.Button
Me.op17.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op17.Location = New System.Drawing.Point(295, 115)
Me.op17.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op17.Name = "op17"
Me.op17.Size = New System.Drawing.Size(90, 46)
Me.op17.TabIndex = 21
Me.op17.TabStop = True
Me.op17.Text = "NOR"
Me.op17.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op17.UseVisualStyleBackColor = True
'
'op18
'
Me.op18.Appearance = System.Windows.Forms.Appearance.Button
Me.op18.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op18.Location = New System.Drawing.Point(390, 114)
Me.op18.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op18.Name = "op18"
Me.op18.Size = New System.Drawing.Size(90, 46)
Me.op18.TabIndex = 22
Me.op18.TabStop = True
Me.op18.Text = "XOR"
Me.op18.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op18.UseVisualStyleBackColor = True
'
'op19
'
Me.op19.Appearance = System.Windows.Forms.Appearance.Button
Me.op19.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op19.Location = New System.Drawing.Point(486, 115)
Me.op19.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op19.Name = "op19"
Me.op19.Size = New System.Drawing.Size(90, 46)
Me.op19.TabIndex = 23
Me.op19.TabStop = True
Me.op19.Text = "XNOR"
Me.op19.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op19.UseVisualStyleBackColor = True
'
'op20
'
Me.op20.Appearance = System.Windows.Forms.Appearance.Button
Me.op20.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op20.Location = New System.Drawing.Point(7, 167)
Me.op20.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op20.Name = "op20"
Me.op20.Size = New System.Drawing.Size(90, 46)
Me.op20.TabIndex = 24
Me.op20.TabStop = True
Me.op20.Text = "Greater than"
Me.op20.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op20.UseVisualStyleBackColor = True
'
'op21
'
Me.op21.Appearance = System.Windows.Forms.Appearance.Button
Me.op21.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op21.Location = New System.Drawing.Point(103, 167)
Me.op21.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op21.Name = "op21"
Me.op21.Size = New System.Drawing.Size(90, 46)
Me.op21.TabIndex = 25
Me.op21.TabStop = True
Me.op21.Text = "Less than"
Me.op21.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op21.UseVisualStyleBackColor = True
'
'op22
'
Me.op22.Appearance = System.Windows.Forms.Appearance.Button
Me.op22.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op22.Location = New System.Drawing.Point(199, 167)
Me.op22.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op22.Name = "op22"
Me.op22.Size = New System.Drawing.Size(90, 46)
Me.op22.TabIndex = 26
Me.op22.TabStop = True
Me.op22.Text = "Equal to"
Me.op22.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op22.UseVisualStyleBackColor = True
'
'op23
'
Me.op23.Appearance = System.Windows.Forms.Appearance.Button
Me.op23.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op23.Location = New System.Drawing.Point(294, 167)
Me.op23.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op23.Name = "op23"
Me.op23.Size = New System.Drawing.Size(90, 46)
Me.op23.TabIndex = 27
Me.op23.TabStop = True
Me.op23.Text = "Bin => Gray"
Me.op23.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op23.UseVisualStyleBackColor = True
'
'op24
'
Me.op24.Appearance = System.Windows.Forms.Appearance.Button
Me.op24.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op24.Location = New System.Drawing.Point(391, 167)
Me.op24.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op24.Name = "op24"
Me.op24.Size = New System.Drawing.Size(90, 46)
Me.op24.TabIndex = 28
Me.op24.TabStop = True
Me.op24.Text = "Gray => Bin"
Me.op24.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op24.UseVisualStyleBackColor = True
'
'Panel1
'
Me.Panel1.Controls.Add(Me.op26)
Me.Panel1.Controls.Add(Me.op11)
Me.Panel1.Controls.Add(Me.op20)
Me.Panel1.Controls.Add(Me.op10)
Me.Panel1.Controls.Add(Me.op12)
Me.Panel1.Controls.Add(Me.op25)
Me.Panel1.Controls.Add(Me.op13)
Me.Panel1.Controls.Add(Me.op24)
Me.Panel1.Controls.Add(Me.op0)
Me.Panel1.Controls.Add(Me.op23)
Me.Panel1.Controls.Add(Me.op1)
Me.Panel1.Controls.Add(Me.op22)
Me.Panel1.Controls.Add(Me.op2)
Me.Panel1.Controls.Add(Me.op21)
Me.Panel1.Controls.Add(Me.op3)
Me.Panel1.Controls.Add(Me.op19)
Me.Panel1.Controls.Add(Me.op4)
Me.Panel1.Controls.Add(Me.op18)
Me.Panel1.Controls.Add(Me.op5)
Me.Panel1.Controls.Add(Me.op17)
Me.Panel1.Controls.Add(Me.op6)
Me.Panel1.Controls.Add(Me.op16)
Me.Panel1.Controls.Add(Me.op7)
Me.Panel1.Controls.Add(Me.op15)
Me.Panel1.Controls.Add(Me.op8)
Me.Panel1.Controls.Add(Me.op14)
Me.Panel1.Controls.Add(Me.op9)
Me.Panel1.Location = New System.Drawing.Point(16, 120)
Me.Panel1.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(702, 236)
Me.Panel1.TabIndex = 78
'
'op11
'
Me.op11.Appearance = System.Windows.Forms.Appearance.Button
Me.op11.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op11.Location = New System.Drawing.Point(391, 62)
Me.op11.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op11.Name = "op11"
Me.op11.Size = New System.Drawing.Size(90, 46)
Me.op11.TabIndex = 15
Me.op11.TabStop = True
Me.op11.Text = "Module"
Me.op11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op11.UseVisualStyleBackColor = True
'
'op25
'
Me.op25.Appearance = System.Windows.Forms.Appearance.Button
Me.op25.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op25.Location = New System.Drawing.Point(486, 167)
Me.op25.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op25.Name = "op25"
Me.op25.Size = New System.Drawing.Size(90, 46)
Me.op25.TabIndex = 29
Me.op25.TabStop = True
Me.op25.Tag = "O"
Me.op25.Text = "Delete"
Me.op25.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op25.UseVisualStyleBackColor = True
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label5.Location = New System.Drawing.Point(89, -3)
Me.Label5.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(28, 18)
Me.Label5.TabIndex = 79
Me.Label5.Text = "Rx"
'
'Panel2
'
Me.Panel2.Controls.Add(Me.Label6)
Me.Panel2.Controls.Add(Me.rx3)
Me.Panel2.Controls.Add(Me.rx2)
Me.Panel2.Controls.Add(Me.rx1)
Me.Panel2.Controls.Add(Me.rx0)
Me.Panel2.Location = New System.Drawing.Point(8, 377)
Me.Panel2.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(218, 130)
Me.Panel2.TabIndex = 79
'
'rx3
'
Me.rx3.Appearance = System.Windows.Forms.Appearance.Button
Me.rx3.Font = New System.Drawing.Font("Bookman Old Style", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.rx3.Location = New System.Drawing.Point(110, 68)
Me.rx3.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.rx3.Name = "rx3"
Me.rx3.Size = New System.Drawing.Size(90, 46)
Me.rx3.TabIndex = 33
Me.rx3.TabStop = True
Me.rx3.Text = "R3"
Me.rx3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.rx3.UseVisualStyleBackColor = True
'
'rx2
'
Me.rx2.Appearance = System.Windows.Forms.Appearance.Button
Me.rx2.Font = New System.Drawing.Font("Bookman Old Style", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.rx2.Location = New System.Drawing.Point(7, 68)
Me.rx2.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.rx2.Name = "rx2"
Me.rx2.Size = New System.Drawing.Size(90, 46)
Me.rx2.TabIndex = 32
Me.rx2.TabStop = True
Me.rx2.Text = "R2"
Me.rx2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.rx2.UseVisualStyleBackColor = True
'
'rx1
'
Me.rx1.Appearance = System.Windows.Forms.Appearance.Button
Me.rx1.Font = New System.Drawing.Font("Bookman Old Style", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.rx1.Location = New System.Drawing.Point(110, 16)
Me.rx1.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.rx1.Name = "rx1"
Me.rx1.Size = New System.Drawing.Size(90, 46)
Me.rx1.TabIndex = 31
Me.rx1.TabStop = True
Me.rx1.Text = "R1"
Me.rx1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.rx1.UseVisualStyleBackColor = True
'
'rx0
'
Me.rx0.Appearance = System.Windows.Forms.Appearance.Button
Me.rx0.Font = New System.Drawing.Font("Bookman Old Style", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.rx0.Location = New System.Drawing.Point(7, 16)
Me.rx0.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.rx0.Name = "rx0"
Me.rx0.Size = New System.Drawing.Size(90, 46)
Me.rx0.TabIndex = 30
Me.rx0.TabStop = True
Me.rx0.Text = "R0"
Me.rx0.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.rx0.UseVisualStyleBackColor = True
'
'Panel3
'
Me.Panel3.Controls.Add(Me.ry3)
Me.Panel3.Controls.Add(Me.ry2)
Me.Panel3.Controls.Add(Me.Label5)
Me.Panel3.Controls.Add(Me.ry1)
Me.Panel3.Controls.Add(Me.ry0)
Me.Panel3.Location = New System.Drawing.Point(233, 378)
Me.Panel3.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.Panel3.Name = "Panel3"
Me.Panel3.Size = New System.Drawing.Size(218, 130)
Me.Panel3.TabIndex = 85
'
'ry3
'
Me.ry3.Appearance = System.Windows.Forms.Appearance.Button
Me.ry3.Font = New System.Drawing.Font("Bookman Old Style", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ry3.Location = New System.Drawing.Point(110, 68)
Me.ry3.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.ry3.Name = "ry3"
Me.ry3.Size = New System.Drawing.Size(90, 46)
Me.ry3.TabIndex = 37
Me.ry3.TabStop = True
Me.ry3.Text = "R3"
Me.ry3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.ry3.UseVisualStyleBackColor = True
'
'ry2
'
Me.ry2.Appearance = System.Windows.Forms.Appearance.Button
Me.ry2.Font = New System.Drawing.Font("Bookman Old Style", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ry2.Location = New System.Drawing.Point(7, 68)
Me.ry2.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.ry2.Name = "ry2"
Me.ry2.Size = New System.Drawing.Size(90, 46)
Me.ry2.TabIndex = 36
Me.ry2.TabStop = True
Me.ry2.Text = "R2"
Me.ry2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.ry2.UseVisualStyleBackColor = True
'
'ry1
'
Me.ry1.Appearance = System.Windows.Forms.Appearance.Button
Me.ry1.Font = New System.Drawing.Font("Bookman Old Style", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ry1.Location = New System.Drawing.Point(110, 16)
Me.ry1.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.ry1.Name = "ry1"
Me.ry1.Size = New System.Drawing.Size(90, 46)
Me.ry1.TabIndex = 35
Me.ry1.TabStop = True
Me.ry1.Text = "R1"
Me.ry1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.ry1.UseVisualStyleBackColor = True
'
'ry0
'
Me.ry0.Appearance = System.Windows.Forms.Appearance.Button
Me.ry0.Font = New System.Drawing.Font("Bookman Old Style", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ry0.Location = New System.Drawing.Point(7, 16)
Me.ry0.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.ry0.Name = "ry0"
Me.ry0.Size = New System.Drawing.Size(90, 46)
Me.ry0.TabIndex = 34
Me.ry0.TabStop = True
Me.ry0.Text = "R0"
Me.ry0.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.ry0.UseVisualStyleBackColor = True
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.Location = New System.Drawing.Point(90, -2)
Me.Label6.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(29, 18)
Me.Label6.TabIndex = 86
Me.Label6.Text = "Ry"
'
'txtBE
'
Me.txtBE.Location = New System.Drawing.Point(425, 53)
Me.txtBE.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.txtBE.Name = "txtBE"
Me.txtBE.Size = New System.Drawing.Size(197, 20)
Me.txtBE.TabIndex = 87
Me.txtBE.Visible = False
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Font = New System.Drawing.Font("Bookman Old Style", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label7.Location = New System.Drawing.Point(469, 24)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(134, 72)
Me.Label7.TabIndex = 88
Me.Label7.Text = "<NAME>" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "<NAME>" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "<NAME>" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "<NAME>"
'
'op26
'
Me.op26.Appearance = System.Windows.Forms.Appearance.Button
Me.op26.Font = New System.Drawing.Font("Bookman Old Style", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.op26.Location = New System.Drawing.Point(582, 115)
Me.op26.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.op26.Name = "op26"
Me.op26.Size = New System.Drawing.Size(90, 46)
Me.op26.TabIndex = 30
Me.op26.TabStop = True
Me.op26.Text = "NOT"
Me.op26.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.op26.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.SystemColors.InactiveCaption
Me.ClientSize = New System.Drawing.Size(784, 592)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.txtBE)
Me.Controls.Add(Me.Panel3)
Me.Controls.Add(Me.txtNumIn)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.lblSpeed)
Me.Controls.Add(Me.lblCOM)
Me.Controls.Add(Me.cbxSpeed)
Me.Controls.Add(Me.cbxCOM)
Me.Controls.Add(Me.lblOutput)
Me.Controls.Add(Me.txtOutput)
Me.Controls.Add(Me.btnWrite)
Me.Controls.Add(Me.btnClose)
Me.Controls.Add(Me.btnInit)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.Panel2)
Me.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
Me.MaximizeBox = False
Me.MaximumSize = New System.Drawing.Size(800, 630)
Me.MinimumSize = New System.Drawing.Size(800, 630)
Me.Name = "Form1"
Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide
Me.Text = "Microprocessor Interface ECE378 Project"
Me.Panel1.ResumeLayout(False)
Me.Panel2.ResumeLayout(False)
Me.Panel2.PerformLayout()
Me.Panel3.ResumeLayout(False)
Me.Panel3.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents btnInit As System.Windows.Forms.Button
Friend WithEvents btnClose As System.Windows.Forms.Button
Friend WithEvents btnWrite As System.Windows.Forms.Button
Friend WithEvents txtOutput As System.Windows.Forms.RichTextBox
Friend WithEvents lblOutput As System.Windows.Forms.Label
Friend WithEvents cbxCOM As System.Windows.Forms.ComboBox
Friend WithEvents cbxSpeed As System.Windows.Forms.ComboBox
Friend WithEvents lblCOM As System.Windows.Forms.Label
Friend WithEvents lblSpeed As System.Windows.Forms.Label
Friend WithEvents SerialPort1 As System.IO.Ports.SerialPort
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents txtNumIn As System.Windows.Forms.TextBox
Friend WithEvents op0 As System.Windows.Forms.RadioButton
Friend WithEvents op1 As System.Windows.Forms.RadioButton
Friend WithEvents op2 As System.Windows.Forms.RadioButton
Friend WithEvents op3 As System.Windows.Forms.RadioButton
Friend WithEvents op4 As System.Windows.Forms.RadioButton
Friend WithEvents op5 As System.Windows.Forms.RadioButton
Friend WithEvents op6 As System.Windows.Forms.RadioButton
Friend WithEvents op7 As System.Windows.Forms.RadioButton
Friend WithEvents op8 As System.Windows.Forms.RadioButton
Friend WithEvents op9 As System.Windows.Forms.RadioButton
Friend WithEvents op10 As System.Windows.Forms.RadioButton
Friend WithEvents op12 As System.Windows.Forms.RadioButton
Friend WithEvents op13 As System.Windows.Forms.RadioButton
Friend WithEvents op14 As System.Windows.Forms.RadioButton
Friend WithEvents op15 As System.Windows.Forms.RadioButton
Friend WithEvents op16 As System.Windows.Forms.RadioButton
Friend WithEvents op17 As System.Windows.Forms.RadioButton
Friend WithEvents op18 As System.Windows.Forms.RadioButton
Friend WithEvents op19 As System.Windows.Forms.RadioButton
Friend WithEvents op20 As System.Windows.Forms.RadioButton
Friend WithEvents op21 As System.Windows.Forms.RadioButton
Friend WithEvents op22 As System.Windows.Forms.RadioButton
Friend WithEvents op23 As System.Windows.Forms.RadioButton
Friend WithEvents op24 As System.Windows.Forms.RadioButton
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Panel2 As System.Windows.Forms.Panel
Friend WithEvents rx3 As System.Windows.Forms.RadioButton
Friend WithEvents rx2 As System.Windows.Forms.RadioButton
Friend WithEvents rx1 As System.Windows.Forms.RadioButton
Friend WithEvents rx0 As System.Windows.Forms.RadioButton
Friend WithEvents Panel3 As System.Windows.Forms.Panel
Friend WithEvents ry3 As System.Windows.Forms.RadioButton
Friend WithEvents ry2 As System.Windows.Forms.RadioButton
Friend WithEvents ry1 As System.Windows.Forms.RadioButton
Friend WithEvents ry0 As System.Windows.Forms.RadioButton
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents op25 As System.Windows.Forms.RadioButton
Friend WithEvents op11 As System.Windows.Forms.RadioButton
Friend WithEvents txtBE As System.Windows.Forms.TextBox
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents op26 As System.Windows.Forms.RadioButton
End Class
|
<gh_stars>10-100
VERSION 5.00
Begin VB.Form frmSynonymSets
BorderStyle = 1 'Fixed Single
Caption = "Edit Synonym Sets"
ClientHeight = 9375
ClientLeft = 45
ClientTop = 330
ClientWidth = 9495
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 9375
ScaleWidth = 9495
Begin VB.CommandButton cmdClose
Caption = "Close"
Height = 375
Left = 8160
TabIndex = 18
Top = 8880
Width = 1215
End
Begin VB.ListBox lstAllSynonymSets
Height = 2985
Left = 120
TabIndex = 1
Tag = "1"
Top = 360
Width = 9255
End
Begin VB.Frame fraSelectedSynonymSet
Caption = "Selected Synonym Set"
Height = 4695
Left = 120
TabIndex = 4
Top = 4080
Width = 9255
Begin VB.TextBox txtName
Height = 285
Left = 1680
TabIndex = 6
Tag = "1"
Top = 360
Width = 7455
End
Begin VB.ListBox lstAllKeywords
Height = 2790
Left = 120
MultiSelect = 2 'Extended
TabIndex = 8
Tag = "1"
Top = 1200
Width = 3735
End
Begin VB.ListBox lstKeywordsInSynonymSet
Height = 2790
Left = 5400
MultiSelect = 2 'Extended
TabIndex = 15
Tag = "1"
Top = 1320
Width = 3735
End
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 375
Left = 7920
TabIndex = 17
Top = 4200
Width = 1215
End
Begin VB.CommandButton cmdUpdateCreate
Caption = "Update/Create"
Height = 375
Left = 6480
TabIndex = 16
Top = 4200
Width = 1335
End
Begin VB.CommandButton cmdRemoveAll
Caption = "<< Remove All"
Height = 375
Left = 3960
TabIndex = 11
Top = 2880
Width = 1335
End
Begin VB.CommandButton cmdRemove
Caption = "<< Remove"
Height = 375
Left = 3960
TabIndex = 10
Top = 2400
Width = 1335
End
Begin VB.CommandButton cmdAdd
Caption = "Add >>"
Height = 375
Left = 3960
TabIndex = 9
Top = 1920
Width = 1335
End
Begin VB.Label lblAllKeywords
Caption = "All Keywords:"
Height = 255
Left = 120
TabIndex = 7
Top = 960
Width = 3735
End
Begin VB.Label lblName
Caption = "Synonym Set Name:"
Height = 255
Left = 120
TabIndex = 5
Top = 360
Width = 1455
End
Begin VB.Label lblKeywordsInSynonymSet3
Caption = "contains the following Keywords:"
Height = 255
Left = 5400
TabIndex = 14
Top = 1080
Width = 3735
End
Begin VB.Label lblKeywordsInSynonymSet2
Caption = "<Synonym Set>"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 6720
TabIndex = 13
Top = 840
Width = 2295
End
Begin VB.Label lblKeywordsInSynonymSet1
Caption = "The Synonym Set"
Height = 255
Left = 5400
TabIndex = 12
Top = 840
Width = 1335
End
End
Begin VB.CommandButton cmdDelete
Caption = "Delete"
Height = 375
Left = 8160
TabIndex = 3
Top = 3480
Width = 1215
End
Begin VB.CommandButton cmdCreate
Caption = "Create"
Height = 375
Left = 6840
TabIndex = 2
Top = 3480
Width = 1215
End
Begin VB.Label lblAllSynonymSets
Caption = "All Synonym Sets:"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 1695
End
End
Attribute VB_Name = "frmSynonymSets"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private p_clsSynonymSets As AuthDatabase.SynonymSets
Private p_clsKeywords As AuthDatabase.Keywords
Private p_rsAllSynonymSets As ADODB.Recordset
Private p_rsAllKeywords As ADODB.Recordset
Private p_rsKeywordsInSynonymSetCopy As ADODB.Recordset
Private p_blnUpdating As Boolean
Private p_blnCreating As Boolean
Private Const STR_DEFAULT_SYNONYM_SET_NAME_C As String = "<Synonym Set>"
Private Sub Form_Load()
On Error GoTo LErrorHandler
Set p_clsSynonymSets = g_AuthDatabase.SynonymSets
Set p_clsKeywords = g_AuthDatabase.Keywords
Set p_rsAllSynonymSets = New ADODB.Recordset
Set p_rsAllKeywords = New ADODB.Recordset
Set p_rsKeywordsInSynonymSetCopy = New ADODB.Recordset
cmdClose.Cancel = True
p_UpdateAllSynonymSets
p_UpdateAllKeywords
p_DisableDelete
p_DisableSelectedSynonymSet
p_SetModeCreating False
p_SetToolTips
SetFontInternal Me
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "Form_Load"
GoTo LEnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set p_clsSynonymSets = Nothing
Set p_clsKeywords = Nothing
Set p_rsAllSynonymSets = Nothing
Set p_rsKeywordsInSynonymSetCopy = Nothing
Set p_rsAllKeywords = Nothing
End Sub
Private Sub lstAllSynonymSets_Click()
On Error GoTo LErrorHandler
If (p_blnCreating Or p_blnUpdating) Then
Exit Sub
End If
If (lstAllSynonymSets.ListIndex <> -1) Then
p_rsAllSynonymSets.Move lstAllSynonymSets.ListIndex, adBookmarkFirst
p_EnableDelete
p_EnableSelectedSynonymSetExceptUpdateCreateCancel
p_GetAndUpdateKeywordsInSynonymSet p_rsAllSynonymSets("EID")
txtName = p_rsAllSynonymSets("Name") & ""
Else
p_DisableSelectedSynonymSet
p_GetAndUpdateKeywordsInSynonymSet INVALID_ID_C
txtName = ""
End If
lblKeywordsInSynonymSet2.Caption = txtName
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "lstAllSynonymSets_Click"
GoTo LEnd
End Sub
Private Sub cmdCreate_Click()
On Error GoTo LErrorHandler
p_SetModeCreating True
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "cmdCreate_Click"
GoTo LEnd
End Sub
Private Sub cmdDelete_Click()
On Error GoTo LErrorHandler
Dim intEID As Long
intEID = p_rsAllSynonymSets("EID")
p_clsSynonymSets.Delete intEID
p_UpdateAllSynonymSets
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "cmdDelete_Click"
GoTo LEnd
End Sub
Private Sub cmdAdd_Click()
On Error GoTo LErrorHandler
Dim intIndex As Long
Dim intKID As Long
If (p_rsAllKeywords.RecordCount > 0) Then
p_rsAllKeywords.MoveFirst
End If
For intIndex = 0 To lstAllKeywords.ListCount - 1
If (lstAllKeywords.Selected(intIndex)) Then
lstAllKeywords.Selected(intIndex) = False
intKID = p_rsAllKeywords("KID")
If (Not p_KIDAlreadyInSynonymSet(intKID)) Then
p_rsKeywordsInSynonymSetCopy.AddNew
p_rsKeywordsInSynonymSetCopy("KID") = intKID
p_rsKeywordsInSynonymSetCopy("Keyword") = p_rsAllKeywords("Keyword")
End If
End If
p_rsAllKeywords.MoveNext
Next
p_UpdateKeywordsInSynonymSet
If (Not p_blnCreating) Then
p_SetModeUpdating True
End If
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "cmdAdd_Click"
GoTo LEnd
End Sub
Private Sub cmdRemove_Click()
On Error GoTo LErrorHandler
Dim intIndex As Long
If (p_rsKeywordsInSynonymSetCopy.RecordCount > 0) Then
p_rsKeywordsInSynonymSetCopy.MoveFirst
End If
For intIndex = 0 To lstKeywordsInSynonymSet.ListCount - 1
If (lstKeywordsInSynonymSet.Selected(intIndex)) Then
p_rsKeywordsInSynonymSetCopy.Delete
End If
p_rsKeywordsInSynonymSetCopy.MoveNext
Next
p_UpdateKeywordsInSynonymSet
If (Not p_blnCreating) Then
p_SetModeUpdating True
End If
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "cmdRemove_Click"
GoTo LEnd
End Sub
Private Sub cmdRemoveAll_Click()
On Error GoTo LErrorHandler
Dim intIndex As Long
For intIndex = 0 To lstKeywordsInSynonymSet.ListCount - 1
lstKeywordsInSynonymSet.Selected(intIndex) = True
Next
cmdRemove_Click
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "cmdRemoveAll_Click"
GoTo LEnd
End Sub
Private Sub cmdUpdateCreate_Click()
On Error GoTo LErrorHandler
Dim strName As String
strName = RemoveExtraSpaces(txtName.Text)
If (strName = "") Then
MsgBox "Synonym Set Name cannot be an empty string", vbExclamation + vbOKOnly
txtName.SetFocus
Exit Sub
End If
If (p_blnCreating) Then
p_CreateSynonymSet strName
Else
p_UpdateSynonymSet p_rsAllSynonymSets("EID"), strName
End If
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "cmdUpdateCreate_Click"
GoTo LEnd
End Sub
Private Sub cmdCancel_Click()
On Error GoTo LErrorHandler
If (p_blnCreating) Then
p_SetModeCreating False
ElseIf (p_blnUpdating) Then
p_SetModeUpdating False
End If
p_DisableUpdateCreateCancel
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "cmdCancel_Click"
GoTo LEnd
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub txtName_KeyPress(KeyAscii As Integer)
On Error GoTo LErrorHandler
p_EnableUpdateCreateCancel
If (Not p_blnCreating) Then
p_SetModeUpdating True
End If
LEnd:
Exit Sub
LErrorHandler:
p_DisplayErrorMessage "txtName_KeyPress"
GoTo LEnd
End Sub
Private Sub p_UpdateAllSynonymSets()
p_clsSynonymSets.GetAllSynonymSetsRs p_rsAllSynonymSets
lstAllSynonymSets.Clear
Do While (Not p_rsAllSynonymSets.EOF)
lstAllSynonymSets.AddItem p_rsAllSynonymSets("Name") & ""
p_rsAllSynonymSets.MoveNext
Loop
End Sub
Private Sub p_UpdateKeywordsInSynonymSet()
lstKeywordsInSynonymSet.Clear
If (p_rsKeywordsInSynonymSetCopy.RecordCount <> 0) Then
p_rsKeywordsInSynonymSetCopy.MoveFirst
End If
Do While (Not p_rsKeywordsInSynonymSetCopy.EOF)
lstKeywordsInSynonymSet.AddItem p_rsKeywordsInSynonymSetCopy("Keyword") & ""
p_rsKeywordsInSynonymSetCopy.MoveNext
Loop
End Sub
Private Sub p_GetAndUpdateKeywordsInSynonymSet(i_intEID As Long)
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
p_clsKeywords.GetKeywordsInSynonymSet i_intEID, rs
CopyRecordSet rs, p_rsKeywordsInSynonymSetCopy
p_UpdateKeywordsInSynonymSet
End Sub
Private Sub p_UpdateAllKeywords()
p_clsKeywords.GetAllKeywordsRs p_rsAllKeywords
lstAllKeywords.Clear
Do While (Not p_rsAllKeywords.EOF)
lstAllKeywords.AddItem p_rsAllKeywords("Keyword") & ""
p_rsAllKeywords.MoveNext
Loop
End Sub
Private Sub p_EnableCreate()
cmdCreate.Enabled = True
End Sub
Private Sub p_DisableCreate()
cmdCreate.Enabled = False
End Sub
Private Sub p_EnableDelete()
cmdDelete.Enabled = True
End Sub
Private Sub p_DisableDelete()
cmdDelete.Enabled = False
End Sub
Private Sub p_DisableSelectedSynonymSet()
fraSelectedSynonymSet.Enabled = False
lblName.Enabled = False
txtName.Enabled = False
lblAllKeywords.Enabled = False
lstAllKeywords.Enabled = False
cmdAdd.Enabled = False
cmdRemove.Enabled = False
cmdRemoveAll.Enabled = False
lblKeywordsInSynonymSet1.Enabled = False
lblKeywordsInSynonymSet2.Enabled = False
lblKeywordsInSynonymSet3.Enabled = False
lstKeywordsInSynonymSet.Enabled = False
p_DisableUpdateCreateCancel
End Sub
Private Sub p_EnableSelectedSynonymSetExceptUpdateCreateCancel()
fraSelectedSynonymSet.Enabled = True
lblName.Enabled = True
txtName.Enabled = True
lblAllKeywords.Enabled = True
lstAllKeywords.Enabled = True
cmdAdd.Enabled = True
cmdRemove.Enabled = True
cmdRemoveAll.Enabled = True
lblKeywordsInSynonymSet1.Enabled = True
lblKeywordsInSynonymSet2.Enabled = True
lblKeywordsInSynonymSet3.Enabled = True
lstKeywordsInSynonymSet.Enabled = True
End Sub
Private Sub p_EnableUpdateCreateCancel()
cmdUpdateCreate.Enabled = True
cmdCancel.Enabled = True
End Sub
Private Sub p_DisableUpdateCreateCancel()
cmdUpdateCreate.Enabled = False
cmdCancel.Enabled = False
End Sub
Private Sub p_NameUpdate()
cmdUpdateCreate.Caption = "Update"
End Sub
Private Sub p_NameCreate()
cmdUpdateCreate.Caption = "Create"
End Sub
Private Sub p_SetModeCreating(i_bln)
If (i_bln) Then
p_blnCreating = True
p_DisableCreate
p_DisableDelete
fraSelectedSynonymSet.Caption = "Creating new Synonym Set"
lblKeywordsInSynonymSet2.Caption = STR_DEFAULT_SYNONYM_SET_NAME_C
p_EnableSelectedSynonymSetExceptUpdateCreateCancel
txtName = ""
txtName.SetFocus
p_GetAndUpdateKeywordsInSynonymSet INVALID_ID_C
p_EnableUpdateCreateCancel
p_NameCreate
Else
p_blnCreating = False
p_EnableCreate
fraSelectedSynonymSet.Caption = "Selected Synonym Set"
lstAllSynonymSets_Click
p_DisableUpdateCreateCancel
p_NameUpdate
End If
End Sub
Private Sub p_SetModeUpdating(i_bln)
If (i_bln) Then
p_blnUpdating = True
p_DisableCreate
p_DisableDelete
p_EnableUpdateCreateCancel
Else
p_blnUpdating = False
p_EnableCreate
lstAllSynonymSets_Click
p_DisableUpdateCreateCancel
End If
End Sub
' Output in o_arrKeywords(1..Number of keywords)
Private Sub p_GetKeywordsInSynonymSet(o_arrKeywords() As Long)
Dim intIndex As Long
Dim intCount As Long
intCount = lstKeywordsInSynonymSet.ListCount
If (intCount = 0) Then
ReDim o_arrKeywords(0)
Exit Sub
End If
ReDim o_arrKeywords(intCount)
p_rsKeywordsInSynonymSetCopy.MoveFirst
intIndex = 1
Do While (Not p_rsKeywordsInSynonymSetCopy.EOF)
o_arrKeywords(intIndex) = p_rsKeywordsInSynonymSetCopy("KID")
p_rsKeywordsInSynonymSetCopy.MoveNext
intIndex = intIndex + 1
Loop
End Sub
Private Function p_KIDAlreadyInSynonymSet(i_intKID As Long) As Boolean
p_KIDAlreadyInSynonymSet = False
If (p_rsKeywordsInSynonymSetCopy.RecordCount = 0) Then
Exit Function
End If
p_rsKeywordsInSynonymSetCopy.MoveFirst
p_rsKeywordsInSynonymSetCopy.Find "KID = " & i_intKID, , adSearchForward
If (Not p_rsKeywordsInSynonymSetCopy.EOF) Then
p_KIDAlreadyInSynonymSet = True
End If
End Function
Private Sub p_CreateSynonymSet(i_strName As String)
Dim arrKeywords() As Long
p_GetKeywordsInSynonymSet arrKeywords
p_clsSynonymSets.Create i_strName, arrKeywords
p_UpdateAllSynonymSets
p_SetModeCreating False
End Sub
Private Sub p_UpdateSynonymSet(i_intEID As Long, i_strName As String)
Dim arrKeywords() As Long
p_GetKeywordsInSynonymSet arrKeywords
p_clsSynonymSets.Update i_intEID, i_strName, arrKeywords
p_UpdateAllSynonymSets
p_SetModeUpdating False
End Sub
Private Sub p_DisplayErrorMessage( _
ByVal i_strFunction As String _
)
Select Case Err.Number
Case errContainsGarbageChar
MsgBox "The Name " & txtName & " contains garbage characters", _
vbExclamation + vbOKOnly
Case errAlreadyExists
MsgBox "The Name " & txtName & " already exists", _
vbExclamation + vbOKOnly
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Case errNotPermittedForAuthoringGroup, errAuthoringGroupDiffers, _
errAuthoringGroupNotPresent
DisplayAuthoringGroupError
Case Else
g_ErrorInfo.SetInfoAndDump i_strFunction
End Select
End Sub
Private Sub p_SetToolTips()
lblAllSynonymSets.ToolTipText = "This is a list of all Synonym Sets that have " & _
"been created for this database."
lstAllSynonymSets.ToolTipText = lblAllSynonymSets.ToolTipText
lblName.ToolTipText = "If you have selected a Synonym Set, its name will appear here. " & _
"If you are creating a new Synonym Set, type in the new name here."
txtName.ToolTipText = lblName.ToolTipText
lblAllKeywords.ToolTipText = "This is a list of all keywords that have been created " & _
"for this database."
lstAllKeywords.ToolTipText = lblAllKeywords.ToolTipText
lblKeywordsInSynonymSet1.ToolTipText = "This is a list of all the keywords that " & _
"the selected synonym set contains."
lblKeywordsInSynonymSet2.ToolTipText = lblKeywordsInSynonymSet1.ToolTipText
lblKeywordsInSynonymSet3.ToolTipText = lblKeywordsInSynonymSet1.ToolTipText
lstKeywordsInSynonymSet.ToolTipText = lblKeywordsInSynonymSet1.ToolTipText
End Sub
|
Imports System
Imports System.Collections
Imports System.Core
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.WinForms
Imports System.Management
Namespace AsyncEvents
Public Class Form1
Inherits System.WinForms.Form
'Required by the Win Form Designer
Private components As System.ComponentModel.Container
Private ButtonClearEvents As System.WinForms.Button
Private LabelStatus As System.WinForms.Label
Private GroupBox2 As System.WinForms.GroupBox
Private ButtonStop As System.WinForms.Button
Private ButtonStart As System.WinForms.Button
Private ListBoxEvents As System.WinForms.ListBox
Private GroupBox1 As System.WinForms.GroupBox
Private WithEvents eventWatcher As ManagementEventWatcher
Public Sub New()
MyBase.New()
'This call is required by the Win Form Designer.
InitializeComponent()
'TODO: Add any initialization after the InitForm call
End Sub
'Form overrides dispose to clean up the component list.
Overrides Public Sub Dispose()
MyBase.Dispose()
components.Dispose()
eventWatcher = Nothing
End Sub
'The main entry point for the application
Shared Sub Main()
System.WinForms.Application.Run(New Form1)
End Sub
'NOTE: The following procedure is required by the Win Form Designer
'It can be modified using the Win Form Designer.
'Do not modify it using the code editor.
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.GroupBox2 = New System.WinForms.GroupBox
Me.GroupBox1 = New System.WinForms.GroupBox
Me.ButtonStop = New System.WinForms.Button
Me.ButtonClearEvents = New System.WinForms.Button
Me.ButtonStart = New System.WinForms.Button
Me.ListBoxEvents = New System.WinForms.ListBox
Me.LabelStatus = New System.WinForms.Label
GroupBox2.Location = New System.Drawing.Point(216, 136)
GroupBox2.TabIndex = 3
GroupBox2.TabStop = False
GroupBox2.Text = "Status"
GroupBox2.Size = New System.Drawing.Size(184, 56)
GroupBox1.Location = New System.Drawing.Point(16, 16)
GroupBox1.TabIndex = 0
GroupBox1.TabStop = False
GroupBox1.Text = "Events"
GroupBox1.Size = New System.Drawing.Size(160, 200)
ButtonStop.Location = New System.Drawing.Point(320, 72)
ButtonStop.Size = New System.Drawing.Size(80, 40)
ButtonStop.TabIndex = 2
ButtonStop.Text = "Stop"
ButtonStop.AddOnClick(New System.EventHandler(AddressOf Me.ButtonStop_Click))
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.Text = "Form1"
'@design Me.TrayLargeIcon = True
'@design Me.TrayHeight = 0
Me.ClientSize = New System.Drawing.Size(504, 261)
ButtonClearEvents.Location = New System.Drawing.Point(216, 24)
ButtonClearEvents.Size = New System.Drawing.Size(184, 40)
ButtonClearEvents.TabIndex = 4
ButtonClearEvents.Text = "Clear Events"
ButtonClearEvents.AddOnClick(New System.EventHandler(AddressOf Me.ButtonClearEvents_Click))
ButtonStart.Location = New System.Drawing.Point(216, 72)
ButtonStart.Size = New System.Drawing.Size(80, 40)
ButtonStart.TabIndex = 1
ButtonStart.Text = "Start"
ButtonStart.AddOnClick(New System.EventHandler(AddressOf Me.ButtonStart_Click))
ListBoxEvents.Location = New System.Drawing.Point(16, 24)
ListBoxEvents.Size = New System.Drawing.Size(128, 160)
ListBoxEvents.TabIndex = 0
LabelStatus.Location = New System.Drawing.Point(16, 24)
LabelStatus.Text = "Not yet started"
LabelStatus.Size = New System.Drawing.Size(152, 16)
LabelStatus.TabIndex = 0
GroupBox1.Controls.Add(ListBoxEvents)
GroupBox2.Controls.Add(LabelStatus)
Me.Controls.Add(ButtonClearEvents)
Me.Controls.Add(GroupBox2)
Me.Controls.Add(ButtonStop)
Me.Controls.Add(ButtonStart)
Me.Controls.Add(GroupBox1)
eventWatcher = New ManagementEventWatcher("select * from __instancemodificationevent within 1 where targetinstance isa 'Win32_Process'")
End Sub
Protected Sub ButtonClearEvents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
ListBoxEvents.Items.Clear()
End Sub
Protected Sub ButtonStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
eventWatcher.Stop()
Catch e1 As ManagementException
End Try
End Sub
Protected Sub ButtonStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
eventWatcher.Start()
LabelStatus.Text = "Started"
Catch e1 As ManagementException
End Try
End Sub
Protected Sub HandleNewEvent(ByVal sender As System.Object, ByVal e As EventArrivedEventArgs) Handles eventWatcher.EventArrived
Dim previousInstance As ManagementBaseObject
Try
previousInstance = CType(e.NewEvent("PreviousInstance"), ManagementBaseObject)
ListBoxEvents.Items.Add(previousInstance.GetPropertyValue("Name"))
Catch f As Exception
ListBoxEvents.Items.Add(f.ToString())
End Try
End Sub
Protected Sub HandleStopped(ByVal sender As System.Object, ByVal e As StoppedEventArgs) Handles eventWatcher.Stopped
LabelStatus.Text = "Stopped"
End Sub
End Class
End Namespace
|
Public Sub BuildHTMLTable()
'simple HTML table, represented as a string matrix "cells"
Const nRows = 6
Const nCols = 4
Dim cells(1 To nRows, 1 To nCols) As String
Dim HTML As String 'the HTML table
Dim temp As String
Dim attr As String
' fill table
' first row with titles
cells(1, 1) = ""
cells(1, 2) = "X"
cells(1, 3) = "Y"
cells(1, 4) = "Z"
'next rows with index & random numbers
For i = 2 To nRows
cells(i, 1) = Format$(i - 1)
For j = 2 To nCols
cells(i, j) = Format$(Int(Rnd() * 10000))
Next j
Next i
'build the HTML
HTML = ""
For i = 1 To nRows
temp = ""
'first row as header row
If i = 1 Then attr = "th" Else attr = "td"
For j = 1 To nCols
temp = temp & HTMLWrap(cells(i, j), attr)
Next j
HTML = HTML & HTMLWrap(temp, "tr")
Next i
HTML = HTMLWrap(HTML, "table", "style=""text-align:center; border: 1px solid""")
Debug.Print HTML
End Sub
Public Function HTMLWrap(s As String, tag As String, ParamArray attributes()) As String
'returns string s wrapped in HTML tag with optional "attribute=value" strings
'ex.: HTMLWrap("Link text", "a", "href=""http://www.somesite.org""")
'returns: <a href="http://www.somesite.org">Link text</a>
Dim sOpenTag As String
Dim sClosingTag As String
sOpenTag = "<" & tag
For Each attr In attributes
sOpenTag = sOpenTag & " " & attr
Next
sOpenTag = sOpenTag & ">"
sClosingTag = "</" & tag & ">"
HTMLWrap = sOpenTag & s & sClosingTag
End Function
|
<gh_stars>10-100
on error resume next
set process = GetObject("winmgmts:{impersonationLevel=impersonate}!Win32_Process")
result = process.Create ("notepad.exe",null,null,processid)
WScript.Echo "Method returned result = " & result
WScript.Echo "Id of new process is " & processid
if err <>0 then
WScript.Echo Hex(Err.Number)
end if
|
<reponame>LaudateCorpus1/RosettaCodeData<filename>Task/Arithmetic-geometric-mean/VBScript/arithmetic-geometric-mean.vb
Function agm(a,g)
Do Until a = tmp_a
tmp_a = a
a = (a + g)/2
g = Sqr(tmp_a * g)
Loop
agm = a
End Function
WScript.Echo agm(1,1/Sqr(2))
|
<filename>Task/Empty-directory/VBA/empty-directory.vba
Sub Main()
Debug.Print IsEmptyDirectory("C:\Temp")
Debug.Print IsEmptyDirectory("C:\Temp\")
End Sub
Private Function IsEmptyDirectory(D As String) As Boolean
Dim Sep As String
Sep = Application.PathSeparator
D = IIf(Right(D, 1) <> Sep, D & Sep, D)
IsEmptyDirectory = (Dir(D & "*.*") = "")
End Function
|
Set oFSO = CreateObject( "Scripting.FileSystemObject" )
oFSO.DeleteFile "input.txt"
oFSO.DeleteFolder "docs"
oFSO.DeleteFile "\input.txt"
oFSO.DeleteFolder "\docs"
'Using Delete on file and folder objects
dim fil, fld
set fil = oFSO.GetFile( "input.txt" )
fil.Delete
set fld = oFSO.GetFolder( "docs" )
fld.Delete
set fil = oFSO.GetFile( "\input.txt" )
fil.Delete
set fld = oFSO.GetFolder( "\docs" )
fld.Delete
|
' Windows Installer database utility to merge data from another database
' For use with Windows Scripting Host, CScript.exe or WScript.exe
' Copyright (c) Microsoft Corporation. All rights reserved.
' Demonstrates the use of the Database.Merge method and MsiDatabaseMerge API
'
Option Explicit
Const msiOpenDatabaseModeReadOnly = 0
Const msiOpenDatabaseModeTransact = 1
Const msiOpenDatabaseModeCreate = 3
Const ForAppending = 8
Const ForReading = 1
Const ForWriting = 2
Const TristateTrue = -1
Dim argCount:argCount = Wscript.Arguments.Count
Dim iArg:iArg = 0
If (argCount < 2) Then
Wscript.Echo "Windows Installer database merge utility" &_
vbNewLine & " 1st argument is the path to MSI database (installer package)" &_
vbNewLine & " 2nd argument is the path to database containing data to merge" &_
vbNewLine & " 3rd argument is the optional table to contain the merge errors" &_
vbNewLine & " If 3rd argument is not present, the table _MergeErrors is used" &_
vbNewLine & " and that table will be dropped after displaying its contents." &_
vbNewLine &_
vbNewLine & "Copyright (C) Microsoft Corporation. All rights reserved."
Wscript.Quit 1
End If
' Connect to Windows Installer object
On Error Resume Next
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError
' Open databases and merge data
Dim database1 : Set database1 = installer.OpenDatabase(WScript.Arguments(0), msiOpenDatabaseModeTransact) : CheckError
Dim database2 : Set database2 = installer.OpenDatabase(WScript.Arguments(1), msiOpenDatabaseModeReadOnly) : CheckError
Dim errorTable : errorTable = "_MergeErrors"
If argCount >= 3 Then errorTable = WScript.Arguments(2)
Dim hasConflicts:hasConflicts = database1.Merge(database2, errorTable) 'Old code returns void value, new returns boolean
If hasConflicts <> True Then hasConflicts = CheckError 'Temp for old Merge function that returns void
If hasConflicts <> 0 Then
Dim message, line, view, record
Set view = database1.OpenView("Select * FROM `" & errorTable & "`") : CheckError
view.Execute
Do
Set record = view.Fetch
If record Is Nothing Then Exit Do
line = record.StringData(1) & " table has " & record.IntegerData(2) & " conflicts"
If message = Empty Then message = line Else message = message & vbNewLine & line
Loop
Set view = Nothing
Wscript.Echo message
End If
If argCount < 3 And hasConflicts Then database1.OpenView("DROP TABLE `" & errorTable & "`").Execute : CheckError
database1.Commit : CheckError
Quit 0
Function CheckError
Dim message, errRec
CheckError = 0
If Err = 0 Then Exit Function
message = Err.Source & " " & Hex(Err) & ": " & Err.Description
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbNewLine & errRec.FormatText : CheckError = errRec.IntegerData(1)
End If
If CheckError = 2268 Then Err.Clear : Exit Function
Wscript.Echo message
Wscript.Quit 2
End Function
|
<gh_stars>1-10
Dim x As Boolean
x = IIf(Int(Rnd * 2), True, False)
MsgBox x
|
VERSION 5.00
Begin VB.Form frmPayload
BackColor = &H00000000&
BorderStyle = 0 'None
ClientHeight = 12960
ClientLeft = -195
ClientTop = -195
ClientWidth = 17280
LinkTopic = "Form1"
ScaleHeight = 12960
ScaleWidth = 17280
ShowInTaskbar = 0 'False
Begin VB.Label Label2
BackColor = &H00000000&
Caption = "<NAME>"
BeginProperty Font
Name = "Arial"
Size = 72
Charset = 238
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 1695
Left = 1320
TabIndex = 2
Top = 4920
Width = 10335
End
Begin VB.Label Label1
BackColor = &H00000000&
Caption = "D.C.A."
BeginProperty Font
Name = "Arial"
Size = 72
Charset = 238
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FFFF&
Height = 1695
Left = 3360
TabIndex = 1
Top = 2040
Width = 4455
End
Begin VB.Label lblTitle
BackColor = &H00000000&
Caption = "Freedom Manifesto anti Pilif"
BeginProperty Font
Name = "Arial"
Size = 20.25
Charset = 238
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 495
Left = 2760
TabIndex = 0
Top = 480
Width = 5775
End
End
Attribute VB_Name = "frmPayload"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'================================================
'| Pilif ... [JOS CeNzurA]! |
'| Rott_En | Dark Coderz Alliance |
'| Manifesto for the human right of expression |
'| No more censore! |
'================================================
Private Sub Form_Load()
frmPayload.Height = Screen.Height
frmPayload.Width = Screen.Width
frmPayload.Top = 0
frmPayload.Left = 0
lblTitle.Top = frmPayload.Height / 6
lblTitle.Left = frmPayload.Width / 3
Label1.Top = frmPayload.Height / 4
Label1.Left = frmPayload.Width / 2.7
Label2.Top = frmPayload.Height / 2
Label2.Left = frmPayload.Width / 4.6
DoEvents
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
MsgBox "Feel how it is to have your basic rights taken away!"
Unload Me
End Sub
'================================================
'| Pilif ... [JOS CeNzurA]! |
'| Rott_En | Dark Coderz Alliance |
'| Manifesto for the human right of expression |
'| No more censore! |
'================================================
|
Function mtf_encode(s)
'create the array list and populate it with the initial symbol position
Set symbol_table = CreateObject("System.Collections.ArrayList")
For j = 97 To 122 'a to z in decimal.
symbol_table.Add Chr(j)
Next
output = ""
For i = 1 To Len(s)
char = Mid(s,i,1)
If i = Len(s) Then
output = output & symbol_table.IndexOf(char,0)
symbol_table.RemoveAt(symbol_table.LastIndexOf(char))
symbol_table.Insert 0,char
Else
output = output & symbol_table.IndexOf(char,0) & " "
symbol_table.RemoveAt(symbol_table.LastIndexOf(char))
symbol_table.Insert 0,char
End If
Next
mtf_encode = output
End Function
Function mtf_decode(s)
'break the function argument into an array
code = Split(s," ")
'create the array list and populate it with the initial symbol position
Set symbol_table = CreateObject("System.Collections.ArrayList")
For j = 97 To 122 'a to z in decimal.
symbol_table.Add Chr(j)
Next
output = ""
For i = 0 To UBound(code)
char = symbol_table(code(i))
output = output & char
If code(i) <> 0 Then
symbol_table.RemoveAt(symbol_table.LastIndexOf(char))
symbol_table.Insert 0,char
End If
Next
mtf_decode = output
End Function
'Testing the functions
wordlist = Array("broood","bananaaa","hiphophiphop")
For Each word In wordlist
WScript.StdOut.Write word & " encodes as " & mtf_encode(word) & " and decodes as " &_
mtf_decode(mtf_encode(word)) & "."
WScript.StdOut.WriteBlankLines(1)
Next
|
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
Public twenties As Variant
Public decades As Variant
Public orders As Variant
Private Sub init()
twenties = [{"zero","one","two","three","four","five","six","seven","eight","nine","ten", "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"}]
decades = [{"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"}]
orders = [{1E15,"quadrillion"; 1E12,"trillion"; 1E9,"billion"; 1E6,"million"; 1E3,"thousand"}]
End Sub
Private Function Twenty(N As Variant)
Twenty = twenties(N Mod 20 + 1)
End Function
Private Function Decade(N As Variant)
Decade = decades(N Mod 10 - 1)
End Function
Private Function Hundred(N As Variant)
If N < 20 Then
Hundred = Twenty(N)
Exit Function
Else
If N Mod 10 = 0 Then
Hundred = Decade((N \ 10) Mod 10)
Exit Function
End If
End If
Hundred = Decade(N \ 10) & "-" & Twenty(N Mod 10)
End Function
Private Function Thousand(N As Variant, withand As String)
If N < 100 Then
Thousand = withand & Hundred(N)
Exit Function
Else
If N Mod 100 = 0 Then
Thousand = withand & Twenty(WorksheetFunction.Floor_Precise(N / 100)) & " hundred"
Exit Function
End If
End If
Thousand = Twenty(N \ 100) & " hundred and " & Hundred(N Mod 100)
End Function
Private Function Triplet(N As Variant)
Dim Order, High As Variant, Low As Variant
Dim Name As String, res As String
For i = 1 To UBound(orders)
Order = orders(i, 1)
Name = orders(i, 2)
High = WorksheetFunction.Floor_Precise(N / Order)
Low = N - High * Order 'N Mod Order
If High <> 0 Then
res = res & Thousand(High, "") & " " & Name
End If
N = Low
If Low = 0 Then Exit For
If Len(res) And High <> 0 Then
res = res & ", "
End If
Next i
If N <> 0 Or res = "" Then
res = res & Thousand(WorksheetFunction.Floor_Precise(N), IIf(res = "", "", "and "))
N = N - Int(N)
If N > 0.000001 Then
res = res & " point"
For i = 1 To 10
n_ = WorksheetFunction.Floor_Precise(N * 10.0000001)
res = res & " " & twenties(n_ + 1)
N = N * 10 - n_
If Abs(N) < 0.000001 Then Exit For
Next i
End If
End If
Triplet = res
End Function
Private Function spell(N As Variant)
Dim res As String
If N < 0 Then
res = "minus "
N = -N
End If
res = res & Triplet(N)
spell = res
End Function
Private Function smartp(N As Variant)
Dim res As String
If N = WorksheetFunction.Floor_Precise(N) Then
smartp = CStr(N)
Exit Function
End If
res = CStr(N)
If InStr(1, res, ".") Then
res = Left(res, InStr(1, res, "."))
End If
smartp = res
End Function
Sub Main()
Dim si As Variant
init
Samples1 = [{99, 300, 310, 417, 1501, 12609, 200000000000100, 999999999999999, -123456787654321,102003000400005,1020030004,102003,102,1,0,-1,-99, -1501,1234,12.34}]
Samples2 = [{10000001.2,1E-3,-2.7182818, 201021002001,-20102100200,2010210020,-201021002,20102100,-2010210, 201021,-20102,2010,-201,20,-2}]
For i = 1 To UBound(Samples1)
si = Samples1(i)
Debug.Print Format(smartp(si), "@@@@@@@@@@@@@@@@"); " "; spell(si)
Next i
For i = 1 To UBound(Samples2)
si = Samples2(i)
Debug.Print Format(smartp(si), "@@@@@@@@@@@@@@@@"); " "; spell(si)
Next i
End Sub
|
Set objSet = GetObject("winmgmts:").InstancesOf("Win32_MountPoint")
for each Mount in objSet
WScript.Echo Mount.Directory & " <-> " & Mount.Volume
next
|
<gh_stars>1-10
data = "1,2,3,4,5,5,4,3,2,1"
token = Split(data,",")
stream = ""
WScript.StdOut.WriteLine "Number" & vbTab & "SMA3" & vbTab & "SMA5"
For j = LBound(token) To UBound(token)
If Len(stream) = 0 Then
stream = token(j)
Else
stream = stream & "," & token(j)
End If
WScript.StdOut.WriteLine token(j) & vbTab & Round(SMA(stream,3),2) & vbTab & Round(SMA(stream,5),2)
Next
Function SMA(s,p)
If Len(s) = 0 Then
SMA = 0
Exit Function
End If
d = Split(s,",")
sum = 0
If UBound(d) + 1 >= p Then
c = 0
For i = UBound(d) To LBound(d) Step -1
sum = sum + Int(d(i))
c = c + 1
If c = p Then
Exit For
End If
Next
SMA = sum / p
Else
For i = UBound(d) To LBound(d) Step -1
sum = sum + Int(d(i))
Next
SMA = sum / (UBound(d) + 1)
End If
End Function
|
<reponame>npocmaka/Windows-Server-2003
VERSION 5.00
Begin VB.Form Form1
Caption = "WMI Privilege Test Client"
ClientHeight = 9585
ClientLeft = 165
ClientTop = 735
ClientWidth = 12540
BeginProperty Font
Name = "<NAME>"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 9585
ScaleWidth = 12540
StartUpPosition = 3 'Windows Default
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 6
ItemData = "Form1.frx":0442
Left = 2040
List = "Form1.frx":0444
TabIndex = 39
ToolTipText = "Required to act as part of the operating system"
Top = 5400
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 14
ItemData = "Form1.frx":0446
Left = 6000
List = "Form1.frx":0448
TabIndex = 38
ToolTipText = "Required to create a paging file"
Top = 5365
Width = 1575
End
Begin VB.CommandButton Command1
BackColor = &H00C0C0C0&
Caption = "Execute"
BeginProperty Font
Name = "Comic Sans MS"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 4800
MaskColor = &H0000FFFF&
Style = 1 'Graphical
TabIndex = 37
Top = 8520
Width = 2775
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 23
ItemData = "Form1.frx":044A
Left = 10080
List = "Form1.frx":044C
TabIndex = 20
ToolTipText = "Required to shutdown a local system"
Top = 6360
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 22
ItemData = "Form1.frx":044E
Left = 10080
List = "Form1.frx":0450
TabIndex = 19
ToolTipText = "Required to receive notifications of file or directory changes"
Top = 5400
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 21
ItemData = "Form1.frx":0452
Left = 10080
List = "Form1.frx":0454
TabIndex = 18
ToolTipText = "Required to modify system environment settings"
Top = 4400
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 20
ItemData = "Form1.frx":0456
Left = 10080
List = "Form1.frx":0458
TabIndex = 17
ToolTipText = "Required to generate audit log entries"
Top = 3420
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 19
ItemData = "Form1.frx":045A
Left = 10080
List = "Form1.frx":045C
TabIndex = 16
ToolTipText = "Requred to debug a process"
Top = 2440
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 18
ItemData = "Form1.frx":045E
Left = 10080
List = "Form1.frx":0460
TabIndex = 15
ToolTipText = "Required to shutdown a local system"
Top = 1460
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 17
ItemData = "Form1.frx":0462
Left = 10080
List = "Form1.frx":0464
TabIndex = 14
ToolTipText = "Required to perform restore operations"
Top = 480
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 16
ItemData = "Form1.frx":0466
Left = 6000
List = "Form1.frx":0468
TabIndex = 13
Top = 7320
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 15
ItemData = "Form1.frx":046A
Left = 6000
List = "Form1.frx":046C
TabIndex = 12
ToolTipText = "Required to create a permanent object"
Top = 6360
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 13
ItemData = "Form1.frx":046E
Left = 6000
List = "Form1.frx":0470
TabIndex = 11
ToolTipText = "Required to increase the base priority of a process"
Top = 4388
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 12
ItemData = "Form1.frx":0472
Left = 6000
List = "Form1.frx":0474
TabIndex = 10
ToolTipText = "Required to gather profiing information for a process"
Top = 3411
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 11
ItemData = "Form1.frx":0476
Left = 6000
List = "Form1.frx":0478
TabIndex = 9
ToolTipText = "Required to modify the system time"
Top = 2434
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 10
ItemData = "Form1.frx":047A
Left = 6000
List = "Form1.frx":047C
TabIndex = 8
ToolTipText = "Required to gather profiling information for the system"
Top = 1455
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 9
ItemData = "Form1.frx":047E
Left = 6000
List = "Form1.frx":0480
TabIndex = 7
ToolTipText = "Required to load or unload a device driver"
Top = 480
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 8
ItemData = "Form1.frx":0482
Left = 2040
List = "Form1.frx":0484
TabIndex = 6
ToolTipText = "Required to modify ownership of an object without being granted discretionary access"
Top = 7320
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 7
ItemData = "Form1.frx":0486
Left = 2040
List = "Form1.frx":0488
TabIndex = 5
ToolTipText = "Required to perform some security-related functions"
Top = 6360
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 5
ItemData = "Form1.frx":048A
Left = 2040
List = "Form1.frx":048C
TabIndex = 4
Top = 4380
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 4
ItemData = "Form1.frx":048E
Left = 2040
List = "Form1.frx":0490
TabIndex = 3
Top = 3400
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 3
ItemData = "Form1.frx":0492
Left = 2040
List = "Form1.frx":0494
TabIndex = 2
Top = 2415
Width = 1575
End
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 2
ItemData = "Form1.frx":0496
Left = 2040
List = "Form1.frx":0498
TabIndex = 1
Top = 1440
Width = 1575
End
Begin VB.Frame Frame1
Caption = "Privileges"
BeginProperty Font
Name = "Comic Sans MS"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 8055
Left = 240
TabIndex = 0
Top = 240
Width = 12015
Begin VB.ListBox PrivilegeSetting
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 735
Index = 1
ItemData = "Form1.frx":049A
Left = 1800
List = "Form1.frx":049C
TabIndex = 26
Top = 240
Width = 1575
End
Begin VB.Label Label9
Caption = "Load Driver"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 495
Left = 4080
TabIndex = 47
ToolTipText = "Required to load and unload device drivers"
Top = 360
Width = 1215
End
Begin VB.Label Label17
Caption = "Restore"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 255
Left = 8280
TabIndex = 46
ToolTipText = "Required to perform restore operations"
Top = 480
Width = 1455
End
Begin VB.Label Label18
Caption = "Shutdown"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 255
Left = 8280
TabIndex = 45
ToolTipText = "Required to shut down the local system"
Top = 1440
Width = 1455
End
Begin VB.Label Label19
Caption = "Debug"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 375
Left = 8280
TabIndex = 44
ToolTipText = "Required to debug a process"
Top = 2280
Width = 1335
End
Begin VB.Label Label20
Caption = "Audit"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 255
Left = 8280
TabIndex = 43
ToolTipText = "Required to generate audit log entries"
Top = 3480
Width = 1455
End
Begin VB.Label Label21
Caption = "System Environment"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 8280
TabIndex = 42
ToolTipText = "Required to change system environment settings"
Top = 4200
Width = 1575
End
Begin VB.Label Label22
Caption = "Change Notify"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 375
Left = 8280
TabIndex = 41
ToolTipText = "Required to receive notifications when a file or directory changes"
Top = 5280
Width = 1575
End
Begin VB.Label Label23
Caption = "Remote Shutdown"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 8280
TabIndex = 40
ToolTipText = "Required to shutdown a remote system"
Top = 6120
Width = 1455
End
Begin VB.Label Label16
Caption = "Backup"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 375
Left = 4080
TabIndex = 36
ToolTipText = "Required to perform backup operations"
Top = 7200
Width = 975
End
Begin VB.Label Label15
Caption = "Create Permanent"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 4080
TabIndex = 35
ToolTipText = "Required to create a permanent object"
Top = 6120
Width = 1335
End
Begin VB.Label Label14
Caption = "Create Pagefile"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 495
Left = 4080
TabIndex = 34
ToolTipText = "Required to create a paging file"
Top = 5280
Width = 1455
End
Begin VB.Label Label13
Caption = "Increase Base Priority"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 4080
TabIndex = 33
ToolTipText = "Required to increase the base priority of a process"
Top = 4200
Width = 1575
End
Begin VB.Label Label12
Caption = "Profile Single Process"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 4080
TabIndex = 32
ToolTipText = "Required to profile a single process"
Top = 3240
Width = 1575
End
Begin VB.Label Label11
Caption = "System Time"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 495
Left = 4080
TabIndex = 31
ToolTipText = "Required to modify the system time"
Top = 2280
Width = 1215
End
Begin VB.Label Label10
Caption = "System Profile"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 4080
TabIndex = 30
ToolTipText = "Required to profile the system"
Top = 1200
Width = 1215
End
Begin VB.Label Label8
Caption = "Take Ownership"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 360
TabIndex = 29
ToolTipText = "Required to take ownership of an object without being granted discretionary access rights"
Top = 7080
Width = 1335
End
Begin VB.Label Label7
Caption = "Security"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 255
Left = 360
TabIndex = 28
ToolTipText = "Required to perform some security operations"
Top = 6240
Width = 1335
End
Begin VB.Label Label1
Caption = "Create Token"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Index = 0
Left = 360
TabIndex = 27
ToolTipText = "Required to create a primary token"
Top = 360
Width = 1095
End
Begin VB.Label Label6
Caption = "Tcb"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 255
Left = 360
TabIndex = 25
ToolTipText = "Required to act as part of the operating system"
Top = 5400
Width = 1335
End
Begin VB.Label Label5
Caption = "Machine Account"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 360
TabIndex = 24
ToolTipText = "Required to add workstations to a domain"
Top = 4200
Width = 1095
End
Begin VB.Label Label4
Caption = "Increase Quota"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 360
TabIndex = 23
ToolTipText = "Required to increase the quota assigned to a process"
Top = 3240
Width = 1335
End
Begin VB.Label Label3
Caption = "Lock Memory"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 495
Left = 360
TabIndex = 22
ToolTipText = "Required to lock physical pages in memory"
Top = 2280
Width = 1335
End
Begin VB.Label Label2
Caption = "Primary Token"
BeginProperty Font
Name = "Comic Sans MS"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 615
Left = 360
TabIndex = 21
ToolTipText = "Required to assign the primary token of a process"
Top = 1320
Width = 1335
End
End
Begin VB.Menu MenuExit
Caption = "&Exit"
NegotiatePosition= 1 'Left
End
Begin VB.Menu MenuOptions
Caption = "&Options"
Begin VB.Menu MenuDisableAllPrivileges
Caption = "&Disable All Privileges"
End
Begin VB.Menu MenuEnableAllPrivileges
Caption = "&Enable All Privileges"
End
Begin VB.Menu MenuResetPrivileges
Caption = "&Reset Privileges"
End
Begin VB.Menu MenuSeparator
Caption = "-"
End
Begin VB.Menu MenuProviderLogging
Caption = "&Provider Logging"
Checked = -1 'True
End
End
Begin VB.Menu MenuHelp
Caption = "&Help"
Begin VB.Menu MenuHelpAbout
Caption = "&About WMI Privilege Test Client..."
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Locator As SWbemLocator
Const privilegeEnabled = 0
Const privilegeDisabled = 1
Const privilegeUnchanged = 2
'Win32 defines
Private Const TokenPrivileges = 3
Private Const SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"
Private Const SE_AUDIT_NAME = "SeAuditPrivilege"
Private Const SE_BACKUP_NAME = "SeBackupPrivilege"
Private Const SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"
Private Const SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"
Private Const SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"
Private Const SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"
Private Const SE_DEBUG_NAME = "SeDebugPrivilege"
Private Const SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"
Private Const SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"
Private Const SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"
Private Const SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"
Private Const SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"
Private Const SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"
Private Const SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"
Private Const SE_RESTORE_NAME = "SeRestorePrivilege"
Private Const SE_SECURITY_NAME = "SeSecurityPrivilege"
Private Const SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
Private Const SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"
Private Const SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"
Private Const SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"
Private Const SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"
Private Const SE_TCB_NAME = "SeTcbPrivilege"
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function GetTokenInformation Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal TokenInformationClass As Long, TokenInformation As Any, ByVal TokenInformationLength As Long, returnLength As Long) As Long
Private Declare Function LookupPrivilegeName Lib "advapi32.dll" Alias "LookupPrivilegeNameA" (ByVal lpSystemName As String, lpLuid As LARGE_INTEGER, ByVal lpName As String, cbName As Long) As Long
Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Type LARGE_INTEGER
LowPart As Long
HighPart As Long
End Type
Private Type luid
LowPart As Long
HighPart As Long
End Type
Private Type LUID_AND_ATTRIBUTES
pLuid As luid
Attributes As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
Privileges(23) As LUID_AND_ATTRIBUTES
End Type
Private Sub Command1_Click()
Dim numEnabled As Integer
Dim numDisabled As Integer
numEnabled = 0
numDisabled = 0
' Modify the Locator privileges
For Each individualPrivilegeSetting In PrivilegeSetting
Select Case individualPrivilegeSetting.ListIndex
Case privilegeEnabled
Locator.Security_.Privileges.Add individualPrivilegeSetting.Index
Case privilegeDisabled
Locator.Security_.Privileges.Add individualPrivilegeSetting.Index, False
End Select
Next
'Create a named value set
Dim nvset As SWbemNamedValueSet
Set nvset = CreateObject("WbemScripting.SWbemNamedValueSet")
For Each privilege In Locator.Security_.Privileges
If privilege.IsEnabled Then
numEnabled = numEnabled + 1
Else
numDisabled = numDisabled + 1
End If
Next
If numEnabled > 0 Then
ReDim enabledarray(0 To numEnabled - 1)
curIndex = 0
For Each privilege In Locator.Security_.Privileges
If privilege.IsEnabled Then
enabledarray(curIndex) = privilege.name
curIndex = curIndex + 1
End If
Next
nvset.Add "EnabledPrivileges", enabledarray
End If
If numDisabled > 0 Then
ReDim disabledArray(0 To numDisabled - 1)
curIndex = 0
For Each privilege In Locator.Security_.Privileges
If privilege.IsEnabled = False Then
disabledArray(curIndex) = privilege.name
curIndex = curIndex + 1
End If
Next
nvset.Add "DisabledPrivileges", disabledArray
End If
'Set the logging flag
nvset.Add "DetailedLogging", MenuProviderLogging.Checked
'For grins print out the context info
PrintSettings nvset
'Now do the biz
Dim service As SWbemServices
Dim obj As SWbemObject
Set service = Locator.ConnectServer(, "root/scenario28")
service.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
On Error Resume Next
Set obj = service.Get("Scenario28.key=""x""", , nvset)
If Err <> 0 Then
Debug.Print Hex(Err.Number), Err.Description
'Look for error object
Dim providerInfo As SWbemLastError
Set providerInfo = CreateObject("WbemScripting.SWbemLastError")
If providerInfo Is Nothing Then
MsgBox "Did not receive error object", vbCritical, "Error"
Else
Dim resultsDialog As Dialog
Set resultsDialog = New Dialog
resultsDialog.SetData providerInfo
resultsDialog.Show vbModal
End If
End If
End Sub
Private Sub Form_Load()
Set Locator = CreateObject("WbemScripting.SwbemLocator")
' Set up all the privilege controls, and by default
' hide every one. We will unhide the ones that
' correspond to privileges avaiable to the
' currently logged-in user.
Dim individualPrivilegeSetting As ListBox
For Each individualPrivilegeSetting In PrivilegeSetting
individualPrivilegeSetting.AddItem "Enabled", privilegeEnabled
individualPrivilegeSetting.AddItem "Disabled", privilegeDisabled
individualPrivilegeSetting.AddItem "Not overridden", privilegeUnchanged
individualPrivilegeSetting.ListIndex = privilegeUnchanged
individualPrivilegeSetting.Visible = False
Next
Dim ProcessHandle As Long
Dim ProcessToken As Long
' Get the process token - this will give us the list
' privileges that the logged-in user can enable/disable
ProcessHandle = GetCurrentProcess()
res = OpenProcessToken(ProcessHandle, 8, ProcessToken)
Dim PrivilegeInfo As TOKEN_PRIVILEGES
Dim returnLength As Long
res = GetTokenInformation(ProcessToken, TokenPrivileges, PrivilegeInfo, 3000, returnLength)
' For each privilege available to the user, make visible
' the corresponding control
For i = 0 To (PrivilegeInfo.PrivilegeCount - 1)
Dim luid As luid
luid = PrivilegeInfo.Privileges(i).pLuid
Dim pLuid As LARGE_INTEGER
pLuid.HighPart = luid.HighPart
pLuid.LowPart = luid.LowPart
Dim name As String
Dim lname As Long
res = LookupPrivilegeName(vbNullString, pLuid, name, lname)
If res = 0 Then
name = String(lname + 1, vbNull)
res = LookupPrivilegeName(vbNullString, pLuid, name, lname)
End If
If res <> 0 Then
' A valid privilege
Dim name2 As String
name2 = Left(name, lname)
Select Case name2
Case SE_ASSIGNPRIMARYTOKEN_NAME
PrivilegeSetting(wbemPrivilegePrimaryToken).Visible = True
Case SE_AUDIT_NAME
PrivilegeSetting(wbemPrivilegeAudit).Visible = True
Case SE_BACKUP_NAME
PrivilegeSetting(wbemPrivilegeBackup).Visible = True
Case SE_CHANGE_NOTIFY_NAME
PrivilegeSetting(wbemPrivilegeChangeNotify).Visible = True
Case SE_CREATE_PAGEFILE_NAME
PrivilegeSetting(wbemPrivilegeCreatePagefile).Visible = True
Case SE_CREATE_PERMANENT_NAME
PrivilegeSetting(wbemPrivilegeCreatePermanent).Visible = True
Case SE_CREATE_TOKEN_NAME
PrivilegeSetting(wbemPrivilegeCreateToken).Visible = True
Case SE_DEBUG_NAME
PrivilegeSetting(wbemPrivilegeDebug).Visible = True
Case SE_INC_BASE_PRIORITY_NAME
PrivilegeSetting(wbemPrivilegeIncreaseBasePriority).Visible = True
Case SE_INCREASE_QUOTA_NAME
PrivilegeSetting(wbemPrivilegeIncreaseQuota).Visible = True
Case SE_LOAD_DRIVER_NAME
PrivilegeSetting(wbemPrivilegeLoadDriver).Visible = True
Case SE_LOCK_MEMORY_NAME
PrivilegeSetting(wbemPrivilegeLockMemory).Visible = True
Case SE_MACHINE_ACCOUNT_NAME
PrivilegeSetting(wbemPrivilegeMachineAccount).Visible = True
Case SE_PROF_SINGLE_PROCESS_NAME
PrivilegeSetting(wbemPrivilegeProfileSingleProcess).Visible = True
Case SE_REMOTE_SHUTDOWN_NAME
PrivilegeSetting(wbemPrivilegeRemoteShutdown).Visible = True
Case SE_RESTORE_NAME
PrivilegeSetting(wbemPrivilegeRestore).Visible = True
Case SE_SECURITY_NAME
PrivilegeSetting(wbemPrivilegeSecurity).Visible = True
Case SE_SHUTDOWN_NAME
PrivilegeSetting(wbemPrivilegeShutdown).Visible = True
Case SE_SYSTEM_ENVIRONMENT_NAME
PrivilegeSetting(wbemPrivilegeSystemEnvironment).Visible = True
Case SE_SYSTEM_PROFILE_NAME
PrivilegeSetting(wbemPrivilegeSystemProfile).Visible = True
Case SE_SYSTEMTIME_NAME
PrivilegeSetting(wbemPrivilegeSystemtime).Visible = True
Case SE_TAKE_OWNERSHIP_NAME
PrivilegeSetting(wbemPrivilegeTakeOwnership).Visible = True
Case SE_TCB_NAME
PrivilegeSetting(wbemPrivilegeTcb).Visible = True
End Select
End If
Next i
End Sub
Sub PrintSettings(nvset As SWbemNamedValueSet)
On Error Resume Next
Debug.Print ""
Debug.Print "Enabled Privileges"
Debug.Print "=================="
Debug.Print ""
ea = nvset("EnabledPrivileges").Value
If Err = 0 Then
For i = LBound(ea) To UBound(ea)
Debug.Print " " & ea(i)
Next
Else
Err.Clear
End If
Debug.Print ""
Debug.Print "Disabled Privileges"
Debug.Print "==================="
Debug.Print ""
ea = nvset("DisabledPrivileges").Value
If Err = 0 Then
For i = LBound(ea) To UBound(ea)
Debug.Print " " & ea(i)
Next
Else
Err.Clear
End If
Debug.Print ""
Debug.Print "Detailed Logging"
Debug.Print "================="
Debug.Print ""
ea = nvset("DetailedLogging").Value
If ea Then
Debug.Print " True"
Else
Debug.Print " False"
End If
Debug.Print ""
End Sub
Private Sub MenuDisableAllPrivileges_Click()
For Each individualPrivilegeSetting In PrivilegeSetting
If individualPrivilegeSetting.Visible = True Then
individualPrivilegeSetting.ListIndex = privilegeDisabled
End If
Next
End Sub
Private Sub MenuEnableAllPrivileges_Click()
For Each individualPrivilegeSetting In PrivilegeSetting
If individualPrivilegeSetting.Visible = True Then
individualPrivilegeSetting.ListIndex = privilegeEnabled
End If
Next
End Sub
Private Sub MenuExit_Click()
Unload Me
End Sub
Private Sub MenuHelpAbout_Click()
Set AboutDialog = New frmAbout
frmAbout.Show vbModal
End Sub
Private Sub MenuProviderLogging_Click()
MenuProviderLogging.Checked = Not MenuProviderLogging.Checked
End Sub
Private Sub MenuResetPrivileges_Click()
For Each individualPrivilegeSetting In PrivilegeSetting
If individualPrivilegeSetting.Visible = True Then
individualPrivilegeSetting.ListIndex = privilegeUnchanged
End If
Next
End Sub
|
'-------------------------------------------------------------------
' Microsoft Windows
'
' Copyright (C) Microsoft Corporation, 1997 - 1999
'
' File: dskquota.vbs
'
' This file is a VBScript for testing the scripting features of
' the Windows 2000 disk quota interface code. It also serves as
' an example of how to properly use the disk quota objects
' with scripting.
'
' It's designed to accept /<cmd>=<value> arguments so that all
' of the scripting features can be tested using the same utility.
' It however wasn't written to be very tolerant of bad input.
' For instance, a command must be preceded by a '/' character.
' An '=' character must separate the command and value.
' No spaces are tolerated between the '/', <cmd>, '=' and <value>.
'
' This is valid:
'
' dskquota /volume=e: /showuser=redmond\brianau
'
' This is not:
'
' dskquota /volume= e: /showuser = redmond\brianau
'
' Multiple commands can appear in the same invocation. The following
' command will display quota information for both the volume and a
' user.
'
' dskquota /volume=e: /show /showuser=redmond\brianau
'
' Here's a summary of the available commands:
'
' /VOLUME=<volume id>
'
' This command is required. <volume id> identifies the volume.
' i.e. "E:"
'
' /STATE=<DISABLE | TRACK | ENFORCE>
'
' Enables or disables quotas on the volume.
' DISABLE disables quotas.
' TRACK enables quotas but doesn't enforce quota limits.
' ENFORCE enables quotas and enforces quota limits.
'
' /NAMERES=<NONE | SYNC | ASYNC>
'
' Sets the user-name synchronization mode for the current
' invocation only. Since Async name resolution is meaningless
' for a command-line script, this command use most useful for
' testing the ability to set the name resolution mode.
' The following command could be used to verify proper operation:
'
' dskquota /volume=e: /nameres=sync /show
'
' The output of /SHOW would be used to verify the correct resolution
' setting.
'
' NONE means that a name must be cached to be returned.
' SYNC means that any function returning a non-cached name
' will block until that name is resolved. This is the
' default.
' ASYNC means that any function returning a non-cached name
' will return immediately. The name resolution connection
' point is used to obtain the name asynchronously once
' it has been resolved. This has no purpose in a cmd line
' script.
'
' /DEFLIMIT=<bytes>
'
' Sets the default quota limit on the volume.
'
' /DEFWARNING=<bytes>
'
' Sets the default quota warning level on the volume.
'
' /SHOW
'
' Displays a summary of volume-specific quota information.
'
' /SHOWUSER=<user logon name>
'
' Displays a summary of user-specific quota information if there's
' a record for the user in the volume's quota file. Specify '*'
' for <user logon name> to enumerate all user quota records.
'
' dskquota /volume=e: /showuser=redmond\brianau
' dskquota /volume=e: /showuser=*
'
' /LOGLIMIT=<YES | NO>
'
' Enables/disables system logging of users who exceed their
' assigned quota limit.
'
' /LOGWARNING=<YES | NO>
'
' Enables/disables system logging of users who exceed their
' assigned quota warning threshold.
'
' /ADDUSER=<user logon name>
'
' Adds a new user record to the volume's quota file. The new record
' has assigned to it the default limit and warning threshold for
' the volume.
'
' dskquota /volume=e: /adduser=redmond\brianau
'
' /DELUSER=<user logon name>
'
' Removes a user's quota record from the volume's quota file.
' In actuality, this merely marks the record for deletion. Actual
' deletion occurs later when NTFS rebuilds the volume's quota info.
'
' /USER=<user logon name>
'
' Specifies the user record associated with a /LIMIT or /WARNING
' command.
'
' dskquota /volume=e: /user=redmond\brianau /limit=1048576
'
' /LIMIT=<bytes>
'
' Sets the quota limit for a user's quota record. Must be accompanied
' by the /USER command.
'
' /WARNING=<bytes>
'
' Sets the quota warning level for a user's quota record. Must be
' accompanied by the /USER command.
'
'-------------------------------------------------------------------
'
' Name Resolution type names.
'
DIM rgstrNameRes(3)
rgstrNameRes(0) = "NONE" ' No name resolution.
rgstrNameRes(1) = "SYNC" ' Synchronous name resolution.
rgstrNameRes(2) = "ASYNC" ' Asynchronous name resolution.
'
' Volume quota state names.
'
DIM rgstrStateNames(3)
rgstrStateNames(0) = "DISABLE" ' Quotas are disabled.
rgstrStateNames(1) = "TRACK" ' Enabled but not enforced.
rgstrStateNames(2) = "ENFORCE" ' Enabled AND enforced.
'
' Generic YES/NO name strings.
'
DIM rgstrYesNo(2)
rgstrYesNo(0) = "NO"
rgstrYesNo(1) = "YES"
'
' Define an array index for each cmdline argument.
'
iArgVolume = 0 ' /VOLUME=<volumeid>
iArgState = 1 ' /STATE=<DISABLE | TRACK | ENFORCE>
iArgNameRes = 2 ' /NAMERES=<NONE | SYNC | ASYNC>
iArgDefLimit = 3 ' /DEFLIMIT=<bytes>
iArgDefWarning = 4 ' /DEFWARNING=<bytes>
iArgShow = 5 ' /SHOW
iArgLogLimit = 6 ' /LOGLIMIT=<YES | NO>
iArgLogWarning = 7 ' /LOGWARNING=<YES | NO>
iArgShowUser = 8 ' /SHOWUSER=<user logon name>
iArgAddUser = 9 ' /ADDUSER=<user logon name>
iArgDelUser = 10 ' /DELUSER=<user logon name>
iArgUser = 11 ' /USER=<user logon name>
iArgLimit = 12 ' /LIMIT=<bytes>
iArgWarning = 13 ' /WARNING=<bytes>
'
' Define an array of argument names.
'
DIM rgstrArgNames(14)
rgstrArgNames(0) = "VOLUME"
rgstrArgNames(1) = "STATE"
rgstrArgNames(2) = "NAMERES"
rgstrArgNames(3) = "DEFLIMIT"
rgstrArgNames(4) = "DEFWARNING"
rgstrArgNames(5) = "SHOW"
rgstrArgNames(6) = "LOGLIMIT"
rgstrArgNames(7) = "LOGWARNING"
rgstrArgNames(8) = "SHOWUSER"
rgstrArgNames(9) = "ADDUSER"
rgstrArgNames(10) = "DELUSER"
rgstrArgNames(11) = "USER"
rgstrArgNames(12) = "LIMIT"
rgstrArgNames(13) = "WARNING"
'
' Define an array to hold argument values.
' The length must be the same as the length of
' rgstrArgNames.
'
DIM rgstrArgValues(14)
'-----------------------------------------------------------------
' Extract an argument name from an argument string.
'
' "/STATE=DISABLE" -> "STATE"
'
PRIVATE FUNCTION ArgNameFromArg(strArg)
s = strArg
iSlash = InStr(s, "/")
IF 0 <> iSlash THEN
s = MID(s, iSlash+1)
END IF
iEqual = INSTR(s, "=")
IF 0 <> iEqual THEN
s = LEFT(s, iEqual-1)
END IF
ArgNameFromArg = UCASE(s)
END FUNCTION
'-----------------------------------------------------------------
' Extract an argument value from an argument string.
'
' "/STATE=DISABLE" -> "DISABLE"
'
PRIVATE FUNCTION ArgValueFromArg(strArg)
iEqual = INSTR(strArg, "=")
ArgValueFromArg = MID(strArg, iEqual+1)
END FUNCTION
'-----------------------------------------------------------------
' Determine the index into the global arrays for
' a given argument string.
'
' "STATE" -> 1
' "DEFLIMIT" -> 3
'
PRIVATE FUNCTION ArgNameToIndex(strArgName)
ArgNameToIndex = -1
n = UBOUND(rgstrArgNames) - LBOUND(rgstrArgNames)
FOR i = 0 TO n
IF strArgName = rgstrArgNames(i) THEN
ArgNameToIndex = i
EXIT FUNCTION
END IF
NEXT
END FUNCTION
'-----------------------------------------------------------------
' Convert a state name into a state code for passing to
' the QuotaState property.
'
' "DISABLE" -> 0
'
PRIVATE FUNCTION StateFromStateName(strName)
StateFromStateName = -1
n = UBOUND(rgstrStateNames) - LBOUND(rgstrStateNames)
FOR i = 0 TO n-1
IF rgstrStateNames(i) = UCASE(strName) THEN
StateFromStateName = i
EXIT FUNCTION
END IF
NEXT
END FUNCTION
'-----------------------------------------------------------------
' Convert a name resolution name into a code for passing to
' the UserNameResolution property.
'
' "SYNC" -> 1
'
PRIVATE FUNCTION NameResTypeFromTypeName(strName)
NameResTypeFromTypeName = -1
n = UBOUND(rgstrNameRes) - LBOUND(rgstrNameRes)
FOR i = 0 TO n-1
IF rgstrNameRes(i) = UCASE(strName) THEN
NameResTypeFromTypeName = i
EXIT FUNCTION
END IF
NEXT
END FUNCTION
'-----------------------------------------------------------------
' Process the arguments on the cmd line, storing the argument
' values in the appropriate slot in rgstrArgValues[]
'
PRIVATE FUNCTION ProcessArgs
SET args = Wscript.Arguments
n = args.COUNT
FOR i = 0 TO n-1
name = ArgNameFromArg(args(i))
iArg = ArgNameToIndex(name)
IF -1 <> iArg THEN
rgstrArgValues(iArg) = UCASE(ArgValueFromArg(args(i)))
IF iArg = iArgShow THEN
rgstrArgValues(iArg) = "SHOW"
END IF
ELSE
Wscript.Echo "Invalid option specified [", name, "]"
END IF
NEXT
ProcessArgs = n
END FUNCTION
'-----------------------------------------------------------------
' Determine if a given argument was present on the cmd line.
'
PRIVATE FUNCTION ArgIsPresent(iArg)
ArgIsPresent = (0 < LEN(rgstrArgValues(iArg)))
END FUNCTION
'-----------------------------------------------------------------
' Display quota information specific to a volume.
'
PRIVATE SUB ShowVolumeInfo(objDQC)
Wscript.Echo ""
Wscript.Echo "Volume............: ", rgstrArgValues(iArgVolume)
Wscript.Echo "State.............: ", rgstrStateNames(objDQC.QuotaState)
Wscript.Echo "Incomplete........: ", CSTR(objDQC.QuotaFileIncomplete)
Wscript.Echo "Rebuilding........: ", CSTR(objDQC.QuotaFileRebuilding)
Wscript.Echo "Name resolution...: ", rgstrNameRes(objDQC.UserNameResolution)
Wscript.Echo "Default Limit.....: ", objDQC.DefaultQuotaLimitText, "(", objDQC.DefaultQuotaLimit, "bytes)"
Wscript.Echo "Default Warning...: ", objDQC.DefaultQuotaThresholdText, "(", objDQC.DefaultQuotaThreshold, "bytes)"
Wscript.Echo "Log limit.........: ", CSTR(objDQC.LogQuotaLimit)
Wscript.Echo "Log Warning.......: ", CSTR(objDQC.LogQuotaThreshold)
Wscript.Echo ""
END SUB
'-----------------------------------------------------------------
' Display quota information specific to a single user.
'
PRIVATE SUB ShowUserInfo(objUser)
Wscript.Echo "Name..............: ", objUser.LogonName
Wscript.Echo "Limit.............: ", objUser.QuotaLimitText, "(",objUser.QuotaLimit, "bytes)"
Wscript.Echo "Warning...........: ", objUser.QuotaThresholdText, "(",objUser.QuotaThreshold, "bytes)"
Wscript.Echo ""
END SUB
'-----------------------------------------------------------------
' Do the work according to what argument values are in
' rgstrArgValues[].
'
PRIVATE SUB Main
DIM objDQC
DIM objUser
'
' User must enter volume ID.
' If none specified, display error msg and exit.
'
IF NOT ArgIsPresent(iArgVolume) THEN
Wscript.Echo "Must provide volume ID. (i.e. '/VOLUME=C:' )"
EXIT SUB
END IF
'
' Create the disk quota control object.
'
SET objDQC = Wscript.CreateObject("Microsoft.DiskQuota.1")
objDQC.Initialize rgstrArgValues(iArgVolume), 1
'
' Set the quota state.
'
IF ArgIsPresent(iArgState) THEN
iState = StateFromStateName(rgstrArgValues(iArgState))
IF (-1 < iState) THEN
objDQC.QuotaState = iState
ELSE
Wscript.Echo "Invalid quota state (" & rgstrArgValues(iArgState) & ")"
END IF
END IF
'
' Set the name resolution type. We won't use this setting here
' but set it to verify we can.
'
IF ArgIsPresent(iArgNameRes) THEN
iResType = NameResTypeFromTypeName(rgstrArgValues(iArgNameRes))
IF (-1 < iResType) THEN
objDQC.UserNameResolution = iResType
ELSE
Wscript.Echo "Invalid name resolution type (" & rgstrArgValues(iArgNameRes) & ")"
END IF
END IF
'
' Set the limit and threshold.
'
IF ArgIsPresent(iArgDefLimit) THEN
objDQC.DefaultQuotaLimit = rgstrArgValues(iArgDefLimit)
END IF
IF ArgIsPresent(iArgDefWarning) THEN
objDQC.DefaultQuotaThreshold = rgstrArgValues(iArgDefWarning)
END IF
'
' Set the logging flags.
'
IF ArgIsPresent(iArgLogLimit) THEN
s = rgstrArgValues(iArgLogLimit)
IF UCASE(s) = "NO" THEN
objDQC.LogQuotaLimit = 0
ELSE
objDQC.LogQuotaLimit = 1
END IF
END IF
IF ArgIsPresent(iArgLogWarning) THEN
s = rgstrArgValues(iArgLogWarning)
IF UCASE(s) = "NO" THEN
objDQC.LogQuotaThreshold = 0
ELSE
objDQC.LogQuotaThreshold = 1
END IF
END IF
'
' Show volume information.
'
IF ArgIsPresent(iArgShow) THEN
ShowVolumeInfo(objDQC)
END IF
'
' Show user information.
'
IF ArgIsPresent(iArgShowUser) THEN
IF rgstrArgValues(iArgShowUser) = "*" THEN
'
' Enumerate all users on the volume.
'
FOR EACH objUser in objDQC
ShowUserInfo(objUser)
NEXT
ELSE
'
' Find and show info for just one user.
'
SET objUser = objDQC.FindUser(rgstrArgValues(iArgShowUser))
IF TYPENAME(objUser) <> "" THEN
ShowUserInfo(objUser)
END IF
END IF
SET objUser = NOTHING
END IF
'
' Delete user.
'
IF ArgIsPresent(iArgDelUser) THEN
SET objUser = objDQC.FindUser(rgstrArgValues(iArgDelUser))
IF TYPENAME(objUser) <> "" THEN
objDQC.DeleteUser(objUser)
Wscript.Echo "Quota record for ", rgstrArgValues(iArgDelUser), "deleted from volume."
SET objUser = NOTHING
END IF
END IF
'
' Set user warning level and/or limit.
'
IF ArgIsPresent(iArgLimit) OR ArgIsPresent(iArgWarning) THEN
IF NOT ArgIsPresent(iArgUser) THEN
Wscript.Echo "Must provide user logon name. (i.e. '/USER=REDMOND\mmouse' )"
EXIT SUB
END IF
SET objUser = objDQC.FindUser(rgstrArgValues(iArgUser))
IF TYPENAME(objUser) <> "" THEN
IF ArgIsPresent(iArgLimit) THEN
objUser.QuotaLimit = rgstrArgValues(iArgLimit)
END IF
IF ArgIsPresent(iArgWarning) THEN
objUser.QuotaThreshold = rgstrArgValues(iArgWarning)
END IF
END IF
SET objUser = NOTHING
END IF
'
' Add new user quota record.
'
IF ArgIsPresent(iArgAddUser) THEN
SET objUser = objDQC.AddUser(rgstrArgValues(iArgAddUser))
IF TYPENAME(objUser) <> "" THEN
Wscript.Echo "Quota record for ", rgstrArgValues(iArgAddUser), "added to volume."
END IF
SET objUser = NOTHING
END IF
SET objDQC = NOTHING
END SUB
'-----------------------------------------------------------------
' MAIN
'
ProcessArgs ' Parse all cmd line args.
Main ' Do the work.
|
<filename>Task/Leap-year/Visual-Basic/leap-year-1.vb<gh_stars>1-10
Public Function IsLeapYear1(ByVal theYear As Integer) As Boolean
'this function utilizes documented behaviour of the built-in DateSerial function
IsLeapYear1 = (VBA.Day(VBA.DateSerial(theYear, 2, 29)) = 29)
End Function
Public Function IsLeapYear2(ByVal theYear As Integer) As Boolean
'this function uses the well-known formula
IsLeapYear2 = IIf(theYear Mod 100 = 0, theYear Mod 400 = 0, theYear Mod 4 = 0)
End Function
|
<reponame>npocmaka/Windows-Server-2003
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "COMCTL32.OCX"
Begin VB.Form DeviceListWindow
Caption = "Fax Devices"
ClientHeight = 4830
ClientLeft = 60
ClientTop = 345
ClientWidth = 7575
Icon = "devlist.frx":0000
LinkTopic = "Form2"
MDIChild = -1 'True
ScaleHeight = 4830
ScaleWidth = 7575
Begin ComctlLib.ListView DeviceList
Height = 4575
Left = 120
TabIndex = 0
Top = 120
Width = 7335
_ExtentX = 12938
_ExtentY = 8070
View = 3
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 327680
ForeColor = -2147483630
BackColor = -2147483633
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "<NAME>"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
MouseIcon = "devlist.frx":0442
NumItems = 0
End
End
Attribute VB_Name = "DeviceListWindow"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub DeviceList_DblClick()
Set Port = Ports.Item(DeviceList.SelectedItem.Index)
DeviceWindow.MyInit
DeviceWindow.Show
End Sub
Private Sub Form_Load()
On Error Resume Next
Create_ColumnHeaders
Err.Clear
Set Ports = Fax.GetPorts
Dim itmX As ListItem
If Err.Number = 0 Then
For i = 1 To Ports.Count
Set Port = Ports.Item(i)
Set itmX = DeviceList.ListItems.Add(, , CStr(Port.DeviceId))
itmX.SubItems(1) = Port.Name
Next i
Else
Msg = "The fax server could not enumerate the ports"
MsgBox Msg, , "Error"
Err.Clear
Unload DeviceListWindow
End If
End Sub
Private Sub Form_Resize()
DeviceList.Left = DeviceListWindow.ScaleLeft
DeviceList.Top = DeviceListWindow.ScaleTop
DeviceList.Width = DeviceListWindow.ScaleWidth
DeviceList.Height = DeviceListWindow.ScaleHeight
Create_ColumnHeaders
End Sub
Private Sub Create_ColumnHeaders()
DeviceList.ColumnHeaders.Clear
DeviceList.ColumnHeaders.Add , , "DeviceId", 1000
DeviceList.ColumnHeaders.Add , , "Name", DeviceList.Width - 1700
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData<filename>Task/Order-two-numerical-lists/VBScript/order-two-numerical-lists.vb
Function order_list(arr1,arr2)
order_list = "FAIL"
n1 = UBound(arr1): n2 = UBound(arr2)
n = 0 : p = 0
If n1 > n2 Then
max = n2
Else
max = n1
End If
For i = 0 To max
If arr1(i) > arr2(i) Then
n = n + 1
ElseIf arr1(i) = arr2(i) Then
p = p + 1
End If
Next
If (n1 < n2 And n = 0) Or _
(n1 = n2 And n = 0 And p - 1 <> n1) Or _
(n1 > n2 And n = 0 And p = n2) Then
order_list = "PASS"
End If
End Function
WScript.StdOut.WriteLine order_list(Array(-1),Array(0))
WScript.StdOut.WriteLine order_list(Array(0),Array(0))
WScript.StdOut.WriteLine order_list(Array(0),Array(-1))
WScript.StdOut.WriteLine order_list(Array(0),Array(0,-1))
WScript.StdOut.WriteLine order_list(Array(0),Array(0,0))
WScript.StdOut.WriteLine order_list(Array(0),Array(0,1))
WScript.StdOut.WriteLine order_list(Array(0,-1),Array(0))
WScript.StdOut.WriteLine order_list(Array(0,0),Array(0))
WScript.StdOut.WriteLine order_list(Array(0,0),Array(1))
WScript.StdOut.WriteLine order_list(Array(1,2,1,3,2),Array(1,2,0,4,4,0,0,0))
|
<reponame>LaudateCorpus1/RosettaCodeData<filename>Task/Verify-distribution-uniformity-Chi-squared-test/VBA/verify-distribution-uniformity-chi-squared-test.vba
Private Function Test4DiscreteUniformDistribution(ObservationFrequencies() As Variant, Significance As Single) As Boolean
'Returns true if the observed frequencies pass the Pearson Chi-squared test at the required significance level.
Dim Total As Long, Ei As Long, i As Integer
Dim ChiSquared As Double, DegreesOfFreedom As Integer, p_value As Double
Debug.Print "[1] ""Data set:"" ";
For i = LBound(ObservationFrequencies) To UBound(ObservationFrequencies)
Total = Total + ObservationFrequencies(i)
Debug.Print ObservationFrequencies(i); " ";
Next i
DegreesOfFreedom = UBound(ObservationFrequencies) - LBound(ObservationFrequencies)
'This is exactly the number of different categories minus 1
Ei = Total / (DegreesOfFreedom + 1)
For i = LBound(ObservationFrequencies) To UBound(ObservationFrequencies)
ChiSquared = ChiSquared + (ObservationFrequencies(i) - Ei) ^ 2 / Ei
Next i
p_value = 1 - WorksheetFunction.ChiSq_Dist(ChiSquared, DegreesOfFreedom, True)
Debug.Print
Debug.Print " Chi-squared test for given frequencies"
Debug.Print "X-squared ="; ChiSquared; ", ";
Debug.Print "df ="; DegreesOfFreedom; ", ";
Debug.Print "p-value = "; Format(p_value, "0.0000")
Test4DiscreteUniformDistribution = p_value > Significance
End Function
Public Sub test()
Dim O() As Variant
O = [{199809,200665,199607,200270,199649}]
Debug.Print "[1] ""Uniform? "; Test4DiscreteUniformDistribution(O, 0.05); """"
O = [{522573,244456,139979,71531,21461}]
Debug.Print "[1] ""Uniform? "; Test4DiscreteUniformDistribution(O, 0.05); """"
End Sub
|
<reponame>npocmaka/Windows-Server-2003
set comp=getobject("umi:///WinNT/computer=alanbos4")
set user = comp.GetInstance_ ("user=guest")
if(user.dialinprivilege = True) then
wscript.echo "Dialin Privilege: True"
else
wscript.echo "Dialin Privilege: False"
end if
callbackId = user.GetRasCallBack
if callbackId=1 then
WScript.Echo "Callback ID: None"
elseif callbackId=2 then
WScript.Echo "Callback ID: Set by admin"
elseif callbackId=4 then
WScript.Echo "Callback ID: Set by caller"
else
WScript.Echo "Callback ID: Unknown"
end if
phoneNum = user.GetRasPhoneNumber
WScript.Echo "Phone #:", phoneNum
|
<filename>Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-2.vb<gh_stars>1-10
dim m1
set m1 = new markovparser
m1.ruleset = "# This rules file is extracted from Wikipedia:" & vbNewLine & _
"# http://en.wikipedia.org/wiki/Markov_Algorithm" & vbNewLine & _
"A -> apple" & vbNewLine & _
"B -> bag" & vbNewLine & _
"S -> shop" & vbNewLine & _
"T -> the" & vbNewLine & _
"the shop -> my brother" & vbNewLine & _
"a never used -> .terminating rule"
wscript.echo m1.apply( "I bought a B of As from T S.")
dim m2
set m2 = new markovparser
m2.ruleset = replace( "# Slightly modified from the rules on Wikipedia\nA -> apple\nB -> bag\nS -> .shop\nT -> the\nthe shop -> my brother\na never used -> .terminating rule", "\n", vbNewLine )
'~ m1.dump
wscript.echo m2.apply( "I bought a B of As from T S.")
dim m3
set m3 = new markovparser
m3.ruleset = replace("# BNF Syntax testing rules\nA -> apple\nWWWW -> with\nBgage -> ->.*\nB -> bag" & vbNewLine & _
"->.* -> money\nW -> WW\nS -> .shop\nT -> the\nthe shop -> my brother\na never used -> .terminating rule", "\n", vbNewLine )
wscript.echo m3.apply("I bought a B of As W my Bgage from T S.")
set m4 = new markovparser
m4.ruleset = "### Unary Multiplication Engine, for testing Markov Algorithm implementations" & vbNewLine & _
"### By Donal Fellows." & vbNewLine & _
"# Unary addition engine" & vbNewLine & _
"_+1 -> _1+" & vbNewLine & _
"1+1 -> 11+" & vbNewLine & _
"# Pass for converting from the splitting of multiplication into ordinary" & vbNewLine & _
"# addition" & vbNewLine & _
"1! -> !1" & vbNewLine & _
",! -> !+" & vbNewLine & _
"_! -> _" & vbNewLine & _
"# Unary multiplication by duplicating left side, right side times" & vbNewLine & _
"1*1 -> x,@y" & vbNewLine & _
"1x -> xX" & vbNewLine & _
"X, -> 1,1" & vbNewLine & _
"X1 -> 1X" & vbNewLine & _
"_x -> _X" & vbNewLine & _
",x -> ,X" & vbNewLine & _
"y1 -> 1y" & vbNewLine & _
"y_ -> _" & vbNewLine & _
"# Next phase of applying" & vbNewLine & _
"1@1 -> x,@y" & vbNewLine & _
"1@_ -> @_" & vbNewLine & _
",@_ -> !_" & vbNewLine & _
"++ -> +" & vbNewLine & _
"# Termination cleanup for addition" & vbNewLine & _
"_1 -> 1" & vbNewLine & _
"1+_ -> 1" & vbNewLine & _
"_+_ -> "
'~ m4.dump
wscript.echo m4.apply( "_1111*11111_")
set fso = createobject("scripting.filesystemobject")
set m5 = new markovparser
m5.ruleset = fso.opentextfile("busybeaver.tur").readall
wscript.echo m5.apply("000000A000000")
|
<filename>admin/activec/test/script/refreshitem.vbs<gh_stars>10-100
'
L_Welcome_MsgBox_Message_Text = "This script demonstrates how to refresh snapin items from scriptable objects."
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample"
Call Welcome()
' ********************************************************************************
Dim mmc
Dim doc
Dim snapins
Dim frame
Dim views
Dim view
Dim scopenamespace
Dim rootnode
Dim Nodes
Dim scopenode
Dim SnapNode
Dim ResultItem
Dim MySnapin
' Following are snapin exposed objects.
Dim ScopeNodeObject
Dim ResultItemObject
'get the various objects we'll need
Set mmc = wscript.CreateObject("MMC20.Application")
Set frame = mmc.Frame
Set doc = mmc.Document
Set namespace = doc.ScopeNamespace
Set rootnode = namespace.GetRoot
Set views = doc.views
Set view = views(1)
Set snapins = doc.snapins
snapins.Add "{975797FC-4E2A-11D0-B702-00C04FD8DBF7}" ' eventlog snapin
snapins.Add "{58221c66-ea27-11cf-adcf-00aa00a80033}" ' the services snap-in
' Select the root of "EventViewer" snapin.
Set rootnode = namespace.GetRoot
Set SnapNode1 = namespace.GetChild(rootnode)
view.ActiveScopeNode = SnapNode1
' Get the "Application Log" node and refresh it (Temp selection).
Set SnapNode1 = namespace.GetChild(SnapNode1)
view.RefreshScopeNode SnapNode1
' Refresh "SystemLog" node in ListView
view.Select view.ListItems.Item(1)
view.RefreshSelection
' Now select "Application Log" node and refresh it.
view.ActiveScopeNode = SnapNode1
view.RefreshScopeNode
' Select the 5th log event and refresh it.
view.Select view.ListItems.Item(4)
view.RefreshSelection
' Select the services snapin root node.
Set SnapNode1 = namespace.GetChild(rootnode)
Set SnapNode1 = namespace.GetNext(SnapNode1)
view.ActiveScopeNode = SnapNode1
' Refresh service 2
view.Select view.ListItems.Item(5)
view.RefreshSelection
Set mmc = Nothing
' ********************************************************************************
' *
' * Welcome
' *
Sub Welcome()
Dim intDoIt
intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
vbOKCancel + vbInformation, _
L_Welcome_MsgBox_Title_Text )
If intDoIt = vbCancel Then
WScript.Quit
End If
End Sub
|
Function dns_query(url,ver)
Set r = New RegExp
r.Pattern = "Pinging.+?\[(.+?)\].+"
Set objshell = CreateObject("WScript.Shell")
Set objexec = objshell.Exec("%comspec% /c " & "ping -" & ver & " " & url)
WScript.StdOut.WriteLine "URL: " & url
Do Until objexec.StdOut.AtEndOfStream
line = objexec.StdOut.ReadLine
If r.Test(line) Then
WScript.StdOut.WriteLine "IP Version " &_
ver & ": " & r.Replace(line,"$1")
End If
Loop
End Function
Call dns_query(WScript.Arguments(0),WScript.Arguments(1))
|
<gh_stars>1-10
Function TopNTail(s,mode)
Select Case mode
Case "top"
TopNTail = Mid(s,2,Len(s)-1)
Case "tail"
TopNTail = Mid(s,1,Len(s)-1)
Case "both"
TopNTail = Mid(s,2,Len(s)-2)
End Select
End Function
WScript.Echo "Top: UPRAISERS = " & TopNTail("UPRAISERS","top")
WScript.Echo "Tail: UPRAISERS = " & TopNTail("UPRAISERS","tail")
WScript.Echo "Both: UPRAISERS = " & TopNTail("UPRAISERS","both")
|
Sub Rosetta_24game()
Dim Digit(4) As Integer, i As Integer, iDigitCount As Integer
Dim stUserExpression As String
Dim stFailMessage As String, stFailDigits As String
Dim bValidExpression As Boolean, bValidDigits As Boolean, bValidChars As Boolean
Dim vResult As Variant, vTryAgain As Variant, vSameDigits As Variant
' Generate 4 random digits
GenerateNewDigits:
For i = 1 To 4
Digit(i) = [randbetween(1,9)]
Next i
' Get user expression
GetUserExpression:
bValidExpression = True
stFailMessage = ""
stFailDigits = ""
stUserExpression = InputBox("Enter a mathematical expression which results in 24, using the following digits: " & _
Digit(1) & ", " & Digit(2) & ", " & Digit(3) & " and " & Digit(4), "Rosetta Code | 24 Game")
' Check each digit is included in user expression
bValidDigits = True
stFailDigits = ""
For i = 1 To 4
If InStr(stUserExpression, Digit(i)) = 0 Then
bValidDigits = False
stFailDigits = stFailDigits & " " & Digit(i)
End If
Next i
If bValidDigits = False Then
bValidExpression = False
stFailMessage = "Your expression excluded the following required digits: " & stFailDigits & vbCr & vbCr
End If
' Check each character of user expression is a valid character type
bValidDigits = True
stFailDigits = ""
For i = 1 To Len(stUserExpression)
If InStr("0123456789+-*/()", Mid(stUserExpression, i, 1)) = 0 Then
bValidDigits = False
stFailDigits = stFailDigits & " " & Mid(stUserExpression, i, 1)
End If
Next i
If bValidDigits = False Then
bValidExpression = False
stFailMessage = stFailMessage & "Your expression contained invalid characters:" & stFailDigits & vbCr & vbCr
End If
' Check no disallowed integers entered
bValidDigits = True
stFailDigits = ""
iDigitCount = 0
For i = 1 To Len(stUserExpression)
If Not InStr("0123456789", Mid(stUserExpression, i, 1)) = 0 Then
iDigitCount = iDigitCount + 1
If IsError(Application.Match(--(Mid(stUserExpression, i, 1)), Digit, False)) Then
bValidDigits = False
stFailDigits = stFailDigits & " " & Mid(stUserExpression, i, 1)
End If
End If
Next i
If iDigitCount > 4 Then
bValidExpression = False
stFailMessage = stFailMessage & "Your expression contained more than 4 digits" & vbCr & vbCr
End If
If iDigitCount < 4 Then
bValidExpression = False
stFailMessage = stFailMessage & "Your expression contained less than 4 digits" & vbCr & vbCr
End If
If bValidDigits = False Then
bValidExpression = False
stFailMessage = stFailMessage & "Your expression contained invalid digits:" & stFailDigits & vbCr & vbCr
End If
' Check no double digit numbers entered
bValidDigits = True
stFailDigits = ""
For i = 11 To 99
If Not InStr(stUserExpression, i) = 0 Then
bValidDigits = False
stFailDigits = stFailDigits & " " & i
End If
Next i
If bValidDigits = False Then
bValidExpression = False
stFailMessage = stFailMessage & "Your expression contained invalid numbers:" & stFailDigits & vbCr & vbCr
End If
' Check result of user expression
On Error GoTo EvalFail
vResult = Evaluate(stUserExpression)
If Not vResult = 24 Then
bValidExpression = False
stFailMessage = stFailMessage & "Your expression did not result in 24. It returned: " & vResult
End If
' Return results
If bValidExpression = False Then
vTryAgain = MsgBox(stFailMessage & vbCr & vbCr & "Would you like to try again?", vbCritical + vbRetryCancel, "Rosetta Code | 24 Game | FAILED")
If vTryAgain = vbRetry Then
vSameDigits = MsgBox("Do you want to use the same numbers?", vbQuestion + vbYesNo, "Rosetta Code | 24 Game | RETRY")
If vSameDigits = vbYes Then
GoTo GetUserExpression
Else
GoTo GenerateNewDigits
End If
End If
Else
vTryAgain = MsgBox("You entered: " & stUserExpression & vbCr & vbCr & "which resulted in: " & vResult, _
vbInformation + vbRetryCancel, "Rosetta Code | 24 Game | SUCCESS")
If vTryAgain = vbRetry Then
GoTo GenerateNewDigits
End If
End If
Exit Sub
EvalFail:
bValidExpression = False
vResult = Err.Description
Resume
End Sub
|
Public Class ComponentPropertiesForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents PanelHeader As System.Windows.Forms.Panel
Friend WithEvents Panel2 As System.Windows.Forms.Panel
Friend WithEvents Selected As System.Windows.Forms.CheckBox
Friend WithEvents Excluded As System.Windows.Forms.CheckBox
Friend WithEvents Uncooked As System.Windows.Forms.CheckBox
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents ScriptText As System.Windows.Forms.RichTextBox
Friend WithEvents ScriptLabel As System.Windows.Forms.Label
Friend WithEvents Tabs As System.Windows.Forms.TabControl
Friend WithEvents ScriptTab As System.Windows.Forms.TabPage
Friend WithEvents DependerTab As System.Windows.Forms.TabPage
Friend WithEvents Panel3 As System.Windows.Forms.Panel
Friend WithEvents DepLabel As System.Windows.Forms.Label
Friend WithEvents DepList As System.Windows.Forms.ListBox
Friend WithEvents PrototypeList As System.Windows.Forms.ComboBox
Friend WithEvents VIGUID As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents VSGUID As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
'Required by the Windows Form Designer
Private components As System.ComponentModel.Container
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(ComponentPropertiesForm))
Me.DependerTab = New System.Windows.Forms.TabPage()
Me.Panel3 = New System.Windows.Forms.Panel()
Me.DepList = New System.Windows.Forms.ListBox()
Me.DepLabel = New System.Windows.Forms.Label()
Me.PanelHeader = New System.Windows.Forms.Panel()
Me.PrototypeList = New System.Windows.Forms.ComboBox()
Me.Uncooked = New System.Windows.Forms.CheckBox()
Me.Excluded = New System.Windows.Forms.CheckBox()
Me.Selected = New System.Windows.Forms.CheckBox()
Me.ScriptText = New System.Windows.Forms.RichTextBox()
Me.Tabs = New System.Windows.Forms.TabControl()
Me.ScriptTab = New System.Windows.Forms.TabPage()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.ScriptLabel = New System.Windows.Forms.Label()
Me.Panel2 = New System.Windows.Forms.Panel()
Me.VIGUID = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.VSGUID = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.DependerTab.SuspendLayout()
Me.Panel3.SuspendLayout()
Me.PanelHeader.SuspendLayout()
Me.Tabs.SuspendLayout()
Me.ScriptTab.SuspendLayout()
Me.Panel1.SuspendLayout()
Me.Panel2.SuspendLayout()
Me.SuspendLayout()
'
'DependerTab
'
Me.DependerTab.Controls.AddRange(New System.Windows.Forms.Control() {Me.Panel3, Me.DepLabel})
Me.DependerTab.DockPadding.All = 2
Me.DependerTab.Location = New System.Drawing.Point(4, 22)
Me.DependerTab.Name = "DependerTab"
Me.DependerTab.Size = New System.Drawing.Size(304, 144)
Me.DependerTab.TabIndex = 0
Me.DependerTab.Text = "Dependers"
'
'Panel3
'
Me.Panel3.Controls.AddRange(New System.Windows.Forms.Control() {Me.DepList})
Me.Panel3.Dock = System.Windows.Forms.DockStyle.Fill
Me.Panel3.Location = New System.Drawing.Point(2, 25)
Me.Panel3.Name = "Panel3"
Me.Panel3.Size = New System.Drawing.Size(300, 117)
Me.Panel3.TabIndex = 2
'
'DepList
'
Me.DepList.Dock = System.Windows.Forms.DockStyle.Fill
Me.DepList.Name = "DepList"
Me.DepList.Size = New System.Drawing.Size(300, 108)
Me.DepList.TabIndex = 0
'
'DepLabel
'
Me.DepLabel.Dock = System.Windows.Forms.DockStyle.Top
Me.DepLabel.Location = New System.Drawing.Point(2, 2)
Me.DepLabel.Name = "DepLabel"
Me.DepLabel.Size = New System.Drawing.Size(300, 23)
Me.DepLabel.TabIndex = 1
Me.DepLabel.Text = "These components depend on this component:"
'
'PanelHeader
'
Me.PanelHeader.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.VSGUID, Me.Label2, Me.Label1, Me.VIGUID, Me.PrototypeList, Me.Uncooked, Me.Excluded, Me.Selected})
Me.PanelHeader.Dock = System.Windows.Forms.DockStyle.Top
Me.PanelHeader.Name = "PanelHeader"
Me.PanelHeader.Size = New System.Drawing.Size(312, 96)
Me.PanelHeader.TabIndex = 2
'
'PrototypeList
'
Me.PrototypeList.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.PrototypeList.DropDownWidth = 312
Me.PrototypeList.Location = New System.Drawing.Point(64, 48)
Me.PrototypeList.Name = "PrototypeList"
Me.PrototypeList.Size = New System.Drawing.Size(248, 21)
Me.PrototypeList.TabIndex = 3
'
'Uncooked
'
Me.Uncooked.Location = New System.Drawing.Point(0, 72)
Me.Uncooked.Name = "Uncooked"
Me.Uncooked.TabIndex = 2
Me.Uncooked.Text = "Uncooked"
'
'Excluded
'
Me.Excluded.Location = New System.Drawing.Point(208, 72)
Me.Excluded.Name = "Excluded"
Me.Excluded.TabIndex = 1
Me.Excluded.Text = "Excluded"
'
'Selected
'
Me.Selected.Location = New System.Drawing.Point(104, 72)
Me.Selected.Name = "Selected"
Me.Selected.TabIndex = 0
Me.Selected.Text = "Selected"
'
'ScriptText
'
Me.ScriptText.Dock = System.Windows.Forms.DockStyle.Fill
Me.ScriptText.Name = "ScriptText"
Me.ScriptText.Size = New System.Drawing.Size(300, 117)
Me.ScriptText.TabIndex = 0
Me.ScriptText.Text = "RichTextBox1"
'
'Tabs
'
Me.Tabs.Controls.AddRange(New System.Windows.Forms.Control() {Me.DependerTab, Me.ScriptTab})
Me.Tabs.Dock = System.Windows.Forms.DockStyle.Fill
Me.Tabs.Name = "Tabs"
Me.Tabs.SelectedIndex = 0
Me.Tabs.Size = New System.Drawing.Size(312, 170)
Me.Tabs.TabIndex = 1
'
'ScriptTab
'
Me.ScriptTab.Controls.AddRange(New System.Windows.Forms.Control() {Me.Panel1, Me.ScriptLabel})
Me.ScriptTab.DockPadding.All = 2
Me.ScriptTab.Location = New System.Drawing.Point(4, 22)
Me.ScriptTab.Name = "ScriptTab"
Me.ScriptTab.Size = New System.Drawing.Size(304, 144)
Me.ScriptTab.TabIndex = 0
Me.ScriptTab.Text = "Script"
'
'Panel1
'
Me.Panel1.Controls.AddRange(New System.Windows.Forms.Control() {Me.ScriptText})
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
Me.Panel1.Location = New System.Drawing.Point(2, 25)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(300, 117)
Me.Panel1.TabIndex = 2
'
'ScriptLabel
'
Me.ScriptLabel.Dock = System.Windows.Forms.DockStyle.Top
Me.ScriptLabel.Location = New System.Drawing.Point(2, 2)
Me.ScriptLabel.Name = "ScriptLabel"
Me.ScriptLabel.Size = New System.Drawing.Size(300, 23)
Me.ScriptLabel.TabIndex = 1
'
'Panel2
'
Me.Panel2.Controls.AddRange(New System.Windows.Forms.Control() {Me.Tabs})
Me.Panel2.Dock = System.Windows.Forms.DockStyle.Fill
Me.Panel2.Location = New System.Drawing.Point(0, 96)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(312, 170)
Me.Panel2.TabIndex = 3
'
'VIGUID
'
Me.VIGUID.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.VIGUID.Location = New System.Drawing.Point(64, 0)
Me.VIGUID.Name = "VIGUID"
Me.VIGUID.Size = New System.Drawing.Size(248, 20)
Me.VIGUID.TabIndex = 4
Me.VIGUID.Text = ""
'
'Label1
'
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 16)
Me.Label1.TabIndex = 5
Me.Label1.Text = "VIGUID"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.BottomRight
'
'VSGUID
'
Me.VSGUID.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.VSGUID.Location = New System.Drawing.Point(64, 24)
Me.VSGUID.Name = "VSGUID"
Me.VSGUID.Size = New System.Drawing.Size(248, 20)
Me.VSGUID.TabIndex = 4
Me.VSGUID.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(0, 24)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 16)
Me.Label2.TabIndex = 5
Me.Label2.Text = "VSGUID"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.BottomRight
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(0, 48)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 16)
Me.Label3.TabIndex = 5
Me.Label3.Text = "Parents"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.BottomRight
'
'ComponentPropertiesForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(312, 266)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Panel2, Me.PanelHeader})
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "ComponentPropertiesForm"
Me.Text = "ComponentPropertiesForm"
Me.DependerTab.ResumeLayout(False)
Me.Panel3.ResumeLayout(False)
Me.PanelHeader.ResumeLayout(False)
Me.Tabs.ResumeLayout(False)
Me.ScriptTab.ResumeLayout(False)
Me.Panel1.ResumeLayout(False)
Me.Panel2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Form1 As Form1
Private Component As CMI.Component
Sub New(ByRef Form1 As Form1)
Me.New()
Me.Form1 = Form1
End Sub
Function Null(ByRef obj As Object) As Boolean
Return obj Is Nothing Or TypeOf obj Is DBNull
End Function
Public Sub DisplayComponent(ByVal Component As CMI.Component)
Me.Component = Component
Me.Text = Form1.GetComponentName(Component)
Sync()
Me.VIGUID.Text = Component.VIGUID
Me.VSGUID.Text = Component.VSGUID
PrototypeList.Items.Clear()
Dim ParentComponent As CMI.Component = Component
Do
Dim i As String = Form1.GetComponentName(ParentComponent)
PrototypeList.Items.Insert(0, i)
PrototypeList.Text = i
ParentComponent = Form1.GetComponent(ParentComponent.PrototypeVIGUID)
Loop While Not ParentComponent Is Nothing
ScriptText.Enabled = False
While Not ScriptText.Enabled And Not Null(Component.PrototypeVIGUID) And Not Component.PrototypeVIGUID Is ""
Try
ScriptText.Enabled = Not Null(Component.ScriptText)
Catch COMErr As System.Runtime.InteropServices.COMException
Component = Form1.GetComponent(Component.PrototypeVIGUID)
End Try
End While
If ScriptText.Enabled Then
ScriptText.Text = Component.ScriptText
'If Not Null(Component.ScriptLanguage) Then
ScriptLabel.Text = "Component: " & Form1.GetComponentName(Component)
ScriptLabel.Text &= "\nLanguage: " & Component.ScriptLanguage
'End If
Else
ScriptLabel.Text = "(component has no script)"
ScriptText.Text = ""
End If
Dim VSGUID As String
For Each VSGUID In Form1.GetDependerList(Component.VSGUID)
DepList.Items.Add(Form1.GetComponentName(VSGUID))
Next VSGUID
End Sub
Sub Sync()
Uncooked.Checked = Form1.IsComponentUncooked(Component)
Selected.Checked = Form1.IsComponentSelected(Component)
Excluded.Checked = Form1.IsComponentExcluded(Component)
Uncooked.Enabled = Not Uncooked.Checked
Selected.Enabled = Not Excluded.Checked
Excluded.Enabled = Not Selected.Checked
End Sub
Private Sub Uncooked_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Uncooked.CheckedChanged
If Uncooked.Checked Then
If Not Form1.IsComponentUncooked(Component) Then
Form1.UncookComponent(Component)
End If
End If
Sync()
End Sub
Private Sub Selected_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Selected.CheckedChanged
Form1.SetComponentSelected(Component, Selected.Checked)
Sync()
End Sub
Private Sub Excluded_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Excluded.CheckedChanged
Form1.SetComponentExcluded(Component, Excluded.Checked)
Sync()
End Sub
End Class
|
<gh_stars>10-100
' Copyright (c) 1997-2001 Microsoft Corporation
'***************************************************************************
' WMI script to change the OS boot default number
' based on WMI Sample Scripts (VBScript)
' <NAME> [sergueik]
'
'***************************************************************************
'Initialize variables
ReDim objArgs(0)
'Get the command line arguments
If 0 = Wscript.arguments.count Then
' ShowUsage
Else
For i = 0 to Wscript.arguments.count-1
ReDim Preserve objArgs(i)
objArgs(i) = Wscript.arguments.Item(i)
Next
End If
ReDim Preserve KeyedArg(2)
Const lcDebug = 0
Dim pbDoBoot:pbDoBoot = False
Dim psHint:psHint = "SAFE"
If Not IsEmpty(objArgs) Then
For i = 0 to Ubound(objArgs)
ParseArg(objArgs(i))
If KeyedArg(0) = "l" Then
psHint = KeyedArg(1)
ElseIf KeyedArg(0) = "h" Then
ShowUsage
ElseIf KeyedArg(0) = "b" Then
pbDoBoot = True
End If
Next
End If
DoChange
if pbDoBoot = True Then
DoBoot
End If
sub DoChange()
Set posBootSet = GetObject("winmgmts:{(SystemEnvironment)}//./root/cimv2")._
InstancesOf ("Win32_ComputerSystem")
Set poRegEx = New RegExp
Dim pnChange:pnChange = 0
poRegEx.Global = True:poRegEx.IgnoreCase = True:poRegEx.Pattern = psHint
for each poBoot in posBootSet
if VBNull = VarType(poBoot.SystemStartupOptions) Then
WScript.echo "Fatal: invalid data in Win32_ComputerSystem.SystemStartupOptions"
WScript.echo "Giving up"
WScript.Quit(1)
Else
Dim pdSafePos: pdSafePos = 0
Dim pdCurPos : pdCurPos = 0
For Each lsLabel in poBoot.SystemStartupOptions
Set isMatches = poRegEx.Execute(lsLabel)
If isMatches.count <> 0 Then
pnSafePos = pdCurPos
pnChange = 1
End If
pdCurPos = pdCurPos + 1
Next
End If
Next
If pnChange = 0 Then
WScript.echo psHint & _
" not found " &_
VbCrLf &_
"Giving up"
WScript.Quit
End If
If pnSafePos = 0 Then
WScript.echo "Don't need swith boot OS" &_
VbCrLf
Exit Sub
End If
Set posBootSet = Nothing
Set posBootSet = GetObject("winmgmts:{impersonationLevel=impersonate,(SystemEnvironment)}")._
ExecQuery("select * from Win32_ComputerSystem")
for each poBoot in posBootSet
poBoot.SystemStartupSetting = pnSafePos
poBoot.Put_()
next
WScript.Echo "Boot up default OS changed to " & psHint
Set posBootSet = Nothing
End Sub
Private Sub ParseArg(lsLabel)
Set poSwitchRegEx = New RegExp
Dim psMaskSwitch:psMaskSwitch = "[-/][hdb]$" 'currently don't handle all switches.
poSwitchRegEx.Global = True:poSwitchRegEx.IgnoreCase = True:poSwitchRegEx.Pattern = psMaskSwitch
Set poFlagRegEx = New RegExp
Dim psMaskFlag:psMaskFlag = "[-/][l]:"
poFlagRegEx.Global = True:poFlagRegEx.IgnoreCase = True:poFlagRegEx.Pattern = psMaskFlag
Set poFullRegEx = New RegExp
Dim psMaskFull:psMaskFull = psMaskFlag & "\w+"
poFullRegEx.Global = True:poFullRegEx.IgnoreCase = True:poFullRegEx.Pattern = psMaskFull
Dim pnChange:pnChange = 0
set issSwitches = poSwitchRegEx.Execute(lsLabel)
If 0 <> issSwitches.Count Then
KeyedArg(0) = Mid(issSwitches(0),2,1)
KeyedArg(1) = "+"
' ShowUsage
Else
Set isMatches = poFullRegEx.Execute(lsLabel)
if 1 <> isMatches.count Then
WScript.echo "Bad Argument: " & lsLabel
WScript.quit(1)
End If
Set psFlag = poFlagRegEx.Execute(lsLabel)
psRes = poFlagRegEx.Replace(lsLabel,"")
KeyedArg(0) = Mid(psFlag(0),2,1)
KeyedArg(1) = psRes
End If
End Sub
Private Sub ShowUsage()
Dim strFullEngineName:strFullEngineName=WScript.FullName
Dim rPos:rPos = Len(strFullEngineName)
Dim lPos:lPos = InStrRev(strFullEngineName, "\")
strFullName = Mid(strFullEngineName, lPos + 1 , rPos - lPos)
Wscript.echo "" & _
"Usage:" & _
VbCrLf & _
Chr(9) & strFullName & Chr(32) & WScript.ScriptName & " [-l:<LABEL>] [-b] [-h]" & _
VbCrLf & _
Chr(9) & "Change the boot order of the BVT machine" & _
VbCrLf & _
"Where:" & _
VbCrLf & _
Chr(9) & "-l:<LABEL> boot into OS marked as <LABEL> (default is SAFE)" & _
VbCrLf & _
Chr(9) & "-b reboot the machine" & _
VbCrLf & _
Chr(9) & "-h view this message"
WScript.Quit(0)
End Sub
private Sub DoBoot()
Const lcWMIObject = "winmgmts:{impersonationLevel=impersonate, (Shutdown)}"
Dim lsWMIQueryString:lsWMIQueryString = "SELECT * FROM " & _
"Win32_OperatingSystem WHERE PRIMARY = true"
Set loWMISet = GetObject(lcWMIObject)._
ExecQuery(lsWMIQueryString, _
"WQL")
if lcDebug = 1 Then
WScript.echo TypeName(loWMISet)
WScript.echo loWMISet.Count
End If
For Each loWMI__ In loWMISet
loWMI__.Reboot()
Next
End Sub
|
Set RPSet = GetObject("winmgmts:root/default").InstancesOf ("SystemRestore")
for each RP in RPSet
wscript.Echo "Dir: RP" & RP.SequenceNumber & ", Name: " & RP.Description & ", Type: ", RP.RestorePointType & ", Time: " & RP.CreationTime
next
|
on error resume next
set service = GetObject("winmgmts:")
while true
service.Get ("Win32_Service")
wend
|
<gh_stars>10-100
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx"
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
ClientHeight = 5550
ClientLeft = 165
ClientTop = 2715
ClientWidth = 8250
Icon = "main.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 370
ScaleMode = 3 'Pixel
ScaleWidth = 550
WhatsThisHelp = -1 'True
Begin VB.CommandButton cmdDelete
Caption = "del"
Height = 345
Left = 6930
TabIndex = 9
Top = 1635
WhatsThisHelpID = 20080
Width = 1260
End
Begin VB.Frame Frame2
Height = 75
Left = -30
TabIndex = 13
Top = -30
Width = 8355
End
Begin VB.CommandButton cmbEdit
Caption = "edit"
Height = 345
Left = 5520
TabIndex = 8
Top = 1635
WhatsThisHelpID = 20070
Width = 1260
End
Begin VB.CommandButton cmbadd
Caption = "add"
Height = 345
Left = 4080
TabIndex = 7
Top = 1635
WhatsThisHelpID = 20060
Width = 1275
End
Begin VB.Frame FilterFrame
Caption = "filter"
Height = 1290
Left = 2925
TabIndex = 11
Top = 210
Width = 5250
Begin VB.TextBox txtsearch
Height = 285
Left = 1650
MaxLength = 20
TabIndex = 5
Top = 780
WhatsThisHelpID = 20040
Width = 2175
End
Begin VB.CommandButton cmbsearch
Caption = "apply"
Height = 345
Left = 3960
TabIndex = 6
Top = 720
WhatsThisHelpID = 20050
Width = 1185
End
Begin VB.ComboBox combosearch
Height = 315
ItemData = "main.frx":0ABA
Left = 1650
List = "main.frx":0ABC
Style = 2 'Dropdown List
TabIndex = 3
Top = 330
WhatsThisHelpID = 20030
Width = 2175
End
Begin VB.Label FilterLabel
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "by"
Height = 255
Left = 120
TabIndex = 2
Top = 375
WhatsThisHelpID = 20030
Width = 1470
End
Begin VB.Label SearchLabel
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "contain"
Height = 255
Left = 120
TabIndex = 4
Top = 795
WhatsThisHelpID = 20040
Width = 1500
End
End
Begin ComctlLib.TreeView PBTree
Height = 1185
Left = 120
TabIndex = 1
Top = 315
WhatsThisHelpID = 20000
Width = 2580
_ExtentX = 4551
_ExtentY = 2090
_Version = 327682
Indentation = 529
LabelEdit = 1
Sorted = -1 'True
Style = 7
ImageList = "ImageList1"
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin ComctlLib.ListView PopList
Height = 3330
Left = 0
TabIndex = 12
Top = 2160
WhatsThisHelpID = 20020
Width = 8205
_ExtentX = 14473
_ExtentY = 5874
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
_Version = 327682
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
NumItems = 6
BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = ""
Object.Tag = ""
Text = "pop"
Object.Width = 2646
EndProperty
BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
Key = ""
Object.Tag = ""
Text = "ac"
Object.Width = 1323
EndProperty
BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
Key = ""
Object.Tag = ""
Text = "num"
Object.Width = 1720
EndProperty
BeginProperty ColumnHeader(4) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 2
Key = ""
Object.Tag = ""
Text = "cntry"
Object.Width = 1984
EndProperty
BeginProperty ColumnHeader(5) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 2
Key = ""
Object.Tag = ""
Text = "reg"
Object.Width = 1984
EndProperty
BeginProperty ColumnHeader(6) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 2
Key = ""
Object.Tag = ""
Text = "stat"
Object.Width = 1058
EndProperty
End
Begin VB.Label PBListLabel
BackStyle = 0 'Transparent
Caption = "pb"
Height = 225
Left = 90
TabIndex = 0
Top = 90
WhatsThisHelpID = 20000
Width = 1695
End
Begin ComctlLib.ImageList ImageList1
Left = 2760
Top = 675
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 327682
BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
NumListImages = 3
BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "main.frx":0ABE
Key = ""
EndProperty
BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "main.frx":0DD8
Key = ""
EndProperty
BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "main.frx":10F2
Key = ""
EndProperty
EndProperty
End
Begin VB.Label PBLabel
BackStyle = 0 'Transparent
BorderStyle = 1 'Fixed Single
Caption = " "
Height = 315
Left = 75
TabIndex = 10
Top = 1665
WhatsThisHelpID = 20010
Width = 3720
End
Begin VB.Menu file
Caption = "&File--"
Begin VB.Menu m_addpb
Caption = "&New Phone Book...--"
End
Begin VB.Menu m_copypb
Caption = "&Copy Phone Book...--"
End
Begin VB.Menu m_removepb
Caption = "&Delete Phone Book--"
End
Begin VB.Menu div5
Caption = "-"
End
Begin VB.Menu m_printpops
Caption = "&Print POP List--"
End
Begin VB.Menu m_viewlog
Caption = "&View Log---"
End
Begin VB.Menu m_div
Caption = "-"
End
Begin VB.Menu m_exit
Caption = "E&xit--"
End
End
Begin VB.Menu m_edit
Caption = "&Edit--"
Begin VB.Menu m_addpop
Caption = "&Add POP...--"
End
Begin VB.Menu m_editpop
Caption = "&Edit POP...--"
End
Begin VB.Menu m_delpop
Caption = "&Delete POP--"
End
End
Begin VB.Menu m_tools
Caption = "&Tools--"
Begin VB.Menu m_buildPhone
Caption = "&Build Phone Book...--"
End
Begin VB.Menu viewChange
Caption = "View &Phone Book Files...--"
End
Begin VB.Menu m_div1
Caption = "-"
End
Begin VB.Menu m_editflag
Caption = "Edit &Flags...--"
Visible = 0 'False
End
Begin VB.Menu m_editRegion
Caption = "&Regions Editor...--"
End
Begin VB.Menu m_div2
Caption = "-"
End
Begin VB.Menu m_options
Caption = "&Options...--"
End
End
Begin VB.Menu help
Caption = "&Help--"
Begin VB.Menu contents
Caption = "&Help Topics... -- "
End
Begin VB.Menu m_whatsthis
Caption = "What's This? ---"
End
Begin VB.Menu m_div3
Caption = "-"
End
Begin VB.Menu about
Caption = "&About Phone Book Administration--"
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim selection As Long
Dim clickSelect As Integer
Function cmdImportPBK(ByVal PBKFile As String, ByRef dbPB As Database) As Integer
' handles importing phone book file, in PBD format, meaning
' that adds, edits, deletes are allowed. based on POP ID.
'
' Add: <new ID>, new data
' Edit: <POP ID>, new data
' Delete: <POP ID>, all zeros
Dim intPBKFile As Integer
Dim intX As Long
Dim DelReturn As Integer, SaveRet As Integer
Dim strSQL, strLine As String
Dim varLine As Variant
Dim CountryRS As Recordset
Dim i As Integer
Dim iLineCount As Integer
'ReDim varRecord(1)
On Error GoTo ImportErr
iLineCount = 0
If CheckPath(PBKFile) <> 0 Then
cmdLogError 6076
cmdImportPBK = 0
Exit Function
End If
intPBKFile = FreeFile
Open PBKFile For Input Access Read As #intPBKFile
Do While Not EOF(intPBKFile)
Line Input #intPBKFile, strLine
If LOF(intPBKFile) = Len(strLine) Then ' check to see if there are any carriage return (Chr(13)) in the file
cmdLogError 6100
cmdImportPBK = 0
Exit Function
End If
iLineCount = iLineCount + 1
If strLine <> "" Then
varLine = SplitLine(strLine, ",") 'SplitLine should return 11 fields (0-10).
'DeletePOP and SavePOP expect the
'full 14. The extras are empty here.
If Not IsNumeric(varLine(0)) Then
cmdLogError 6086, " - " & LoadResString(6061) & "; " & LoadResString(6094) & " = " & iLineCount
cmdImportPBK = 0
Exit Function
Else
If varLine(1) = "0" Then
intX = varLine(0)
DelReturn = DeletePOP(intX, dbPB)
If DelReturn <> 0 Then
cmdLogError 6078, " - " & LoadResString(6061) & " = " & CStr(DelReturn)
End If
Else
intX = varLine(0)
If UBound(varLine) <> 10 Then
cmdLogError 6077, " - " & LoadResString(6084) & "; " & LoadResString(6061) & " = " & CStr(intX)
cmdImportPBK = 0 'wrong # of fields
Exit Function
End If
For i = 1 To 10
Select Case i
Case 1
If Not IsNumeric(varLine(i)) Then
cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6062) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
strSQL = "SELECT * from Country where CountryNumber = " & CStr(varLine(1))
Set CountryRS = dbPB.OpenRecordset(strSQL)
If CountryRS.BOF And CountryRS.EOF Then
cmdLogError 6090, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6062) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
Case 2
If varLine(i) = "" Then
varLine(i) = 0
End If
If Not IsNumeric(varLine(i)) Then
cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6063) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
strSQL = "SELECT * from region where RegionID = " & CStr(varLine(2))
Set GsysRgn = dbPB.OpenRecordset(strSQL)
If GsysRgn.BOF And GsysRgn.EOF And CInt(varLine(i)) > 0 Then
cmdLogError 6089, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX)
cmdImportPBK = 0
Exit Function
End If
Case 3
If Len(varLine(i)) > 30 Then
cmdLogError 6085, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6064) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
If varLine(i) = "" Then
varLine(i) = " "
End If
Case 4
If Len(varLine(i)) > 10 Then
cmdLogError 6085, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6065) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
If varLine(i) = "" Then
varLine(i) = " "
End If
Case 5
If Len(varLine(i)) > 40 Then
cmdLogError 6085, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6066) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
If varLine(i) = "" Then
varLine(i) = " "
End If
Case 6
If Not IsNumeric(varLine(i)) And varLine(i) <> "" Then
cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6067) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
If varLine(i) = "" Then
varLine(i) = 0
End If
Case 7
If Not IsNumeric(varLine(i)) And varLine(i) <> "" Then
cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6068) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
If varLine(i) = "" Then
varLine(i) = 0
End If
Case 8
If Not IsNumeric(varLine(i)) And varLine(i) <> "" Then
cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6069) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
If varLine(i) = "" Then
varLine(i) = 0
End If
Case 9
If Not IsNumeric(varLine(i)) And varLine(i) <> "" Then
cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6070) & " = " & CStr(varLine(i))
cmdImportPBK = 0
Exit Function
End If
If varLine(i) = "" Then
varLine(i) = 0
End If
End Select
Next i
If Len(varLine(4)) + Len(varLine(5)) > 35 Then
cmdLogError 6091, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(varLine(0))
cmdImportPBK = 0
Exit Function
End If
SaveRet = SavePOP(varLine, dbPB)
If SaveRet <> 0 Then
cmdLogError 6079, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(SaveRet)
cmdImportPBK = 0
Exit Function
End If
End If
End If
End If
Loop
Close #intPBKFile
cmdLogSuccess 6096
On Error GoTo 0
Exit Function
ImportErr:
cmdImportPBK = 1
Exit Function
End Function
Function cmdImportRegions(ByVal RegionFile As String, ByRef dbPB As Database) As Integer
' this function imports a region file, format:
' <region ID>, <region name>
'
' Add: <new region ID>, <new region name>
' Edit: <region ID>, <new region name>
' Delete: <region ID>, <empty string>
Dim intRegionFile As Integer
'Dim rsRegions As Recordset
Dim strSQL, strLine As String
Dim strRegionID, strRegionDesc As String
Dim varLine As Variant
Dim RS As Recordset
Dim NewRgn As Recordset
Dim PerformedDelete As Boolean
Dim rsTempPop As Recordset, rsTempDelta As Recordset
Dim i As Integer, deltnum As Integer
Dim deltasql As String, popsql As String
On Error GoTo RegionImport
PerformedDelete = False
If CheckPath(RegionFile) <> 0 Then
cmdLogError 6076
cmdImportRegions = 0
Exit Function
End If
intRegionFile = FreeFile
Open RegionFile For Input Access Read As #intRegionFile
Do While Not EOF(intRegionFile)
Line Input #intRegionFile, strLine
If LOF(intRegionFile) = Len(strLine) Then ' check to see if there are any carriage return (Chr(13)) in the file
cmdLogError 6100
cmdImportRegions = 0
Exit Function
End If
varLine = SplitLine(strLine, ",")
strRegionID = varLine(0)
strRegionDesc = varLine(1)
If Trim(Str(Val(strRegionID))) = strRegionID Then ' check for integer ID value
If strRegionDesc = "" Then
Set GsysRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
strSQL = "DELETE FROM region WHERE RegionID = " & strRegionID
dbPB.Execute strSQL
popsql = "Select * from DialUpPort Where RegionID = " & strRegionID
Set rsTempPop = dbPB.OpenRecordset(popsql, dbOpenDynaset)
If Not (rsTempPop.BOF And rsTempPop.EOF) Then
rsTempPop.MoveFirst
Do Until rsTempPop.EOF
rsTempPop.Edit
rsTempPop!RegionID = 0
rsTempPop.Update
If rsTempPop!status = 1 Then
Set rsTempDelta = dbPB.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
If rsTempDelta.RecordCount = 0 Then
deltnum = 1
Else
rsTempDelta.MoveLast
deltnum = rsTempDelta!deltanum
If deltnum > 6 Then
deltnum = deltnum - 1
End If
End If
For i = 1 To deltnum
deltasql = "Select * from delta where DeltaNum = " & i & _
" AND AccessNumberId = '" & rsTempPop!AccessNumberId & "' " & _
" order by DeltaNum"
Set rsTempDelta = dbPB.OpenRecordset(deltasql, dbOpenDynaset)
If Not (rsTempDelta.BOF And rsTempDelta.EOF) Then
rsTempDelta.Edit
Else
rsTempDelta.AddNew
rsTempDelta!deltanum = i
rsTempDelta!AccessNumberId = rsTempPop!AccessNumberId
End If
If rsTempPop!status = 1 Then
rsTempDelta!CountryNumber = rsTempPop!CountryNumber
rsTempDelta!AreaCode = rsTempPop!AreaCode
rsTempDelta!AccessNumber = rsTempPop!AccessNumber
rsTempDelta!MinimumSpeed = rsTempPop!MinimumSpeed
rsTempDelta!MaximumSpeed = rsTempPop!MaximumSpeed
rsTempDelta!RegionID = rsTempPop!RegionID
rsTempDelta!CityName = rsTempPop!CityName
rsTempDelta!ScriptID = rsTempPop!ScriptID
rsTempDelta!Flags = rsTempPop!Flags
rsTempDelta.Update
End If
Next i
End If
rsTempPop.MoveNext
Loop
End If
PerformedDelete = True
LogRegionDelete GsysRgn!RegionDesc, CStr(GsysRgn!RegionDesc) & ";" & CStr(GsysRgn!RegionID)
Else
Set GsysRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
If GsysRgn.EOF And GsysRgn.BOF Then
strSQL = "Select * From region where RegionDesc="" " & strRegionDesc & " "" "
Set RS = dbPB.OpenRecordset(strSQL, dbOpenSnapshot)
If RS.EOF And RS.BOF Then
strSQL = "INSERT INTO Region (RegionID, RegionDesc) VALUES (" & _
strRegionID & ", "" " & strRegionDesc & " "")"
dbPB.Execute strSQL
Set GsysRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
LogRegionAdd strRegionDesc, strRegionDesc & ";" & strRegionID
Else
cmdLogError 6088, " - " & gsCurrentPB & "; " & strRegionDesc
cmdImportRegions = 0
Exit Function
End If
Else
strSQL = "Select * From region where RegionDesc="" " & strRegionDesc & " "" "
Set RS = dbPB.OpenRecordset(strSQL, dbOpenSnapshot)
If (RS.EOF And RS.BOF) Then
strSQL = "UPDATE region SET RegionDesc="" " & strRegionDesc & " "" " & _
" WHERE RegionID=" & strRegionID
dbPB.Execute strSQL
strSQL = "INSERT INTO Region (RegionID, RegionDesc) VALUES (" & _
strRegionID & ", "" " & strRegionDesc & " "")"
dbPB.Execute strSQL
Set NewRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
LogRegionEdit GsysRgn!RegionDesc, strRegionDesc & ";" & strRegionID
Else
If RS!RegionID = CInt(strRegionID) Then
strSQL = "UPDATE region SET RegionDesc="" " & strRegionDesc & " "" " & _
" WHERE RegionID=" & strRegionID
dbPB.Execute strSQL
strSQL = "INSERT INTO Region (RegionID, RegionDesc) VALUES (" & _
strRegionID & ", "" " & strRegionDesc & " "")"
dbPB.Execute strSQL
Set NewRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
LogRegionEdit GsysRgn!RegionDesc, strRegionDesc & ";" & strRegionID
Else
cmdLogError 6088, " - " & gsCurrentPB & "; " & strRegionDesc
cmdImportRegions = 0
Exit Function
End If
End If
End If
End If
End If
Loop
If PerformedDelete Then
If Not ReIndexRegions(dbPB) Then GoTo RegionImport
End If
Close #intRegionFile
cmdLogSuccess 6097
cmdImportRegions = 0
On Error GoTo 0
Exit Function
RegionImport:
cmdLogError 6080, " - " & gsCurrentPB & "; " & LoadResString(6063) & " = " & strRegionID
cmdImportRegions = 0
Exit Function
End Function
Function cmdLogSuccess(ErrorNum As Integer, Optional ErrorMsg As String)
Dim intFile As Integer
Dim strFile As String
On Error GoTo LogErr
gCLError = True
intFile = FreeFile
strFile = locPath & "import.log"
Open strFile For Append As #intFile
On Error GoTo 0
Print #intFile, Now & ", " & gsCurrentPB & ", " & LoadResString(ErrorNum) & ErrorMsg
Close #intFile
Exit Function
LogErr:
Exit Function
End Function
Function cmdPublish(ByVal PhoneBook As String, ByRef dbPB As Database) As Integer
Dim rsConfig As Recordset
Dim Pbversion As Integer
Dim config As Recordset
Dim deltnum, vercheck As Integer
Dim sql1, sql2 As String
Dim vernumsql, mastersql, deltasql As String
Dim deltanum As Integer, vernum As Integer, previousver As Integer
Dim filesaveas As String, i As Integer, verfile As String
Dim fullddffile As String, dtaddffile As String
Dim sShort, sLong As String
Dim strTemp As String
Dim strRelPath As String
Dim strSPCfile As String
Dim strPVKfile As String
Dim filelen As Long
Dim bNewVersion As Boolean
Dim result As Integer
Dim strucFname As OFSTRUCT
Dim strSearchFile As String
Dim strRelativePath As String
Dim configure As Recordset
Dim intX As Integer, previous As Integer
Dim vertualpath As String
Dim strSource As String, strDestination As String
Dim webpostdir As String
Dim webpostdir1 As String
Dim strBaseFile As String
Dim strPBVirPath As String
Dim strPBName As String
Dim postpath As Variant
Dim myValue As Long
Dim intAuthCount As Integer
Dim bErr As Boolean
Dim bTriedRepair As Boolean
Dim intVersion As Integer
Dim intRC As Integer
Dim URL
Set GsysVer = dbPB.OpenRecordset("Select * from PhoneBookVersions order by version", dbOpenDynaset)
Set GsysDelta = dbPB.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
Set rsConfig = dbPB.OpenRecordset("select * from Configuration where Index = 1", dbOpenSnapshot)
Set gsyspb = dbPB
gsCurrentPB = PhoneBook
If GsysVer.RecordCount = 0 Then
Pbversion = 1
Else
GsysVer.MoveLast
Pbversion = GsysVer!version + 1
End If
gBuildDir = rsConfig!PBbuildDir
If IsEmpty(gBuildDir) Or gBuildDir = "" Or IsNull(gBuildDir) Then
gBuildDir = locPath & gsCurrentPB
End If
URL = rsConfig!URL
If CheckPath(gBuildDir) <> 0 Then
cmdLogError 6087
Exit Function
End If
If IsNull(URL) Then
cmdLogError 6087
Exit Function
End If
rsConfig.Close
On Error GoTo ErrTrapFile
gBuildDir = Trim(gBuildDir)
If Right(gBuildDir, 1) = "\" Then
gBuildDir = Left(gBuildDir, Len(gBuildDir) - 1)
End If
strRelPath = gBuildDir & "\"
Set config = dbPB.OpenRecordset("select * from Configuration where Index = 1", dbOpenDynaset)
config.MoveLast
If GsysDelta.RecordCount = 0 Then
deltnum = 1
Else
GsysDelta.MoveLast
deltnum = GsysDelta!deltanum
vercheck = GsysDelta!NewVersion
bNewVersion = False
If Not IsNull(config!NewVersion) Then
If config!NewVersion = 1 Then
bNewVersion = True
End If
End If
If vercheck = 1 And Not bNewVersion Then
cmdLogError (6038)
Exit Function
End If
End If
vernum = Pbversion
mastersql = "SELECT * from DialUpPort where Status = '1' order by AccessNumberId"
Set GsysNDial = dbPB.OpenRecordset(mastersql, dbOpenSnapshot)
If GsysNDial.RecordCount = 0 Then 'master phone file
Set GsysNDial = Nothing
cmdLogError (6039)
Exit Function
Else
sLong = strRelPath
filesaveas = sLong & vernum & "Full.pbk"
verfile = sLong & vernum & ".VER"
Load frmNewVersion
masterOutfile filesaveas, GsysNDial
FileCopy filesaveas, sLong & gsCurrentPB & ".pbk"
frmNewVersion.VersionOutFile verfile, vernum
frmNewVersion.outfullddf sLong, vernum & "Full.pbk", Str(vernum)
frmNewVersion.WriteRegionFile sLong & gsCurrentPB & ".pbr"
If Left(Trim(locPath), 2) <> "\\" Then
ChDrive locPath
End If
ChDir locPath
WaitForApp "full.bat" & " " & _
gQuote & sLong & vernum & "Full.cab" & gQuote & " " & _
gQuote & sLong & vernum & "Full.ddf" & gQuote
End If
'Check for existence of full.cab
strSearchFile = sLong & vernum & "Full.cab"
result = OpenFile(strSearchFile, strucFname, OF_EXIST)
If result = -1 Then
cmdLogError (6075)
Exit Function
End If
If vernum > 1 Then
deltasql = "Select * from delta order by DeltaNum"
Set GsysNDelta = dbPB.OpenRecordset(deltasql, dbOpenSnapshot)
If GsysNDelta.RecordCount <> 0 Then
GsysNDelta.MoveLast
deltanum = GsysNDelta!deltanum
End If
previousver = vernum - deltanum + 1
For i = 2 To deltanum
deltasql = "Select * from delta where NewVersion <> 1 and DeltaNum = " & i & " order by AccessNumberId"
Set GsysNDelta = dbPB.OpenRecordset(deltasql, dbOpenSnapshot)
filesaveas = sLong & vernum & "DTA" & previousver & ".pbk"
dtaddffile = vernum & "DELTA" & previousver & ".ddf"
deltaoutfile filesaveas, GsysNDelta
frmNewVersion.outdtaddf sLong, dtaddffile, filesaveas, Str(vernum)
WaitForApp "dta.bat" & " " & _
gQuote & sLong & vernum & "DELTA" & previousver & ".cab" & gQuote & " " & _
gQuote & sLong & vernum & "DELTA" & previousver & ".ddf" & gQuote
previousver = previousver + 1
Next i%
End If
Set GsysNDial = Nothing
Set GsysNDelta = Nothing
On Error GoTo ErrTrapPost
bTriedRepair = False
intVersion = Val(Pbversion)
deltanum = GetDeltaCount(intVersion)
postpath = locPath + "pbserver.mdb"
strPBName = gsCurrentPB
strPBVirPath = ReplaceChars(strPBName, " ", "_")
Set configure = dbPB.OpenRecordset("select * from Configuration where Index = 1", dbOpenDynaset)
intRC = frmNewVersion.UpdateHkeeper(postpath, gsCurrentPB, intVersion, strPBVirPath)
' here's the webpost stuff
webpostdir = gBuildDir & "\" & intVersion & "post"
If CheckPath(webpostdir) = 0 Then
' dir name in use - rename old
myValue = Hour(Now) * 10000 + Minute(Now) * 100 + Second(Now)
Name webpostdir As webpostdir & "_old_" & myValue
End If
MkDir webpostdir
FileCopy locPath & "pbserver.mdb", webpostdir & "\pbserver.mdb"
' copy the CABs
FileCopy gBuildDir & "\" & intVersion & "full.cab", webpostdir & "\" & intVersion & "full.cab"
previous = intVersion - deltanum
For intX = 1 To deltanum
strSource = gBuildDir & "\" & intVersion & "delta" & previous & ".cab"
strDestination = webpostdir & "\" & intVersion & "delta" & previous & ".cab"
FileCopy strSource, strDestination
previous = previous + 1
Next intX
intRC = PostFiles(configure!URL, configure!ServerUID, configure!ServerPWD, intVersion, webpostdir, strPBVirPath)
If intRC = 1 Then bErr = True Else bErr = False
If Not bErr Then
GsysVer.AddNew
GsysVer!version = intVersion
GsysVer!CreationDate = Date
GsysVer.Update
Set GsysDelta = dbPB.OpenRecordset("SELECT * FROM delta ORDER BY DeltaNum", dbOpenDynaset)
GsysDelta.MoveLast
deltanum = GsysDelta!deltanum
If deltanum < 6 Then
GsysDelta.AddNew
GsysDelta!deltanum = deltanum + 1
GsysDelta!NewVersion = 1
GsysDelta.Update
Else
sql1 = "DELETE FROM delta WHERE DeltaNum = 1"
dbPB.Execute sql1, dbFailOnError
sql2 = "UPDATE delta SET DeltaNum = DeltaNum - 1"
dbPB.Execute sql2, dbFailOnError
Set GsysDelta = dbPB.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
GsysDelta.AddNew
GsysDelta!deltanum = 6
GsysDelta!NewVersion = 1
GsysDelta.Update
End If
Set GsysDelta = Nothing
End If
If Not bErr Then
cmdLogSuccess 6098
configure.Edit
configure!NewVersion = 0
configure.Update
LogPublish intVersion
End If
configure.Close
Unload frmNewVersion
Exit Function
ErrTrapFile:
Set GsysNDial = Nothing
Set GsysNDelta = Nothing
Select Case Err.Number
Case 3022
cmdLogError (6040)
Case 75
cmdLogError (6041)
Case Else
cmdLogError (6041)
End Select
Exit Function
ErrTrapPost:
Set GsysDelta = Nothing
cmdLogError (6043)
Exit Function
End Function
Public Function PostFiles(ByVal Host As String, ByVal UID As String, ByVal PWD As String, ByVal version As Integer, ByVal PostDir As String, ByVal VirPath As String) As Integer
' =================================================================================
' this function handles the
' POST to the PB Server
'
' Arguments: host, uid, pwd, version, postdir, virpath
' Returns: 0 = success
' 1 = fail
'
' history: Created April '97 <NAME>
'
' =================================================================================
Const VROOT As String = "PBSDATA"
Const DIR_DB As String = "DATABASE"
Const LOCALFILE As String = "pbserver.mdb"
Const REMOTEFILE As String = "newpb.mdb"
Dim intAuthCount As Byte
Dim intX As Integer
Dim strBaseFile As String
' setup the OCX and check for connection
With frmNewVersion.inetOCX
.URL = "ftp://" & Host
.UserName = UID
.Password = <PASSWORD>
.Protocol = icFTP
.AccessType = icUseDefault
.RequestTimeout = 60
End With
On Error GoTo DirError
frmNewVersion.inetOCX.Execute , "CD /" & VROOT & "/" & VirPath
frmNewVersion.PostWait
' If the directory doesn't exist then create it
If frmNewVersion.inetOCX.ResponseCode = 12003 Then
frmNewVersion.inetOCX.Execute , "CD /" & VROOT
frmNewVersion.PostWait
If frmNewVersion.inetOCX.ResponseCode = 12003 Then
cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
PostFiles = 1
Exit Function
End If
frmNewVersion.inetOCX.Execute , "MKDIR " & VirPath
frmNewVersion.PostWait
If frmNewVersion.inetOCX.ResponseCode = 12003 Then
cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
PostFiles = 1
Exit Function
End If
frmNewVersion.inetOCX.Execute , "CD /" & VROOT & "/" & VirPath
frmNewVersion.PostWait
If frmNewVersion.inetOCX.ResponseCode = 12003 Then
cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
PostFiles = 1
Exit Function
End If
End If
' full CAB
frmNewVersion.inetOCX.Execute , "PUT " & gQuote & PostDir & "\" & version & "full.cab" & gQuote & " " & _
version & "full.cab"
frmNewVersion.PostWait
If frmNewVersion.inetOCX.ResponseCode = 12003 Then
cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
PostFiles = 1
Exit Function
End If
' Delta CABs
strBaseFile = version & "delta"
For intX = version - GetDeltaCount(version) To version - 1
frmNewVersion.inetOCX.Execute , "PUT " & gQuote & PostDir & "\" & strBaseFile & intX & ".cab" & gQuote & " " & _
strBaseFile & intX & ".cab"
frmNewVersion.PostWait
Next
If frmNewVersion.inetOCX.ResponseCode = 12003 Then
cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
PostFiles = 1
Exit Function
End If
' go to db dir
frmNewVersion.inetOCX.Execute , "CD /" & VROOT & "/" & DIR_DB
frmNewVersion.PostWait
If frmNewVersion.inetOCX.ResponseCode = 12003 Then
cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
PostFiles = 1
Exit Function
End If
'PBSERVER.mdb (NewPB.mdb)
frmNewVersion.inetOCX.Execute , "PUT " & gQuote & PostDir & "\" & LOCALFILE & gQuote & " " & REMOTEFILE
frmNewVersion.PostWait
If frmNewVersion.inetOCX.ResponseCode = 12003 Then
cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
PostFiles = 1
Exit Function
End If
' NewPB.txt
frmNewVersion.inetOCX.Execute , "PUT " & gQuote & gBuildDir & "\" & version & ".ver" & gQuote & " newpb.txt"
frmNewVersion.PostWait
If frmNewVersion.inetOCX.ResponseCode = 12003 Then
cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
PostFiles = 1
Exit Function
End If
frmNewVersion.inetOCX.Execute , "QUIT"
PostFiles = 0
Exit Function
DirError:
Select Case Err.Number
Case 35750 To 35755, 35761 'Unable to contact
cmdLogError 6042
PostFiles = 1
Case 35756 To 35760 'Connection Timed Out
cmdLogError 6043
PostFiles = 1
Case Else
cmdLogError 6043
PostFiles = 1
End Select
End Function
Function EndApp()
On Error Resume Next
OSWinHelp Me.hWnd, App.HelpFile, HelpConstants.cdlHelpQuit, 0
'DBEngine.Idle 'dbFreeLocks
GsysRgn.Close
Set GsysRgn = Nothing
GsysCty.Close
Set GsysCty = Nothing
GsysDial.Close
Set GsysDial = Nothing
GsysVer.Close
Set GsysVer = Nothing
GsysDelta.Close
Set GsysDelta = Nothing
GsysNRgn.Close
Set GsysNRgn = Nothing
GsysNCty.Close
Set GsysNCty = Nothing
GsysNDial.Close
Set GsysNDial = Nothing
GsysNVer.Close
Set GsysNVer = Nothing
GsysNDelta.Close
Set GsysNDelta = Nothing
temp.Close
Set temp = Nothing
gsyspb.Close
Set gsyspb = Nothing
Gsyspbpost.Close
Set Gsyspbpost = Nothing
MyWorkspace.Close
Set MyWorkspace = Nothing
End
End Function
Function FillPBTree() As Integer
Dim itmX As Node
Dim varRegKeys As Variant
Dim intX As Integer
Dim strPB As String
Dim strPath As String
On Error GoTo FillpbTreeErr
PBTree.Nodes.Clear
DoEvents
' get pb list from registry
varRegKeys = GetINISetting("Phonebooks", "") 'all settings
If TypeName(varRegKeys) = Empty Then
FillPBTree = 1
Exit Function
End If
intX = 0
Do While varRegKeys(intX, 0) <> Empty
strPB = Trim(varRegKeys(intX, 1))
If strPB <> "" And Not IsNull(strPB) Then
strPath = locPath & strPB
If CheckPath(strPath) = 0 Then 'verify files
Set itmX = PBTree.Nodes.Add()
With itmX
.Image = 2
.Text = varRegKeys(intX, 0)
.Key = varRegKeys(intX, 0)
End With
End If
End If
intX = intX + 1
Loop
PBTree.Sorted = True
HighlightPB gsCurrentPB
Exit Function
FillpbTreeErr:
FillPBTree = 1
Exit Function
'Set itmX = PBTree.Nodes.Add()
'With itmX
' .Image = 1
' .Text = "Big New Phone Book"
' .key = itmX.Text
'End With
'Set child = PBTree.Nodes.Add(itmX.Index, tvwChild, , "Current Release", 3)
'Set child = PBTree.Nodes.Add(itmX.Index, tvwChild, , "Previous Releases", 3)
'Set subChild = PBTree.Nodes.Add(child, tvwChild, , "2", 3)
'Set subChild = PBTree.Nodes.Add(child, tvwChild, , "1", 3)
End Function
Function FillPOPList() As Integer
Dim sqlstm, strTemp As String
Dim intRow, intX As Integer
Dim itmX As ListItem
On Error GoTo ErrTrap
If gsCurrentPB = "" Then
PopList.ListItems.Clear
Exit Function
End If
Me.Enabled = False
Screen.MousePointer = 11
sqlstm = "SELECT DISTINCTROW DialUpPort.CityName, Country.CountryName, Region.RegionDesc, DialUpPort.RegionID, DialUpPort.AreaCode, DialUpPort.AccessNumber, DialUpPort.Status, DialUpPort.AccessNumberId " & _
"FROM (Country INNER JOIN DialUpPort ON Country.CountryNumber = DialUpPort.CountryNumber) LEFT JOIN Region ON DialUpPort.RegionId = Region.RegionId "
Select Case combosearch.ItemData(combosearch.ListIndex)
Case 0, -1 '"all pops"
' nothing
Case 1 '"access number"
sqlstm = sqlstm & " WHERE AccessNumber like '*" & txtsearch.Text & "*" & "'"
Case 2 '"area code"
sqlstm = sqlstm & " WHERE AreaCode like '*" & txtsearch.Text & "*" & "'"
Case 3 '"country"
sqlstm = sqlstm & " WHERE CountryName like '*" & txtsearch.Text & "*" & "'"
Case 4 '"pop name"
sqlstm = sqlstm & " WHERE CityName like '*" & txtsearch.Text & "*" & "'"
Case 5 '"region"
sqlstm = sqlstm & " WHERE RegionDesc like '*" & txtsearch.Text & "*" & "'"
Case 6 '"status"
strTemp = ""
For intX = 0 To 1
If InStr(LCase(gStatusText(intX)), Trim(LCase(txtsearch.Text))) <> 0 Then
If strTemp = "" Then
strTemp = Trim(Str(intX))
Else
strTemp = "*"
End If
End If
Next
If strTemp = "" Then
PopList.ListItems.Clear
Me.Enabled = True
Screen.MousePointer = 0
Exit Function
End If
sqlstm = sqlstm & " WHERE Status like '" & strTemp & "'"
End Select
sqlstm = sqlstm & ";"
Set GsysNDial = gsyspb.OpenRecordset(sqlstm, dbOpenSnapshot)
If GsysNDial.BOF = False Then
GsysNDial.MoveLast
If GsysNDial.RecordCount > 50 Then RefreshPBLabel "loading"
PopList.ListItems.Clear
PopList.Sorted = False
GsysNDial.MoveFirst
Do While Not GsysNDial.EOF
Set itmX = PopList.ListItems.Add()
With itmX
.Text = GsysNDial!CityName
.SubItems(1) = GsysNDial!AreaCode
.SubItems(2) = GsysNDial!AccessNumber
.SubItems(3) = GsysNDial!countryname
intX = GsysNDial!RegionID
Select Case intX
Case 0, -1
.SubItems(4) = gRegionText(intX)
Case Else
.SubItems(4) = GsysNDial!RegionDesc
End Select
.SubItems(5) = gStatusText(GsysNDial!status)
strTemp = "Key:" & GsysNDial!AccessNumberId
.Key = strTemp
End With
If GsysNDial.AbsolutePosition Mod 300 = 0 Then DoEvents
GsysNDial.MoveNext
Loop
Else
PopList.ListItems.Clear
End If
PopList.Sorted = True
Me.Enabled = True
Screen.MousePointer = 0
Exit Function
ErrTrap:
Me.Enabled = True
FillPOPList = 1
Screen.MousePointer = 0
Exit Function
End Function
Function HighlightPB(strPBName As String) As Integer
' highlight pb in tree view control
' and clear the other nodes image setting.
Dim intX As Integer
For intX = 1 To PBTree.Nodes.Count
PBTree.Nodes(intX).Image = 2
If PBTree.Nodes(intX).Key = strPBName Then
PBTree.Nodes(intX).Image = 1
PBTree.Nodes(intX).Selected = True
PBTree.Nodes(intX).EnsureVisible
End If
Next
RefreshPBLabel ""
End Function
Function LoadMainRes() As Integer
Dim cRef As Integer
Dim intX As Integer
On Error GoTo ResErr
cRef = 3010
'global status text array
gStatusText(0) = LoadResString(4061)
gStatusText(1) = LoadResString(4060)
'gRegionText(-1) = LoadResString(4063)
gRegionText(0) = LoadResString(4063)
PBListLabel.Caption = LoadResString(cRef + 0)
FilterFrame.Caption = LoadResString(cRef + 1)
FilterLabel.Caption = LoadResString(cRef + 2)
SearchLabel.Caption = LoadResString(cRef + 3)
cmbsearch.Caption = LoadResString(cRef + 4)
cmbadd.Caption = LoadResString(cRef + 5)
cmbEdit.Caption = LoadResString(cRef + 6)
cmdDelete.Caption = LoadResString(cRef + 7)
'column headers
For intX = 1 To 6
PopList.ColumnHeaders(intX).Text = LoadResString(cRef + 7 + intX)
Next
' pop search list
For intX = 0 To 6
combosearch.AddItem LoadResString(cRef + 15 + intX)
combosearch.ItemData(combosearch.NewIndex) = intX
Next
combosearch.Text = LoadResString(cRef + 15)
'menus
file.Caption = LoadResString(cRef + 22)
m_edit.Caption = LoadResString(cRef + 23)
m_tools.Caption = LoadResString(cRef + 24)
help.Caption = LoadResString(cRef + 25)
m_addpb.Caption = LoadResString(cRef + 26)
m_copypb.Caption = LoadResString(cRef + 27)
m_removepb.Caption = LoadResString(cRef + 28)
m_exit.Caption = LoadResString(cRef + 29)
m_addpop.Caption = LoadResString(cRef + 30)
m_editpop.Caption = LoadResString(cRef + 31)
m_delpop.Caption = LoadResString(cRef + 32)
m_buildPhone.Caption = LoadResString(cRef + 33)
viewChange.Caption = LoadResString(cRef + 34)
m_editRegion.Caption = LoadResString(cRef + 36)
m_options.Caption = LoadResString(cRef + 37)
contents.Caption = LoadResString(cRef + 38)
about.Caption = LoadResString(cRef + 39)
m_printpops.Caption = LoadResString(cRef + 40)
m_viewlog.Caption = LoadResString(cRef + 41)
m_whatsthis.Caption = LoadResString(cRef + 42)
' set fonts
SetFonts Me
PopList.Font.Charset = gfnt.Charset
PopList.Font.Name = gfnt.Name
PopList.Font.Size = gfnt.Size
LoadMainRes = 0
On Error GoTo 0
Exit Function
ResErr:
LoadMainRes = 1
Exit Function
End Function
Function RefreshPBLabel(ByVal Action As String) As Integer
On Error GoTo LabelErr
If gsCurrentPB <> "" Then
Select Case Action
Case "loading"
PBLabel.Caption = " " & LoadResString(3061) & " " & gsCurrentPB
Case Else
PBLabel.Caption = " " & gsCurrentPB & " - [" & combosearch.Text & "]"
End Select
Else
PBLabel.Caption = " " & LoadResString(3060) & " "
End If
DoEvents
On Error GoTo 0
Exit Function
LabelErr:
Exit Function
End Function
Function RemovePB() As Integer
' get the open phonebook and ask if it should
' be removed. clean out pbserver.mdb
Dim varRegKeys As Variant
Dim intRC As Integer
On Error GoTo delErr
If gsCurrentPB = "" Then Exit Function
intRC = MsgBox(LoadResString(4066) & Chr(13) & Chr(13) & gsCurrentPB & Chr(13) & Chr(13) & LoadResString(4088), vbQuestion + 4 + 256)
If intRC = 6 Then
DBEngine.Idle
gsyspb.Close
Set gsyspb = Nothing
Kill gsCurrentPBPath
' delete entry and flush out INI edits
OSWritePrivateProfileString "Phonebooks", gsCurrentPB, vbNullString, locPath & gsRegAppTitle & ".ini"
OSWritePrivateProfileString vbNullString, vbNullString, vbNullString, locPath & gsRegAppTitle & ".ini"
' clear hkeeper
Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(locPath + "pbserver.mdb")
DBEngine.Idle
Gsyspbpost.Execute "DELETE from Phonebooks WHERE ISPid = (select ISPid from ISPs where Description ='" & gsCurrentPB & "')", dbFailOnError
Gsyspbpost.Execute "DELETE from ISPs WHERE Description = '" & gsCurrentPB & "'", dbFailOnError
Gsyspbpost.Close
Set Gsyspbpost = Nothing
If SetCurrentPB("") = 0 Then
PopList.ListItems.Clear
FillPBTree
RefreshButtons
End If
End If
Exit Function
delErr:
Exit Function
End Function
Function RunCommandLine() As Integer
' this function manages the no-GUI, command-line
' execution of PBAdmin.exe
Dim ArgArray As Variant
Dim strArg As String
Dim bImport, bImportPBK, bImportRegions, bPublish, bNewDB As Boolean
Dim bHelp As Boolean
Dim bSetOptions As Boolean
Dim strPhoneBook, strPBPath As String
Dim strPBKFile, strRegionFile As String
Dim strNewDB As String
Dim strURL As String
Dim strUser As String
Dim strPassword As String
Dim intX, intRC As Integer
Dim dbPB As Database
Dim RetVal As Integer
On Error GoTo RunErr
ArgArray = GetCommandLine
If UBound(ArgArray) = 0 Then
RunCommandLine = 0
Exit Function
End If
'MsgBox str(Asc(ArgArray(0)))
'If ArgArray(0) = "" Then
' RunCommandLine = 0
' Exit Function
'End If
strPhoneBook = ""
intX = 1
Do While intX <= UBound(ArgArray)
Select Case ArgArray(intX)
Case "/?"
' list switches
bHelp = True
Case "/I"
intX = intX + 1
strPhoneBook = ArgArray(intX)
bImport = True
Case "/P"
intX = intX + 1
strPBKFile = ArgArray(intX)
bImportPBK = True
Case "/R"
intX = intX + 1
strRegionFile = ArgArray(intX)
bImportRegions = True
Case "/B"
intX = intX + 1
strPhoneBook = ArgArray(intX)
bPublish = True
Case "/N"
intX = intX + 1
strNewDB = ArgArray(intX)
bNewDB = True
Case "/O"
intX = intX + 1
strPhoneBook = ArgArray(intX)
intX = intX + 1
strURL = ArgArray(intX)
intX = intX + 1
strUser = ArgArray(intX)
intX = intX + 1
strPassword = ArgArray(intX)
bSetOptions = True
Case Else
bHelp = True
End Select
intX = intX + 1
Loop
If bHelp Then
MsgBox LoadResString(6057), vbInformation
End
End If
If strPhoneBook <> "" Then ' open database
If Right(strPhoneBook, 4) = ".mdb" Then
strPhoneBook = Left(strPhoneBook, Len(strPhoneBook) - 4)
End If
strPBPath = GetLocalPath & strPhoneBook
If CheckPath(strPBPath) <> 0 Then
cmdLogError 6082, " - " & strPhoneBook
End
End If
gsCurrentPB = strPhoneBook
On Error Resume Next
ConvertDatabaseIfNeeded DBEngine.Workspaces(0), strPBPath & ".mdb", dbDriverNoPrompt, False
Set dbPB = DBEngine.Workspaces(0).OpenDatabase(strPBPath & ".mdb", dbDriverNoPrompt, False, DBPassword)
' Cannot open same object twice & close it twice. Otherwise you
' will get a runtime error. v-vijayb 6/11/99
Set gsyspb = dbPB
'Set gsyspb = DBEngine.Workspaces(0).OpenDatabase(strPBPath & ".mdb")
If Err.Number <> 0 Then
Select Case Err.Number
Case 3051
cmdLogError 6027, " - " & gsCurrentPB
End
Case 3343
cmdLogError 6028, " - " & gsCurrentPB
End
Case 3045
cmdLogError 6029, " - " & gsCurrentPB
End
Case Else
cmdLogError 6030, " - " & gsCurrentPB
End
End Select
End If
On Error GoTo RunErr
'import regions
If bImportRegions Then
If cmdImportRegions(strRegionFile, dbPB) <> 0 Then
dbPB.Close
cmdLogError 6080
End
End If
End If
'import pbk/pbd
If bImportPBK Then
If cmdImportPBK(strPBKFile, dbPB) <> 0 Then
'error
dbPB.Close
cmdLogError 6080
End
End If
End If
'publish: UpdateHkeeper
If bPublish Then
If cmdPublish(strPhoneBook, dbPB) <> 0 Then
dbPB.Close
cmdLogError 6081
End 'error
End If
End If
If bSetOptions Then
SetOptions strURL, strUser, strPassword
End If
dbPB.Close
'gsyspb.Close
Else
' Create a new PB
If bNewDB Then
CreatePB (strNewDB)
Else
If bImportPBK Or bImportRegions Then
cmdLogError 6092
Else
cmdLogError 6093
End If
End If
End If
End
Exit Function
RunErr:
cmdLogError 6081
End
End Function
Function SetCurrentPB(ByVal strPBName As String) As Integer
' all phonebooks are in app directory, for now.
' the registry layout does allow storing them anywhere, with
' any name, excepting pbserver.mdb and hkeeper.mdb.
Dim strPBFile, strPath As String
Dim rsTest As Recordset
On Error GoTo SetCurrentPBErr
If strPBName = gsCurrentPB Then
Exit Function
ElseIf strPBName = "" Then
strPBFile = ""
Else
strPBFile = GetINISetting("Phonebooks", strPBName)
If CheckPath(locPath & strPBFile) <> 0 Then
strPBFile = ""
End If
End If
'close old Phone Book
gsCurrentPBPath = ""
gsCurrentPB = ""
FillPOPList
DBEngine.Idle
Set MyWorkspace = Nothing
If strPBFile = "" And strPBName <> "" Then ' bad pb, delete entry
On Error GoTo DelSettingErr
OSWritePrivateProfileString "Phonebooks", strPBName, vbNullString, locPath & gsRegAppTitle & ".ini"
OSWritePrivateProfileString vbNullString, vbNullString, vbNullString, locPath & gsRegAppTitle & ".ini"
strPBName = ""
strPath = ""
MsgBox LoadResString(6026), vbExclamation
FillPBTree
Else ' looking good
Set MyWorkspace = Workspaces(0)
strPath = locPath & strPBFile
On Error GoTo BadFileErr
ConvertDatabaseIfNeeded MyWorkspace, strPath, dbDriverNoPrompt, False
Set gsyspb = MyWorkspace.OpenDatabase(strPath, dbDriverNoPrompt, False, DBPassword) 'exclusive
Set rsTest = gsyspb.OpenRecordset("select * from Configuration", dbOpenSnapshot)
rsTest.Close
Set rsTest = Nothing
DBEngine.Idle 'dbFreeLocks
'UpgradePB
End If
On Error GoTo SetCurrentPBErr
gsCurrentPBPath = strPath
gsCurrentPB = strPBName
If FillPOPList <> 0 Then
MsgBox LoadResString(6030), vbExclamation
gsCurrentPB = ""
SetCurrentPB = 1
End If
OSWritePrivateProfileString "General", "LastPhonebookUsed", gsCurrentPB, locPath & gsRegAppTitle & ".ini"
OSWritePrivateProfileString vbNullString, vbNullString, vbNullString, locPath & gsRegAppTitle & ".ini"
HighlightPB strPBName
RefreshButtons
selection = 0
updateFound = 0
On Error GoTo 0
Exit Function
SetCurrentPBErr:
SetCurrentPB = 1
Exit Function
BadFileErr:
If strPBName <> "" Then
Select Case Err.Number
Case 3051
MsgBox LoadResString(6027) & _
Chr(13) & Chr(13) & strPath, vbInformation
Case 3343
MsgBox LoadResString(6028) & _
Chr(13) & Chr(13) & strPath, vbExclamation
Case 3045
MsgBox LoadResString(6029) & Chr(13) & Chr(13) & Err.Description, vbInformation
Case Else
MsgBox LoadResString(6030) & Chr(13) & Chr(13) & Err.Description, vbExclamation
End Select
End If
strPBName = ""
strPath = ""
Resume Next
DelSettingErr:
Resume Next
End Function
Function Startup() As Integer
' handle all app init here
Dim intRC As Integer
Dim varPhonebooks, varLastPB As Variant
Dim bTriedReg As Boolean
On Error GoTo StartupErr
' set global values
gsRegAppTitle = "PBAdmin"
gsCurrentPB = "-"
gQuote = Chr(34)
gCLError = False
GetFont gfnt
LoadMainRes 'load labels
DoEvents
' Check for required files
GetLocalPath
On Error GoTo HelpFileErr
App.HelpFile = locPath & gsRegAppTitle & ".hlp"
HTMLHelpFile = GetWinDir & "\help\cps_ops.chm"
On Error GoTo HkeeperErr
Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(locPath & "pbserver.mdb")
Gsyspbpost.Close
'DBEngine.Idle
On Error GoTo Empty_PBErr
Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(locPath & "Empty_PB.mdb")
Gsyspbpost.Close
App.title = LoadResString(1001)
'cmd line processing
On Error GoTo CmdErr
RunCommandLine
On Error GoTo StartupErr
frmMain.Show
'kludge to set the font property of these two controls
PBTree.Font.Charset = gfnt.Charset
PBTree.Font.Name = gfnt.Name
PBTree.Font.Size = gfnt.Size
PBLabel.Font.Charset = gfnt.Charset
PBLabel.Font.Name = gfnt.Name
PBLabel.Font.Size = gfnt.Size
intRC = FillPBTree
'get last used phone book and make it current
varLastPB = GetINISetting("General", "LastPhonebookUsed")
If IsNull(varLastPB) Then
' fallback to first pb in list
varPhonebooks = GetINISetting("Phonebooks", "")
If TypeName(varPhonebooks) <> Empty And Not IsNull(varPhonebooks) Then
varLastPB = varPhonebooks(0, 0)
Else
varLastPB = ""
End If
End If
PBLabel.Visible = True
' set misc
Me.Caption = App.title
SetCurrentPB varLastPB
RefreshButtons
On Error GoTo 0
Exit Function
StartupErr:
Startup = 1
Exit Function
HelpFileErr:
MsgBox LoadResString(6031), vbExclamation
App.HelpFile = ""
Resume Next
HkeeperErr:
' problem w/ hkeeper.mdb. this is the first DAO test so first try to
' reregister the dao dll. if that fails then display message and end.
If CheckPath(locPath & "pbserver.mdb") <> 0 Or bTriedReg Then
MsgBox LoadResString(6032) & Chr(13) & locPath & "pbserver.mdb", vbCritical
End
Else
Dim strDAOPath As String
Dim lngValue As Long
'strDAOPath = RegGetValue("Software\Microsoft\Shared Tools\DAO", "Path")
'strDAOPath = GetMyShortPath(strDAOPath)
bTriedReg = True
If Not (IsNull(strDAOPath) Or strDAOPath = "") Then
WaitForApp "regsvr32 /s " & strDAOPath
Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(locPath & "pbserver.mdb")
Resume Next
Else
GoTo HkeeperErr
End If
End If
Empty_PBErr:
MsgBox LoadResString(6032) & Chr(13) & locPath & "Empty_PB.mdb", vbCritical
End
CmdErr:
' error processing commandline
End
End Function
Function GetCommandLine(Optional MaxArgs)
'Declare variables.
Dim C, CmdLine, CmdLnLen, InArg, i, NumArgs
'See if MaxArgs was provided.
If IsMissing(MaxArgs) Then MaxArgs = 10
'Make array of the correct size.
ReDim ArgArray(MaxArgs)
NumArgs = 0: InArg = False
'Get command line arguments.
CmdLine = Command()
CmdLnLen = Len(CmdLine)
'Go thru command line one character
'at a time.
For i = 1 To CmdLnLen
C = Mid(CmdLine, i, 1)
'Test for space or tab.
If (C <> " " And C <> vbTab) Then
'Neither space nor tab.
'Test if already in argument.
If Not InArg Then
'New argument begins.
'Test for too many arguments.
If NumArgs = MaxArgs Then Exit For
NumArgs = NumArgs + 1
InArg = True
End If
'Concatenate character to current argument.
ArgArray(NumArgs) = ArgArray(NumArgs) & C
Else
'Found a space or tab.
'Set InArg flag to False.
InArg = False
End If
Next i
'Resize array just enough to hold arguments.
ReDim Preserve ArgArray(NumArgs)
'Return Array in Function name.
GetCommandLine = ArgArray()
End Function
Private Sub about_Click()
frmabout.Show vbModal
End Sub
Private Sub cmbsearch_GotFocus()
cmbEdit.Enabled = False
cmdDelete.Enabled = False
m_editpop.Enabled = False
m_delpop.Enabled = False
End Sub
Private Sub combosearch_GotFocus()
cmbEdit.Enabled = False
cmdDelete.Enabled = False
m_editpop.Enabled = False
m_delpop.Enabled = False
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
CheckChar KeyAscii
End Sub
Private Sub Form_Unload(Cancel As Integer)
EndApp
End Sub
Private Sub m_addpop_Click()
cmbadd_Click
End Sub
Private Sub m_buildPhone_Click()
Screen.MousePointer = 11
frmNewVersion.Show vbModal
RefreshButtons
End Sub
Private Sub cmbadd_Click()
'Dim strReturn As String
'Dim lngBuffer As Long
'Dim lngRC As Long
'strReturn = Space(50)
'lngBuffer = Len(strReturn)
'lngRC = WNetGetConnection(txtsearch.Text, strReturn, lngBuffer)
'MsgBox strReturn & " id:" & lngRC, , "wnetgetconnection"
'Exit sub
frmPopInsert.Show vbModal
RefreshButtons
End Sub
Private Sub cmbEdit_Click()
If updateFound = 0 Then Exit Sub
frmupdate.Show vbModal
End Sub
Private Sub cmbsearch_Click()
Screen.MousePointer = 11
cmbsearch.Enabled = False
updateFound = 0 ' clear the pop-selected variables
selection = 0
If FillPOPList = 0 Then
RefreshPBLabel ""
RefreshButtons
End If
cmbsearch.Enabled = True
Screen.MousePointer = 0
End Sub
Private Sub cmdDelete_Click()
Dim response As Integer, deltnum As Integer
Dim Message As String, title As String, dialogtype As Long
Dim i As Integer, deltasql As String, deltafind As Integer
Dim deletecheck As Recordset
Dim statuscheck As Integer
On Error GoTo ErrTrap
Set GsysDial = gsyspb.OpenRecordset("select * from Dialupport where accessnumberId = " & selection, dbOpenSnapshot)
If GsysDial.EOF And GsysDial.BOF Then Exit Sub
If updateFound = GsysDial!AccessNumberId Then
Message = LoadResString(6033)
dialogtype = vbYesNo + vbQuestion + vbDefaultButton2
response = MsgBox(Message, dialogtype)
If response = 6 Then
Screen.MousePointer = 11
statuscheck = 0
If GsysDial!status = "1" Then
statuscheck = 1
End If
gsyspb.Execute "DELETE from DialUpPort where AccessNumberId = " & updateFound
If statuscheck = 1 Then
'insert the delta table
Set GsysDelta = gsyspb.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
If GsysDelta.RecordCount = 0 Then
deltnum = 1
Else
GsysDelta.MoveLast
deltnum = GsysDelta!deltanum
If deltnum > 6 Then
deltnum = deltnum - 1
End If
End If
For i = 1 To deltnum
deltasql = "Select * from delta where DeltaNum = " & i% & _
" AND AccessNumberId = '" & updateFound & "' " & _
" order by DeltaNum"
Set GsysDelta = gsyspb.OpenRecordset(deltasql, dbOpenDynaset)
If Not (GsysDelta.BOF And GsysDelta.EOF) Then
GsysDelta.Edit
Else
GsysDelta.AddNew
GsysDelta!deltanum = i%
GsysDelta!AccessNumberId = updateFound
End If
GsysDelta!CountryNumber = 0
GsysDelta!AreaCode = 0
GsysDelta!AccessNumber = 0
GsysDelta!MinimumSpeed = 0
GsysDelta!MaximumSpeed = 0
GsysDelta!RegionID = 0
GsysDelta!CityName = "0"
GsysDelta!ScriptID = "0"
GsysDelta!Flags = 0
GsysDelta.Update
Next i%
End If
Set deletecheck = gsyspb.OpenRecordset("DialUpPort", dbOpenSnapshot)
If deletecheck.RecordCount = 0 Then
gsyspb.Execute "DELETE from PhoneBookVersions"
gsyspb.Execute "DELETE from delta"
End If
Else
Exit Sub
End If
LogPOPDelete GsysDial
GsysDial.Close
Set GsysDial = Nothing
PopList.ListItems.Remove "Key:" & updateFound
selection = 0
updateFound = 0
RefreshButtons
frmMain.PopList.SetFocus
Screen.MousePointer = 0
End If
On Error GoTo 0
Exit Sub
ErrTrap:
Screen.MousePointer = 0
MsgBox LoadResString(6056) & Chr(13) & Chr(13) & Err.Description, vbExclamation
Exit Sub
End Sub
Private Sub combosearch_Click()
If combosearch.Text = LoadResString(3025) Then
txtsearch.Enabled = False
SearchLabel.Enabled = False
Else
txtsearch.Enabled = True
SearchLabel.Enabled = True
End If
RefreshButtons
End Sub
Private Sub contents_Click()
'OSWinHelp Me.hWnd, App.HelpFile, HelpConstants.cdlHelpContents, 0
HtmlHelp Me.hWnd, HTMLHelpFile & ">proc4", HH_DISPLAY_TOPIC, CStr("cps_topnode.htm")
End Sub
Private Sub Form_Load()
Dim cRef As Integer
On Error GoTo LoadErr
'If App.PrevInstance Then
' MsgBox LoadResString(6035), vbExclamation
' End
'End If
Screen.MousePointer = 11
CenterForm Me, Screen
If Startup <> 0 Then
'If 0 = 1 Then
Screen.MousePointer = 0
MsgBox LoadResString(6036), vbCritical
End
End If
Screen.MousePointer = 0
On Error GoTo 0
Exit Sub
LoadErr:
Screen.MousePointer = 0
Exit Sub
End Sub
Private Sub m_addpb_Click()
Dim strNewPB As String
Dim itmX As Node
On Error GoTo AddPBErr
frmNewPB.Show vbModal
strNewPB = frmNewPB.strPB
Unload frmNewPB
If strNewPB <> "" Then
SetCurrentPB strNewPB
FillPBTree
'frmcab.Show vbModal ' show options page
End If
Exit Sub
AddPBErr:
Exit Sub
End Sub
Private Sub m_copypb_Click()
Dim intRC As Integer
Dim strNewPB As String
Dim itmX As Node
On Error GoTo CopyPBErr
frmCopyPB.Show vbModal
strNewPB = frmCopyPB.strPB
Unload frmCopyPB
If strNewPB <> "" Then
SetCurrentPB strNewPB
FillPBTree
'frmcab.Show vbModal
End If
Exit Sub
CopyPBErr:
Exit Sub
End Sub
Private Sub m_delpop_Click()
cmdDelete_Click
End Sub
Private Sub m_editpop_Click()
cmbEdit_Click
End Sub
Private Sub m_editRegion_Click()
Screen.MousePointer = 11
frmLoadRegion.Show vbModal
End Sub
Private Sub m_exit_Click()
EndApp
End Sub
Private Sub m_printpops_Click()
On Error GoTo ErrTrap
Screen.MousePointer = 13
m_printpops.Enabled = False
' popup print screen and let it print
Load frmPrinting
frmPrinting.JobType = 2
frmPrinting.Show vbModal
m_printpops.Enabled = True
Screen.MousePointer = 0
Exit Sub
ErrTrap:
m_printpops.Enabled = True
Screen.MousePointer = 0
Exit Sub
End Sub
Private Sub m_removepb_Click()
RemovePB
End Sub
Private Sub m_options_Click()
Screen.MousePointer = 11
frmcab.Show vbModal
End Sub
Private Sub m_viewlog_Click()
Dim strFile As String
Dim intFile As Integer
On Error GoTo LogErr
strFile = locPath & gsCurrentPB & "\" & gsCurrentPB & ".log"
If CheckPath(strFile) <> 0 Then
MakeLogFile gsCurrentPB
End If
Shell "notepad " & strFile, vbNormalFocus
On Error GoTo 0
Exit Sub
LogErr:
MsgBox LoadResString(6053), vbExclamation
Exit Sub
End Sub
Private Sub m_whatsthis_Click()
frmMain.WhatsThisMode
End Sub
Private Sub PBTree_DblClick()
If gsCurrentPB <> "" Then
frmcab.Show vbModal
End If
End Sub
Private Sub PBTree_GotFocus()
cmbEdit.Enabled = False
cmdDelete.Enabled = False
m_editpop.Enabled = False
m_delpop.Enabled = False
End Sub
Private Sub PBTree_NodeClick(ByVal ClickedNode As Node)
' this routine just sets the current pb based
' on the clicked node.
' we're currently only displaying pb nodes so
' it can be very simple.
Dim strNewPB As String
Dim intRC As Integer
On Error Resume Next
Screen.MousePointer = 11
' change current phonebook
strNewPB = ClickedNode.Key
If strNewPB = "" Then
Screen.MousePointer = 0
Exit Sub
End If
If SetCurrentPB(strNewPB) <> 0 Then
Screen.MousePointer = 0
Exit Sub
End If
selection = 0
updateFound = 0
RefreshButtons
Screen.MousePointer = 0
On Error GoTo 0
End Sub
Private Sub PopList_ColumnClick(ByVal ColumnHeader As ColumnHeader)
On Error Resume Next
Screen.MousePointer = 11
DoEvents
PopList.SortKey = ColumnHeader.index - 1
PopList.Sorted = True
Screen.MousePointer = 0
On Error GoTo 0
End Sub
Private Sub PopList_DblClick()
'selection = Val(Right$(PopList.SelectedItem.Key, Len(PopList.SelectedItem.Key) - 4))
'updateFound = selection
If selection <> 0 And Not IsNull(selection) Then
cmbEdit_Click
End If
End Sub
Private Sub PopList_GotFocus()
If gsCurrentPB <> "" Then
cmbEdit.Enabled = True
cmdDelete.Enabled = True
m_editpop.Enabled = True
m_delpop.Enabled = True
End If
End Sub
Private Sub PopList_ItemClick(ByVal Item As ListItem)
On Error GoTo ItemErr
' here's our baby
selection = Val(Right$(Item.Key, Len(Item.Key) - 4))
updateFound = selection
RefreshButtons
On Error GoTo 0
Exit Sub
ItemErr:
Exit Sub
End Sub
Private Sub txtsearch_Change()
cmbsearch.Default = True
RefreshButtons
End Sub
Private Sub txtsearch_GotFocus()
SelectText txtsearch
cmbEdit.Enabled = False
cmdDelete.Enabled = False
m_editpop.Enabled = False
m_delpop.Enabled = False
End Sub
Function RefreshButtons() As Integer
' this routine attempts to handle all of the main
' screen ui - buttons and menus.
Dim bSetting As Boolean
Dim rsTemp As Recordset
cmbsearch.Enabled = Not txtsearch = "" Or combosearch.Text = LoadResString(3025)
If Not cmbsearch.Enabled Then
cmbsearch.Default = False
End If
'based on PB selected
If gsCurrentPB <> "" Then
bSetting = True
cmbadd.Enabled = bSetting
m_addpop.Enabled = bSetting
m_copypb.Enabled = bSetting
m_removepb.Enabled = bSetting
m_viewlog.Enabled = bSetting
m_buildPhone.Enabled = bSetting
viewChange.Enabled = bSetting
m_editRegion.Enabled = bSetting
m_options.Enabled = bSetting
FilterFrame.Enabled = bSetting
'pop list print
If PopList.ListItems.Count = 0 Then
m_printpops.Enabled = False
Else
m_printpops.Enabled = True
End If
' handle regions editing
'If gsCurrentPBPath <> "" Then
' Set rsTemp = GsysPb.OpenRecordset("PhonebookVersions", dbOpenSnapshot)
' If rsTemp.BOF And rsTemp.EOF Then
'enable
' m_editRegion.Enabled = True
' Else
'disable region edits
' m_editRegion.Enabled = False
' End If
' rsTemp.Close
'End If
' based on pop selected
If selection > 0 Then
bSetting = True
Else
bSetting = False
End If
cmbEdit.Enabled = bSetting
cmdDelete.Enabled = bSetting
m_editpop.Enabled = bSetting
m_delpop.Enabled = bSetting
Else
bSetting = False
cmbadd.Enabled = bSetting
cmbEdit.Enabled = bSetting
cmdDelete.Enabled = bSetting
m_viewlog.Enabled = bSetting
m_addpop.Enabled = bSetting
m_editpop.Enabled = bSetting
m_delpop.Enabled = bSetting
m_copypb.Enabled = bSetting
m_removepb.Enabled = bSetting
m_printpops.Enabled = bSetting
m_buildPhone.Enabled = bSetting
viewChange.Enabled = bSetting
m_editflag.Enabled = bSetting
m_editRegion.Enabled = bSetting
m_options.Enabled = bSetting
FilterFrame.Enabled = bSetting
End If
End Function
Private Sub viewChange_Click()
Dim masterSet As Recordset
Dim sql As String
On Error GoTo ErrTrap
Screen.MousePointer = 11
sql = "Select AccessNumberId as [Access ID], AreaCode as [Area Code], AccessNumber as [Access number], Status, MinimumSpeed as [Min speed], Maximumspeed as [Max speed], CityName as [POP name], CountryNumber as [Country Number], ServiceType as [Service type], RegionId as [Region ID], ScriptID as [Dial-up connection], SupportNumber as [Flags for input], flipFactor as [Flip factor], Flags , Comments from DialUpPort order by AccessNumberId"
Set masterSet = gsyspb.OpenRecordset(sql, dbOpenSnapshot)
If masterSet.EOF And masterSet.BOF Then
masterSet.Close
Screen.MousePointer = 0
MsgBox LoadResString(6034), vbExclamation
Exit Sub
End If
masterSet.Close
frmdelta.Show vbModal
Exit Sub
ErrTrap:
Screen.MousePointer = 0
MsgBox LoadResString(6056) & Chr(13) & Chr(13) & Err.Description, vbExclamation
Exit Sub
End Sub
' This function returns the path to the Windows directory as a
' string.
Function GetWinDir() As String
Dim lpbuffer As String * 255
Dim Length As Long
Length = apiGetWindowsDirectory(lpbuffer, Len(lpbuffer))
GetWinDir = Left(lpbuffer, Length)
End Function
|
<filename>admin/wmi/wbem/scripting/test/vbscript/stress/enumerr.vbs<gh_stars>10-100
On Error Resume Next
while true
Set E = GetObject ("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select Name from Win32_Processs", "WQL", 0)
if Err <> 0 Then
WScript.Echo "Expected error was raised:", Err.Source, Err.Number, Err.Description
Err.Clear
end if
for each Process in E
if Err <> 0 Then
'Create the last error object
set t_Object = CreateObject("WbemScripting.SWbemLastError")
WScript.Echo ""
WScript.Echo "WBEM Last Error Information:"
WScript.Echo ""
WScript.Echo " Operation:", t_Object.Operation
WScript.Echo " Provider:", t_Object.ProviderName
strDescr = t_Object.Description
strPInfo = t_Object.ParameterInfo
strCode = t_Object.StatusCode
if (strDescr <> nothing) Then
WScript.Echo " Description:", strDescr
end if
if (strPInfo <> nothing) Then
WScript.Echo " Parameter Info:", strPInfo
end if
if (strCode <> nothing) Then
WScript.Echo " Status:", strCode
end if
Err.Clear
Else
WScript.Echo "Shouldn't get here!"
End if
next
wend
|
<reponame>npocmaka/Windows-Server-2003<gh_stars>10-100
'
L_Welcome_MsgBox_Message_Text = "This script demonstrates how to access list view text from scriptable objects."
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample"
Call Welcome()
' ********************************************************************************
Dim mmc
Dim doc
Dim snapins
Dim frame
Dim views
Dim view
Dim scopenamespace
Dim rootnode
Dim Nodes
Dim scopenode
Dim SnapNode1
Dim MySnapin
Dim CellData
Dim Flags
' Following are snapin exposed objects.
Dim ScopeNodeObject
Dim ResultItemObject
'get the various objects we'll need
Set mmc = wscript.CreateObject("MMC20.Application")
Set frame = mmc.Frame
Set doc = mmc.Document
Set namespace = doc.ScopeNamespace
Set rootnode = namespace.GetRoot
Set views = doc.views
Set view = views(1)
Set snapins = doc.snapins
snapins.Add "{18731372-1D79-11D0-A29B-00C04FD909DD}" ' Sample snapin
' Select sample snapin root
Set rootnode = namespace.GetRoot
Set SnapNode1 = namespace.GetChild(rootnode)
view.ActiveScopeNode = SnapNode1
' Now select the "User Data".
Set SnapNode1 = namespace.GetChild(SnapNode1)
view.ActiveScopeNode = SnapNode1
' Now Select/Deselect nodes in succession.
Set Nodes = view.ListItems
view.Select Nodes(1)
'view.Deselect Nodes(1)
view.Select Nodes(2)
CellData = view.CellContents(0, 0)
MsgBox("Cell(0,0) = " + CellData)
CellData = view.CellContents(3, 2)
MsgBox("Cell(3,2) = " + CellData)
' Uncomment below line, will fail as it addresses non-existent cell.
'CellData = view.CellContents(4, 3)
' ExportList(filename, bSelected, bTabDelimited, bUnicode)
ExportListOptions_Default = 0
ExportListOptions_TabDelimited = 2
ExportListOptions_Unicode = 1
ExportListOptions_SelectedItemsOnly = 4
Flags = ExportListOptions_TabDelimited
view.ExportList "c:\temp\ansi_all.txt", Flags
Flags = ExportListOptions_TabDelimited Or ExportListOptions_Unicode
view.ExportList "c:\temp\unicode_all.txt", Flags
view.ExportList "c:\temp\ansi_all.csv", ExportListOptions_Default
view.ExportList "c:\temp\unicode_all.csv", ExportListOptions_Unicode
Flags = ExportListOptions_SelectedItemsOnly Or ExportListOptions_TabDelimited
view.ExportList "c:\temp\ansi_sel.txt", Flags
Flags = ExportListOptions_SelectedItemsOnly Or ExportListOptions_TabDelimited Or ExportListOptions_Unicode
view.ExportList "c:\temp\unicode_sel.txt", Flags
view.ExportList "c:\temp\ansi_sel.csv", ExportListOptions_SelectedItemsOnly
Flags = ExportListOptions_SelectedItemsOnly Or ExportListOptions_Unicode
view.ExportList "c:\temp\unicode_sel.csv", Flags
view.ExportList "c:\temp\defaultparm_all"
Set mmc = Nothing
' ********************************************************************************
' *
' * Welcome
' *
Sub Welcome()
Dim intDoIt
intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
vbOKCancel + vbInformation, _
L_Welcome_MsgBox_Title_Text )
If intDoIt = vbCancel Then
WScript.Quit
End If
End Sub
|
<filename>fib.bas
10 PRINT "0\n"
20 PRINT "1\n"
30 LET a = 1
40 LET b = a + a
50 PRINT a, "\n"
60 PRINT b, "\n"
70 LET a = a + b
90 LET b = a + b
100 PRINT a, "\n"
110 PRINT b, "\n"
120 IF a < 1000000 THEN goto 70
|
<gh_stars>1-10
LenB(string|varname)
|
<gh_stars>10-100
on error resume next
'// Create a new shadow
set Shadow = GetObject("winmgmts:Win32_ShadowCopy")
set Storage = GetObject("winmgmts:Win32_ShadowStorage")
Result = 0
Result = Shadow.Create(Null, Null, Null)
rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
end if
Result = 0
Result = Shadow.Create("BogusVolumeName", "ClientAccessible", strShadowID)
rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
end if
Result = 0
Result = Shadow.Create(-1, "ClientAccessible", strShadowID)
rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
end if
Result = 0
Result = Shadow.Create("c:\", "BogusContext", strShadowID)
rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
end if
Result = 0
Result = Shadow.Create("c:\", -1, strShadowID)
rc = ReportIfErr(Err, "FAILED - ShadowCopy Create")
strMessage = MapErrorCode("Win32_ShadowCopy", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowCopy.Create returned: " & Result & " : " & strMessage
end if
Result = 0
Result = Storage.Create(Null, Null, Null)
rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
end if
Result = 0
Result = Storage.Create("BogusVolumeName", "C:\", Null)
rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
end if
Result = 0
Result = Storage.Create("C:\", "BogusVolumeName", Null)
rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
end if
Result = Null
Result = Storage.Create("C:\", "C:\", "BogusMaxSpaceValue")
rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
end if
Result = Null
Result = Storage.Create("C:\", "C:\", -1)
rc = ReportIfErr(Err, "FAILED - ShadowStorage Create")
strMessage = MapErrorCode("Win32_ShadowStorage", "Create", Result)
if Result <> 0 then
wscript.echo "ShadowStorageCreate returned: " & Result & " : " & strMessage
end if
Result = Null
Function MapErrorCode(ByRef strClass, ByRef strMethod, ByRef intCode)
set objClass = GetObject("winmgmts:").Get(strClass, &h20000)
set objMethod = objClass.methods_(strMethod)
values = objMethod.qualifiers_("values")
if ubound(values) < intCode then
wscript.echo " FAILURE - no error message found for " & intCode & " : " & strClass & "." & strMethod
MapErrorCode = ""
else
MapErrorCode = values(intCode)
end if
End Function
Function ReportIfErr(ByRef objErr, ByRef strMessage)
ReportIfErr = objErr.Number
if objErr.Number <> 0 then
strError = strMessage & " : " & Hex(objErr.Number) & " : " & objErr.Description
wscript.echo (strError)
objErr.Clear
end if
End Function
|
Sub Check_Is_Empty()
Dim A As String, B As Variant
Debug.Print IsEmpty(A) 'return False
Debug.Print IsEmpty(Null) 'return False
Debug.Print IsEmpty(B) 'return True ==> B is a Variant
Debug.Print A = vbNullString 'return True
Debug.Print StrPtr(A) 'return 0 (zero)
'Press the OK button without enter a data in the InputBox :
A = InputBox("Enter your own String : ")
Debug.Print A = "" 'return True
Debug.Print IsEmpty(A) 'return False
Debug.Print StrPtr(A) = 0 'return False
'Press the cancel button (with or without enter a data in the InputBox)
A = InputBox("Enter your own String : ")
Debug.Print StrPtr(A) = 0 'return True
Debug.Print IsEmpty(A) 'return False
Debug.Print A = "" 'return True
'Note : StrPtr is the only way to know if you cancel the inputbox
End Sub
|
<reponame>npocmaka/Windows-Server-2003
VERSION 5.00
Begin VB.Form frmXML
Caption = "Schema Documentation Program"
ClientHeight = 5730
ClientLeft = 60
ClientTop = 345
ClientWidth = 6195
LinkTopic = "Form1"
ScaleHeight = 5730
ScaleWidth = 6195
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Domain
Height = 395
IMEMode = 3 'DISABLE
Left = 1200
TabIndex = 6
Top = 3840
Width = 3275
End
Begin VB.TextBox Password
Height = 395
IMEMode = 3 'DISABLE
Left = 1200
PasswordChar = "*"
TabIndex = 5
Top = 3240
Width = 3275
End
Begin VB.TextBox DirPath
Height = 395
Left = 1320
TabIndex = 1
Top = 240
Width = 3275
End
Begin VB.TextBox Prefix
Height = 395
Left = 1320
TabIndex = 2
Top = 840
Width = 3275
End
Begin VB.TextBox txtFile
Height = 395
Left = 1320
TabIndex = 3
Top = 1440
Width = 3275
End
Begin VB.CommandButton Next
Caption = "&Next >"
Default = -1 'True
Height = 375
Left = 5040
TabIndex = 7
Top = 5280
Width = 1095
End
Begin VB.CommandButton cmdClose
Caption = "Exit"
Height = 375
Left = 120
TabIndex = 8
Top = 5280
Width = 975
End
Begin VB.TextBox Username
Height = 395
Left = 1200
TabIndex = 4
Top = 2640
Width = 3275
End
Begin VB.Frame Frame1
Caption = "Credentials"
Height = 2175
Left = 120
TabIndex = 11
Top = 2280
Width = 4575
Begin VB.Label Label6
Caption = "Domain:"
Height = 255
Left = 120
TabIndex = 14
Top = 1680
Width = 735
End
Begin VB.Label Label5
Caption = "Password:"
Height = 255
Left = 120
TabIndex = 13
Top = 1080
Width = 855
End
Begin VB.Label Label4
Caption = "User name:"
Height = 255
Left = 120
TabIndex = 12
Top = 480
Width = 855
End
End
Begin VB.Label Label1
Caption = "Directory path:"
Height = 255
Left = 120
TabIndex = 10
Top = 360
Width = 1095
End
Begin VB.Label Label3
Caption = "Output file:"
Height = 255
Left = 120
TabIndex = 9
Top = 1560
Width = 855
End
Begin VB.Label Label2
Caption = "Naming prefix:"
Height = 255
Left = 120
TabIndex = 0
Top = 960
Width = 1095
End
End
Attribute VB_Name = "frmXML"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private bUnloading
Private Sub LoadData()
On Error GoTo err:
Open "XML.CFG" For Input As #2
'Read the main info
Input #2, strPrefix
Input #2, strUsername
Input #2, strDomain
'Read the vendor info
Input #2, strVendName
Input #2, strVendAddress
Input #2, strVendCity
Input #2, strVendState
Input #2, strVendCountry
Input #2, strVendPostalCode
Input #2, strVendTelephone
Input #2, strVendEmail
'Read the product info
Input #2, strProdName
Input #2, strProdDescription
Input #2, strProdVMajor
Input #2, strProdVMinor
Close #2
err:
End Sub
Public Sub SaveData()
strADSPath = DirPath
strDomain = Domain
strFile = txtFile
strPassword = Password
strPrefix = Prefix
strUsername = Username
End Sub
Private Sub SaveDataToFile()
Open "XML.CFG" For Output As #2
'Save the main info
Write #2, strPrefix
Write #2, strUsername
Write #2, strDomain
'Save the vendor info
Write #2, strVendName
Write #2, strVendAddress
Write #2, strVendCity
Write #2, strVendState
Write #2, strVendCountry
Write #2, strVendPostalCode
Write #2, strVendTelephone
Write #2, strVendEmail
' Write #2, strVendContactName
'Save the product info
Write #2, strProdName
Write #2, strProdDescription
Write #2, strProdVMajor
Write #2, strProdVMinor
Close #2
End Sub
Private Sub Form_Load()
Dim rootDSE As IADs
Dim oConvAd As New MakeDitDB
bUnloading = False
oConvAd.UpdateAttribute "Hello There"
Set .oMail = Server.CreateObject("VBMail.Connector")
oMail.Sender = "George"
oMail.Recipient = "JCCannon"
oMail.SenderName = "<NAME>"
oMail.RecipientName = " JC "
oMail.Subject = "My subject"
oMail.Body = "Body message"
LoadData
'--- Set the default values
Set rootDSE = GetObject("LDAP://RootDSE")
strADSPath = "LDAP://" & rootDSE.Get("schemaNamingContext")
'strADSPath = "LDAP://" & rootDSE.Get("defaultNamingContext")
DirPath = strADSPath
Domain = strDomain
Prefix = strPrefix
txtFile = "c:\test.xml"
Username = strUsername
' JC Set rootDSE = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload ProdInfo
Unload VendorInfo
SaveData
SaveDataToFile
End
End Sub
Private Sub Next_Click()
frmXML.Visible = False
VendorInfo.Left = frmXML.Left
VendorInfo.Top = frmXML.Top
VendorInfo.Visible = True
End Sub
Public Sub EndProgram()
If (bUnloading = False) Then
bUnloading = True
Unload frmXML
End If
End Sub
Private Sub cmdClose_Click()
Unload frmXML
End Sub
|
<gh_stars>1-10
Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with '123' = " _
& TESTSTRING & "123"
End Sub
|
<reponame>npocmaka/Windows-Server-2003<filename>admin/wmi/wbem/scripting/test/whistler/directory/guest.vbs
on error resume next
set computer = GetObject("umi:///winnt/computer=alanbos4")
if err <> 0 then
WScript.Echo "Retireval failed: 0x", Hex(Err.Number), Err.Description
WScript.Quit 0
end if
set user = computer.GetInstance_ ("user=guest")
if err <> 0 then
WScript.Echo "User Retireval failed: 0x", Hex(Err.Number), Err.Description
WScript.Quit 0
end if
WScript.Echo user.Description
user.Put_
if err <> 0 then
WScript.Echo "Put failed: 0x", Hex(Err.Number), Err.Description
WScript.Quit 0
end if
WScript.Echo "Success"
|
<filename>admin/wmi/wbem/scripting/test/vbscript/stress/qualtest.vbs
On Error Resume Next
while true
Set Service = GetObject("winmgmts:root/default")
Set Class = Service.Get()
Class.Path_.Class = "Qualtest00"
Set Qualifiers = Class.Qualifiers_
Qualifiers.Add "qbool", true, true, true, false
Qualifiers.Add "qsint32", 345
Qualifiers.Add "qreal64", -345.675
Qualifiers.Add "qstring", "freddy the frog"
Qualifiers.Add "qstring2", "freddy the froggie", false
Qualifiers.Add "qstring3", "freddy the froggies", false, false
Qualifiers.Add "qstring4", "freddy the froggiess", true, false
Qualifiers.Add "qstring5", "wibble", true, true, false
Qualifiers.Add "aqbool", Array(true, false, true)
Qualifiers.Add "aqsint32", Array (10, -12)
Qualifiers.Add "aqreal64", Array(-2.3, 2.456, 12.356567897)
Qualifiers.Add "aqstring", Array("lahdi", "dah", "wibble")
Qualifiers("qsint32").Value = 7677
WScript.Echo "There are", Qualifiers.Count, "Qualifiers in the collection"
for each qualifier in Qualifiers
If (IsArray(qualifier)) Then
str = qualifier.Name & "={"
for x=LBound(qualifier) to UBound(qualifier)
v =qualifier
str = str & v(x)
if x <> UBound(qualifier) then
str = str & ", "
end if
next
str = str & "}"
WScript.Echo str
Else
WScript.Echo qualifier.Name, "=", qualifier
End If
Next
if Err <> 0 Then
WScript.Echo Err.Description
End if
Class.Put_
wend
|
set locator = CreateObject("WbemScripting.SWbemLocatorEx")
set ldap = locator.Open ("umi://nw01t1/LDAP", "nw01t1domnb\administrator", "nw01t1domnb")
for each c in ldap.SubclassesOf
WScript.Echo c.Path_.Path
next
|
'the function
Sub whatever(foo As Long, bar As Integer, baz As Byte, qux As String)
'...
End Sub
'calling the function -- note the Pascal-style assignment operator
Sub crap()
whatever bar:=1, baz:=2, foo:=-1, qux:="Why is ev'rybody always pickin' on me?"
End Sub
|
<reponame>npocmaka/Windows-Server-2003<filename>admin/wmi/wbem/scripting/test/vbscript/privilege/privilege_ps1.vbs
on error resume next
const wbemPrivilegeDebug = 19
set locator = CreateObject("WbemScripting.SWbemLocator")
locator.Security_.Privileges.Add wbemPrivilegeDebug
set service = locator.connectserver
service.security_.impersonationLevel = 3
set processes = service.instancesof ("Win32_Process")
for each process in processes
if IsNull(process.priority) then
WScript.Echo process.Name, process.Handle, "<NULL>"
else
WScript.Echo process.name, process.Handle, process.priority
end if
next
if err <> 0 then
WScript.Echo Err.Number, Err.Description, Err.Source
end if
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.