Search is not available for this dataset
content
stringlengths 0
376M
|
---|
<gh_stars>1-10
Function LCM(a,b)
LCM = POS((a * b)/GCD(a,b))
End Function
Function GCD(a,b)
Do
If a Mod b > 0 Then
c = a Mod b
a = b
b = c
Else
GCD = b
Exit Do
End If
Loop
End Function
Function POS(n)
If n < 0 Then
POS = n * -1
Else
POS = n
End If
End Function
i = WScript.Arguments(0)
j = WScript.Arguments(1)
WScript.StdOut.Write "The LCM of " & i & " and " & j & " is " & LCM(i,j) & "."
WScript.StdOut.WriteLine
|
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form frmTerminalMode
BorderStyle = 0 'None
Caption = "Terminal Mode"
ClientHeight = 5730
ClientLeft = 0
ClientTop = 0
ClientWidth = 9480
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 5730
ScaleWidth = 9480
ShowInTaskbar = 0 'False
Visible = 0 'False
Begin VB.Timer Timer1
Left = 3360
Top = 4320
End
Begin VB.TextBox txtTerminal
Height = 5295
Left = 6120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 16
Top = 120
Width = 3255
End
Begin VB.Frame framePort
Height = 5415
Left = 0
TabIndex = 18
Top = 0
Width = 6015
Begin VB.PictureBox Picture1
Height = 255
Left = 1920
Picture = "frmTerminalMode.frx":0000
ScaleHeight = 195
ScaleWidth = 435
TabIndex = 23
Top = 4920
Visible = 0 'False
Width = 495
End
Begin VB.PictureBox Picture2
Height = 255
Left = 2640
Picture = "frmTerminalMode.frx":05A6
ScaleHeight = 195
ScaleWidth = 435
TabIndex = 22
Top = 4920
Visible = 0 'False
Width = 495
End
Begin VB.PictureBox Picture3
Height = 255
Left = 3480
Picture = "frmTerminalMode.frx":0B4C
ScaleHeight = 195
ScaleWidth = 435
TabIndex = 21
Top = 4920
Visible = 0 'False
Width = 495
End
Begin MSCommLib.MSComm MSComm1
Left = 2400
Top = 4200
_ExtentX = 1005
_ExtentY = 1005
_Version = 327681
DTREnable = -1 'True
End
Begin VB.ComboBox Combo11
Height = 315
ItemData = "frmTerminalMode.frx":10F2
Left = 1080
List = "frmTerminalMode.frx":1126
Style = 2 'Dropdown List
TabIndex = 1
Top = 240
Width = 1695
End
Begin VB.ComboBox Combo21
Height = 315
ItemData = "frmTerminalMode.frx":11A1
Left = 4080
List = "frmTerminalMode.frx":11CC
Style = 2 'Dropdown List
TabIndex = 9
Top = 240
Width = 1815
End
Begin VB.TextBox Text11
Height = 315
Left = 4080
TabIndex = 11
Text = "1.5"
Top = 690
Width = 1815
End
Begin VB.TextBox Text21
BackColor = &H80000004&
Enabled = 0 'False
Height = 315
Left = 4080
TabIndex = 19
TabStop = 0 'False
Top = 1170
Width = 1815
End
Begin VB.ComboBox Combo31
Height = 315
ItemData = "frmTerminalMode.frx":1224
Left = 1080
List = "frmTerminalMode.frx":1237
Style = 2 'Dropdown List
TabIndex = 3
Top = 720
Width = 1695
End
Begin VB.ComboBox Combo41
Height = 315
ItemData = "frmTerminalMode.frx":124A
Left = 1080
List = "frmTerminalMode.frx":125D
Style = 2 'Dropdown List
TabIndex = 5
Top = 1170
Width = 1695
End
Begin VB.ComboBox Combo51
Height = 315
ItemData = "frmTerminalMode.frx":127F
Left = 1080
List = "frmTerminalMode.frx":128C
Style = 2 'Dropdown List
TabIndex = 7
Top = 1620
Width = 1695
End
Begin VB.CommandButton cmdGo
Caption = "&Connect"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2880
TabIndex = 12
Top = 1560
Width = 1455
End
Begin VB.CommandButton cmdStop
Caption = "D&isconnect"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4440
TabIndex = 13
Top = 1560
Width = 1455
End
Begin VB.TextBox Text3
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 120
TabIndex = 15
Top = 2640
Width = 5775
End
Begin VB.Label Label3
Caption = "&Port:"
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 = 120
TabIndex = 0
Top = 270
Width = 855
End
Begin VB.Label Label4
Caption = "Port &speed:"
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 = 2880
TabIndex = 8
Top = 270
Width = 1095
End
Begin VB.Label Label5
Caption = "&Data bits:"
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 = 120
TabIndex = 2
Top = 720
Width = 855
End
Begin VB.Label Label6
Caption = "P&arity:"
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 = 120
TabIndex = 4
Top = 1200
Width = 855
End
Begin VB.Label Label7
Caption = "S&top bits:"
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 = 120
TabIndex = 6
Top = 1680
Width = 855
End
Begin VB.Label Label1
Caption = "I&nterval:"
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 = 2880
TabIndex = 10
Top = 720
Width = 1095
End
Begin VB.Label Label2
Caption = "&Reset:"
Enabled = 0 'False
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 = 2880
TabIndex = 20
Top = 1200
Width = 1095
End
Begin VB.Label lblCommand
Caption = "C&ommand:"
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 = 120
TabIndex = 14
Top = 2400
Width = 1935
End
End
Begin ComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 300
Left = 0
TabIndex = 17
Top = 5430
Width = 9480
_ExtentX = 16722
_ExtentY = 529
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 4
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 1
Object.Width = 12171
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 882
MinWidth = 882
Picture = "frmTerminalMode.frx":129B
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 6
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "5/3/98"
Object.Tag = ""
EndProperty
BeginProperty Panel4 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 5
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "1:10 PM"
Object.Tag = ""
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Attribute VB_Name = "frmTerminalMode"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Command() As String
Dim Instring As String ' Buffer to hold input string
Dim SectionName$
Dim Halt As Boolean
Dim Section() As String
Dim FileOut As String
Dim Go As Boolean
Dim CP As Integer
Dim X As Integer
Dim z As Integer
Public Filename$
Const Q = """"
Dim TerminalOutput As String
Private Sub cmdGo_Click()
Dim TimeInterval As String
Dim ComSettings As String
Dim ParitySetting As String
On Error GoTo ErrorHandler
cmdGo.Enabled = False
cmdStop.Enabled = True
Halt = False
Go = False
TimeInterval = Text11.Text
If TimeInterval > 0 Then
Timer1.Interval = TimeInterval
Else
Timer1.Interval = 1000
End If
MSComm1.CommPort = Right(Combo11.Text, 2) ' Use selected port.
ParitySetting = Left(Combo41.Text, 1)
ComSettings = Combo21.Text & ", " & ParitySetting & ", " & Combo31.Text & ", " & Combo51.Text
MSComm1.Settings = ComSettings
MSComm1.InputLen = 0 ' Tell the control to read entire buffer when Input is used.
'StatusBar1.Panels(1).Text = "Working"
StatusBar1.Panels(1).Text = MSComm1.Settings & " Port number: " & MSComm1.CommPort
txtTerminal.Refresh
txtTerminal.Text = ""
TerminalOutput = ""
MSComm1.PortOpen = True ' Open the port.
MSComm1.Output = "AT" + Chr$(13)
Text3.Enabled = True
Text3.SetFocus
Do
DoEvents
Loop Until Halt = True
Text3.Enabled = False
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False ' Close the serial port.
End If
cmdGo.Enabled = True
cmdStop.Enabled = False
StatusBar1.Panels(2).Picture = Picture1.Picture
StatusBar1.Panels(1).Text = "Finished"
Exit Sub
ErrorHandler:
If Err.Number = "8002" Then
RetVal = MsgBox("Invalid Port Number", vbExclamation)
Else
RetVal = MsgBox(Err.Description & " " & Err.Number, vbCritical)
End If
cmdStop.Enabled = False
cmdGo.Enabled = True
StatusBar1.Panels(1).Text = "Finished"
End Sub
Private Sub cmdStop_Click()
Halt = True
End Sub
Private Sub Form_Load()
TerminalOutput = ""
framePort.Top = 0
framePort.Left = 0
Combo11.Text = GetSetting(App.Title, "Settings", "Combo11", "Com 1")
Combo21.Text = GetSetting(App.Title, "Settings", "Combo21", "9600")
Combo31.Text = GetSetting(App.Title, "Settings", "Combo31", "8")
Combo41.Text = GetSetting(App.Title, "Settings", "Combo41", "None")
Combo51.Text = GetSetting(App.Title, "Settings", "Combo51", "1")
Text11.Text = GetSetting(App.Title, "Settings", "Text11", "1.5")
Text21.Text = GetSetting(App.Title, "Settings", "Text21", "")
End Sub
Private Sub Form_Resize()
txtTerminal.Width = frmTerminalMode.Width - 6225
txtTerminal.Height = frmTerminalMode.Height - 435
framePort.Height = frmTerminalMode.Height - 350
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting App.Title, "Settings", "Combo11", Combo11.Text
SaveSetting App.Title, "Settings", "Combo21", Combo21.Text
SaveSetting App.Title, "Settings", "Combo31", Combo31.Text
SaveSetting App.Title, "Settings", "Combo41", Combo41.Text
SaveSetting App.Title, "Settings", "Combo51", Combo51.Text
SaveSetting App.Title, "Settings", "Text11", Text11.Text
SaveSetting App.Title, "Settings", "Text21", ""
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text3.Text = "" Then
Exit Sub
End If
TextLine = Text3.Text
StatusBar1.Panels(2).Picture = Picture2.Picture
MSComm1.Output = TextLine + Chr$(13) ' Send the command to the modem.
Go = False
Do
DoEvents
Loop Until Go = True ' Wait for data to come back to the serial port.
Instring = MSComm1.Input ' Read the response data in the serial port.
StatusBar1.Panels(2).Picture = Picture3.Picture
TerminalOutput = TerminalOutput & TextLine & Instring
txtTerminal.Text = TerminalOutput
txtTerminal.SelStart = Len(txtTerminal.Text)
Text3.Text = ""
End If
End Sub
Private Sub Timer1_Timer()
Go = True
End Sub
Public Sub ClearControl()
txtTerminal.Text = ""
End Sub
Public Sub EditCopy()
Clipboard.Clear
Clipboard.SetText txtTerminal.SelText
End Sub
Public Sub EditPaste()
txtTerminal.Text = (Clipboard.GetText)
End Sub
|
"reviewId": "",
"reviewDate": {
"$date": "2014-05-21T00:00:00.000Z"
},
"reviewTitle": "",
"reviewText": "I absolutely love this B B! The food is great! The birds are wonderful. I received excellent help with local information. I will definitely stay here again.",
"reviewerCity": "",
"reviewerState": ""
}, {
"reviewId": "",
"reviewDate": {
"$date": "2014-03-12T00:00:00.000Z"
},
"reviewTitle": "",
"reviewText": "We stayed only one night -- 2 couples. Our rooms were very comfortable. My husband and I had the Equine Room, and the bathroom was indeed lovely. The owners are very hospitable, and Tom cooked a unique and delicious breakfast.",
"reviewerCity": "",
"reviewerState": ""
}, {
"reviewId": "",
"reviewDate": {
"$date": "2014-07-18T00:00:00.000Z"
},
"reviewTitle": "",
"reviewText": "I enjoyed the stayed here the food was awesome very peaceful and wondrous I am glad I found this place to stay whenever I feel like having a nice peaceful weekend I come here and I enjoy it very much I love how relaxing it is.",
"reviewerCity": "",
"reviewerState": ""
}, {
"reviewId": "",
"reviewDate": {
"$date": "2014-07-23T00:00:00.000Z"
},
"reviewTitle": "",
"reviewText": "Beautiful quiet setting thank you for such a comfortable atmosphere this was a beautiful one night retreat and I cant wait to come back again.",
"reviewerCity": "",
"reviewerState": ""
}, {
"reviewId": "",
"reviewDate": {
"$date": "2014-03-19T00:00:00.000Z"
},
"reviewTitle": "",
"reviewText": "The setting is the best thing about the Spirit Inn, in our opinion -- lovely location, and pretty good birds, too, although we did not get our target Montezuma Quail.",
"reviewerCity": "",
"reviewerState": ""
}]
} {
"_id": {
"$oid": "5cf9dcbd433d2b44c0de3ffb"
},
"name": "<NAME>",
"categories": ["Hotels"],
"location": {
"country": "US",
"state": "AL",
"city": "Abbeville",
"postalCode": "36310",
"address": "1237 Us Highway 431 S",
"coordinates": {
"type": "Point",
"coordinates": [-85.2837, 31.55176]
}
},
"reviews": [{
"reviewId": "",
"reviewDate": {
"$date": "2008-10-06T00:00:00.000Z"
},
"reviewTitle": "",
"reviewText": "Budget hotel offers standard amenities and low rates to road-weary travelers. In ShortSince 1946, this Phoenix, Ariz.-based hotel chain has provided guests with comfortable accommodations. Its BestRequests program offers 16 of the most frequently requested services and amenities, including complimentary in-room tea/coffeemakers, hair dryers, iron and ironing boards, free local calls less than 30 minutes and long-distance access. Complimentary toiletries, like toothpaste, razors and sewing kits, are also available upon request. Business travelers will enjoy the computer data ports in each room and photocopying services.",
"reviewerCity": "",
"reviewerState": ""
}]
} {
"_id": {
"$oid": "5cf9dcbd433d2b44c0de3ffc"
},
"name": "<NAME>",
"categories": ["Hotels \u0026 Motels"],
"location": {
"country": "US",
"state": "AZ",
"city": "Sierra Vista",
"postalCode": "85635",
"address": "1551 E Fry Blvd",
"coordinates": {
"type": "Point",
"coordinates": [-110.281579, 31.554729]
}
},
"reviews": [{
"reviewId": "",
"reviewDate": {
"$date": "2008-10-05T00:00:00.000Z"
},
"reviewTitle": "",
"reviewText": "The familiar sign promises economy, consistency and no surprises. In ShortSince 1962, travelers have enjoyed budget-friendly prices at Motel 6. The national chain (more than 800 locations in the U.S.) accommodates traveling families, as kids stay for free and complimentary coffee is available every morning. The rooms are simple--a TV on the dresser (free HBO and ESPN), data port for computer users and a basic bathroom--but at these prices, who needs a whirlpool",
"reviewerCity": "",
"reviewerState": ""
}]
} {
|
<filename>Task/Active-Directory-Search-for-a-user/VBScript/active-directory-search-for-a-user-1.vb
strUsername = "TestUser"
strQuery = "<LDAP://dc=skycityauckland,dc=sceg,dc=com>;"_
& "(&(objectclass=*)(samaccountname=" & strUsername & "));distinguishedname;subtree"
objCmd.ActiveConnection = objConn
objCmd.Properties("Page Size")=100
objCmd.CommandText = strQuery
Set objRS = objCmd.Execute
|
<gh_stars>1-10
Function LIS(arr)
n = UBound(arr)
Dim p()
ReDim p(n)
Dim m()
ReDim m(n)
l = 0
For i = 0 To n
lo = 1
hi = l
Do While lo <= hi
middle = Int((lo+hi)/2)
If arr(m(middle)) < arr(i) Then
lo = middle + 1
Else
hi = middle - 1
End If
Loop
newl = lo
p(i) = m(newl-1)
m(newl) = i
If newL > l Then
l = newl
End If
Next
Dim s()
ReDim s(l)
k = m(l)
For i = l-1 To 0 Step - 1
s(i) = arr(k)
k = p(k)
Next
LIS = Join(s,",")
End Function
WScript.StdOut.WriteLine LIS(Array(3,2,6,4,5,1))
WScript.StdOut.WriteLine LIS(Array(0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15))
|
<filename>examples/VBScript.vbs
Wscript.Echo "Hello World!"
|
Rem GPU geometry engine simulator/tester written in 'FreeBasic'
REM Setup by <NAME>
REM
REM Get the freeBasic compiler at
REM
REM
rem 16 bit command buffer:
rem
rem Idea - fdat(0/1) bits = 1 1 1 1 1 1 (Read vertically)
rem 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
rem [primary][ primary 12 bit data ]
rem [command][ ]
rem
rem [extend command][ 8 bit data for ]
rem [ ][extended command]
rem This means there are 15 functions. Allow func 15 through 8 to set the 12 bit data registers
rem IE: while func bit 15=1. When func bit 15=0, there will be 128 additional functions where you
rem have access to the lower 8 bit data word.
rem
rem For the first 8 functions, you will be basically setting 8 different 12 bit registers
rem For the alternate 128 instructions, you will be setting multiple 8 bit registers
rem and executing state machines.
Declare Sub read_palette() : REM loads the GPU palette into memory
Declare Sub draw_pixel(xp as integer, yp as integer, col as Ubyte) : REM Draws 1 dot with paleted Color
Declare Sub drawLine(x1 as integer, y1 as integer, x2 as integer, y2 As Integer, color_val As Ubyte)
Declare Sub drawFilledTriangle(x1 as integer, y1 as integer, x2 as integer, y2 As Integer, x3 as integer, y3 As Integer, color_val As Ubyte)
Declare Sub drawCircle(x As integer, y As Integer, a As integer, b As integer, colour as Integer, filled As Boolean = FALSE)
Declare Sub drawEllipse(x1 As integer, y1 As Integer, x2 As integer, y2 As Integer, colour as Integer, filled As Boolean = FALSE)
Declare Sub func_plot(draw_type as Ubyte, color_type as Ubyte, color_val as Ubyte, dst_mem as integer, sx as integer, sy as integer, dx as integer, dy as integer, tx as integer, ty as integer, zx as integer, zy as integer, mx as integer, my as integer)
Declare Sub setup_linegen_num ( byval i as integer)
Declare Sub run_linegen_num ( byval i as integer, byval stop_Y_pos as integer, byval color_val as UByte )
Dim Shared As Integer xa(2),ya(2),xb(2),yb(2)
Dim Shared As Integer dx(2),dy(2),sx(2),sy(2)
Dim Shared As Integer magic(2),errd(2)
Dim Shared As Integer is_done(2)
Dim Shared As Integer out_y
Dim Shared fdat (0 To 1) As Ubyte
Dim Shared pal_dat_r (0 To 255) As Ubyte
Dim Shared pal_dat_g (0 To 255) As Ubyte
Dim Shared pal_dat_b (0 To 255) As Ubyte
dim Shared as integer funcdata12, x0,y0,x1,y1,x2,y2,x3,y3,x4,y4,c1,c2,c3,c4
dim Shared as integer destmem, srcmem, max_x,max_y, src_width, dest_width
dim shared as Ubyte funcdata8,func1,func2,func3, draw_collision, blit_collision, show_pset
dim shared as string ink
ScreenRes 720,560,16,0,0 : REM open a window a little larger than 640x480
read_palette(): REM initially load the palette into memory
out_y = 3 : Rem Set y-position of ordering Output
REM *************************************************************
REM **** Open the 'drawing.bin' file ************
REM *************************************************************
Open "drawing.bin" For Binary Access Read As 1
REM *************************************************************************
REM **** perform a loop while characters still exist in the file ************
REM *************************************************************************
while not eof(1)
REM *************************************************************************
REM **** Read 2 bytes as the command format dat is 16 bits wide ************
REM *************************************************************************
get #1,,fdat(1), 1 : REM Big endian order
get #1,,fdat(0), 1 : REM Big endian order
REM decode 16 bit instruction
funcdata12 = fdat(1) + ( fdat(0) and 15) * 256 : Rem separate out a 12 bit number
funcdata8 = fdat(1)
func1 = int (fdat(0)/16) : Rem separate out 16 possible main functions.
func2 = int (fdat(0) and 127) : Rem separate out 128 possible sub functions
func3 = fdat(1)
REM *************************************************************
REM **** For the upper main function set the appropriate 12 bit registers ************
REM *************************************************************
if func1 > 7 then
if func1=8 then x0=funcdata12
if func1=9 then x1=funcdata12
if func1=10 then x2=funcdata12
if func1=11 then x3=funcdata12
if func1=12 then y0=funcdata12
if func1=13 then y1=funcdata12
if func1=14 then y2=funcdata12
if func1=15 then y3=funcdata12
end if
REM *************************************************************
REM **** All other possible 127 functions ************
REM *************************************************************
if func1<8 then
REM *************************************************************
REM **** Set 24 bit screen memory registers ************
REM *************************************************************
if func2=127 then destmem = y0*4096 + x0: Rem set 24 bit destination screen memory pointer for plotting
if func2=126 then destmem = y1*4096 + x1: Rem set 24 bit destination screen memory pointer for plotting
if func2=125 then destmem = y2*4096 + x2: Rem set 24 bit destination screen memory pointer for plotting
if func2=124 then destmem = y3*4096 + x3: Rem set 24 bit destination screen memory pointer for plotting
if func2=123 then srcmem = y0*4096 + x0: Rem set 24 bit source screen memory pointer for blitter copy
if func2=122 then srcmem = y1*4096 + x1: Rem set 24 bit source screen memory pointer for blitter copy
if func2=121 then srcmem = y2*4096 + x2: Rem set 24 bit source screen memory pointer for blitter copy
if func2=120 then srcmem = y3*4096 + x3: Rem set 24 bit source screen memory pointer for blitter copy
if func2=119 then destmem = y0*4096 + x0:srcmem = x1*4096 + y1: Rem both source and destination pointers for blitter copy
if func2=118 then destmem = y1*4096 + x1:srcmem = x0*4096 + y0: Rem both source and destination pointers for blitter copy
if func2=117 then destmem = y2*4096 + x2:srcmem = x3*4096 + y3: Rem both source and destination pointers for blitter copy
if func2=116 then destmem = y3*4096 + x3:srcmem = x2*4096 + y2: Rem both source and destination pointers for blitter copy
if func2=115 then dest_width = x2 : Rem Sets the number of bytes per horizontal line in the destination raster
if func2=114 then src_width = y2 : Rem Sets the number of bytes per horizontal line in the destination raster
if func2=113 then dest_width = x3 : Rem Sets the number of bytes per horizontal line in the destination raster
if func2=112 then src_width = y3 : Rem Sets the number of bytes per horizontal line in the destination raster
REM *************************************************************
REM **** Set screen width and height limits ************
REM *************************************************************
if func2=95 then max_x = x0: max_y = y0 : REM set the maximum width and height of the screen
if func2=94 then max_x = x1: max_y = y1 : REM set the maximum width and height of the screen
if func2=93 then max_x = x2: max_y = y2 : REM set the maximum width and height of the screen
if func2=92 then max_x = x3: max_y = y3 : REM set the maximum width and height of the screen
if func2=91 then draw_collision = 0 : REM Clear the pixel drawing collision counter
if func2=90 then blit_collision = 0 : REM Clear the blitter copy pixel collision counter
REM *************************************************************
REM **** Numerous plotting functions ************
REM *************************************************************
if func2>0 and func2<90 then func_plot(func2,1,func3,destmem,x0,y0,x1,y1,x2,y2,x3,y3,max_x,max_y) : rem draw oval filled
REM *************************************************************
REM **** reset function ************
REM *************************************************************
if func2=0 and func3=255 then
x0=0:x1=0:x2=0:x3=0:x4=0
y0=0:y1=0:y2=0:y3=0:y4=0
max_x=0:max_y=0
end if
end if
wend : rem process until all bytes in file are finished
close #1
REM *************************************************************
REM **** Finished reading file, press ESC key to quit ************
REM *************************************************************
color rgb(0,255,0),rgb(0,0,0)
locate 67,1
? " Finished drawing.bin. Press ESC key to close window. "
ink=""
while ink<>chr(27)
sleep 10,0: rem wait for a keypress before quitting
ink=inkey
wend
end
REM *************************************************************
REM **** The PLOT functions ************
REM *************************************************************
REM draw_type = what type of geometric object to draw
REM color_type = (will be used in GPU to define the bits/pixel)
REM color_val = Will be used to define the drawing pen color
REM dst_mem = defines the base memory address of the screen display
REM sx,sy...zx,zy = defines the drawing coordinates
REM mx,my = defines the maximum X&Y locations allowed to be plotted
Sub func_plot(draw_type as Ubyte, color_type as Ubyte, color_val as Ubyte, dst_mem as integer, sx as integer, sy as integer, dx as integer, dy as integer, tx as integer, ty as integer, zx as integer, zy as integer, mx as integer, my as integer)
dim as integer x,y,z
color rgb(255,255,255),rgb(0,0,0)
locate 62,1
? " Func Plot ";draw_type;" ";color_type;" ";color_val;" "
? " base Addr= ";dst_mem;" "
? " coord 1ab (";sx;",";sy;")-(";dx;",";dy;") "
? " coord 2ab (";tx;",";ty;")-(";zx;",";zy;") "
? " x&y limit (";mx;",";my;") ";
if draw_type = 0 then : REM ********* Draw a Dot at sx,sy
draw_pixel (sx,sy,color_val)
end if
if draw_type = 1 then : REM ********* Draw a Line from (sx,sy)-(dx,dy) (Using Bresenham's Line Algorithm)
drawLine(sx,sy,dx,dy,color_val)
End if
if draw_type = 2 then : REM ********* Draw a Box inside area (sx,sy)-(dx,dy)
for x=sx to dx
draw_pixel (x,sy,color_val)
draw_pixel (x,dy,color_val)
next x
for y=sy to dy
draw_pixel (sx,y,color_val)
draw_pixel (dx,y,color_val)
next y
End if
if draw_type = 2+8 then : REM ********* Draw a filled Box inside area (sx,sy)-(dx,dy)
for y=sy to dy
for x=sx to dx
draw_pixel (x,y,color_val)
next x
next y
end If
if draw_type = 3+8 then : REM ********* Draw a triangle with points (sx,sy),(dx,dy),(tx,ty)
drawFilledTriangle(sx,sy,dx,dy,tx,ty,color_val)
End If
If draw_type = 4 Then : REM ********* Draw a ellipse within Rectangle bounded by sx,sy,dx,dy
drawEllipse(sx, sy, dx, dy, color_val)
EndIf
If draw_type = 4+8 Then : REM ********* Draw a filled ellipse within Rectangle bounded by sx,sy,dx,dy
drawEllipse(sx, sy, dx, dy, color_val, TRUE)
EndIf
If draw_type = 5 Then : REM ********* Draw a Circle at sx, sy With radius dx
drawCircle(sx, sy, dx, dy, color_val)
EndIf
If draw_type = 5+8 Then : REM ********* Draw a filled Circle at sx, sy With radius dx
drawCircle(sx, sy, dx, dy, color_val, TRUE)
EndIf
REM *************************************************************
sleep : REM PAUSE for keypress after every plot command
REM *************************************************************
end Sub
REM *************************************************************
REM **** Draw Circle Using Bresenham's algorithm ************
REM *************************************************************
Sub drawCircle(ByVal xc As integer, ByVal yc As Integer, ByVal a As integer, ByVal b As Integer, ByVal colour as Integer, ByVal filled As Boolean = FALSE)
Dim As Integer x, y, sigma, xd
Dim As Integer a2 = a*a, b2 = b*b, fa2 = 4*a2, fb2 = 4*b2
x=0
y=b
sigma = 2*b2+a2*(1-2*b)
While (b2*x <= a2*y)
draw_pixel(xc+x, yc+y, colour) : Rem I. Quadrant
draw_pixel(xc-x, yc+y, colour) : Rem II. Quadrant
draw_pixel(xc+x, yc-y, colour) : Rem III. Quadrant
draw_pixel(xc-x, yc-y, colour) : Rem IV. Quadrant
If (filled) Then
For xd=xc-x to xc+x
draw_pixel (xd, yc+y, colour)
draw_pixel (xd, yc-y, colour)
Next xd
EndIf
If (sigma>= 0) Then
sigma += fa2*(1-y)
y=y-1
EndIf
sigma = sigma + b2*(4*x+6)
x=x+1
Wend
x=a
y=0
sigma = 2*a2+b2*(1-2*a)
While (a2*y <= b2*x)
draw_pixel(xc+x, yc+y, colour) : Rem I. Quadrant
draw_pixel(xc-x, yc+y, colour) : Rem II. Quadrant
draw_pixel(xc+x, yc-y, colour) : Rem III. Quadrant
draw_pixel(xc-x, yc-y, colour) : Rem IV. Quadrant
If (filled) Then
For xd=xc-x to xc+x
draw_pixel (xd, yc+y, colour)
draw_pixel (xd, yc-y, colour)
Next xd
EndIf
If (sigma>= 0) Then
sigma += fb2*(1-x)
x=x-1
EndIf
sigma = sigma + a2*(4*y+6)
y=y+1
Wend
End Sub
REM *************************************************************
REM **** Draw Ellipse Using Bresenham's algorithm ************
REM *************************************************************
Sub drawEllipse(ByVal x0 As Integer, ByVal y0 As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal colour as Integer, ByVal filled As Boolean = FALSE)
Dim As Integer a = Abs(x1-x0), b = Abs(y1-y0), b1, x : Rem values of diameter
Dim As Integer dx = 4*(1-a)*b*b, dy = 4*(b1+1)*a*a : Rem error increment
Dim As Integer errd = dx + dy + b1 * a * a, e2 : Rem error of 1.step
b1 = b And 1
if (x0 > x1) then
x0 = x1
x1 = x1 + a : Rem if called with swapped points
End If
if (y0 > y1) Then
y0 = y1 : Rem .. exchange them
End If
y0 = y0 + (b + 1) / 2
y1 = y0 - b1 : Rem starting pixel
a = a*(8*a)
b1 = 8*b*b
While (x0 <= x1)
draw_pixel(x1, y0, colour) : Rem I. Quadrant
draw_pixel(x0, y0, colour) : Rem II. Quadrant
draw_pixel(x0, y1, colour) : Rem III. Quadrant
draw_pixel(x1, y1, colour) : Rem IV. Quadrant
If (filled) Then
For x=x0 to x1
draw_pixel (x, y0, colour)
draw_pixel (x, y1, colour)
Next x
EndIf
e2 = 2*errd
If (e2 <= dy) Then
y0 = y0 + 1
y1 = y1 - 1
dy = dy + a
errd = errd + dy : rem y Step
End If
If (e2 >= dx Or 2*errd > dy) Then
x0 = x0 + 1
x1 = x1 - 1
dx = dx + b1
errd = errd + dx : rem x Step
End If
Wend
While (y0 - y1 < b) : Rem too early stop of flat ellipses a=1
draw_pixel(x0 - 1, y0, colour) : Rem -> finish tip of Ellipse
y0 = y0 + 1
draw_pixel(x1 + 1, y0, colour)
draw_pixel(x0 - 1, y1, colour)
y1 = y1 - 1
draw_pixel(x1 + 1, y1, colour)
Wend
End Sub
REM *************************************************************
REM **** Draw Line Using Bresenham's algorithm ************
REM *************************************************************
Sub drawLine (ByVal x0 as Integer, byval y0 as Integer, byval x1 as Integer, byval y1 as Integer, byval color_val As UByte)
Dim As integer dx,dy,x,y,sx,sy,errd,magic
Dim As boolean is_done
locate 1,1
Rem bounding box's width and height
dx = x1 - x0
dy = y1 - y0
Rem set the loop's sign
if (dx < 0) Then
dx = -dx
sx = -1
Else
sx = 1
End If
if (dy > 0) Then
dy = -dy
sy = 1
Else
sy = -1
End If
Rem set initial values
magic = 0
errd = dx + dy
x = x0
y = y0
is_done = FALSE
While (is_done = False)
Rem plot(x, y, color)
draw_pixel (x,y,color_val)
Rem Reached the End
If (x = x1 And y = y1) Then
is_done = TRUE
Else
is_done = FALSE
End If
Rem Loop carried
magic = errd shl 1
if (magic > dy) Then
errd += dy
x += sx
End If
if (magic < dx) Then
errd += dx
y += sy
End If
Wend
End Sub
REM *************************************************************
REM **** Read 256 color GPU 4444 palette memory ************
REM *************************************************************
Sub read_palette()
Open "palette.bin" For Binary Access Read As 1
for x1=0 to 255
get #1,,fdat(0), 1 : REM Little edian
get #1,,fdat(1), 1 : REM Little edian
func1 = fdat(0) and 15
pal_dat_r(x1) = func1*16+func1
func1 = int(fdat(1)/16) and 15
pal_dat_g(x1) = func1*16+func1
func1 = fdat(1) and 15
pal_dat_b(x1) = func1*16+func1
next x1
close #1
end sub
REM *************************************************************
REM **** Draw a dot with the palette color ************
REM *************************************************************
Sub draw_pixel(xp as integer, yp as integer, col as Ubyte)
PSet ( xp,yp ),rgb( pal_dat_r(col),pal_dat_g(col),pal_dat_b(col) )
if (show_pset) then ? xp,yp
end sub
Rem *************************************************************
REM **** Draw filled triangle algorithm ************
REM *************************************************************
Sub drawFilledTriangle (ByVal x0 as Integer, byval y0 as Integer, byval x1 as Integer, byval y1 as Integer, byval x2 as Integer, byval y2 as Integer, byval color_val As UByte)
Dim As Integer i,raster_Y_pos,raster_X_pos,next_face
locate 1,1 : show_pset = 0
? y0, : ? y1, : ? y2,
If (y0 >= y1 and y1 >= y2 ) Then
Locate out_y,1:? "y0>y1>y2", : out_y += 1
xa(0) = x2 : rem LineGen 0 start & end
ya(0) = y2
xb(0) = x0
yb(0) = y0
xa(1) = x2 : rem LineGen 1 start & end
ya(1) = y2
xb(1) = x1
yb(1) = y1
xa(2) = x1 : rem LineGen 2 start & end
ya(2) = y1
xb(2) = x0
yb(2) = y0
ElseIf (y1 >= y2 And y2 >= y0) Then
Locate out_y,1:? "y1>y2>y0", : out_y += 1
xa(0) = x0 : rem LineGen 0 start & end
ya(0) = y0
xb(0) = x1
yb(0) = y1
xa(1) = x0 : rem LineGen 1 start & end
ya(1) = y0
xb(1) = x2
yb(1) = y2
xa(2) = x2 : Rem LineGen 2 start & end
ya(2) = y2
xb(2) = x1
yb(2) = y1
ElseIf (y2 >= y0 And y0 >= y1) Then
Locate out_y,1:? "y2>y0>y1", : out_y += 1
xa(0) = x1 : rem LineGen 0 start & end
ya(0) = y1
xb(0) = x2
yb(0) = y2
xa(1) = x1 : rem LineGen 1 start & end
ya(1) = y1
xb(1) = x0
yb(1) = y0
xa(2) = x0 : rem LineGen 2 start & end
ya(2) = y0
xb(2) = x2
yb(2) = y2
ElseIf (y0 >= y2 And y2 >= y1) Then
Locate out_y,1:? "y0>y2>y1", : out_y += 1
xa(0) = x1 : rem LineGen 0 start & end
ya(0) = y1
xb(0) = x0
yb(0) = y0
xa(1) = x1 : rem LineGen 1 start & end
ya(1) = y1
xb(1) = x2
yb(1) = y2
xa(2) = x2 : rem LineGen 2 start & end
ya(2) = y2
xb(2) = x0
yb(2) = y0
ElseIf (y2 >= y1 And y1 >= y0) Then
Locate out_y,1:? "y2>y1>y0", : out_y += 1
xa(0) = x0 : rem LineGen 0 start & end
ya(0) = y0
xb(0) = x2
yb(0) = y2
xa(1) = x0 : rem LineGen 1 start & end
ya(1) = y0
xb(1) = x1
yb(1) = y1
xa(2) = x1 : rem LineGen 2 start & end
ya(2) = y1
xb(2) = x2
yb(2) = y2
ElseIf (y1 >= y0 And y0 >= y2) Then
Locate out_y,1:? "y1>y0>y2" : out_y += 1
xa(0) = x2 : rem LineGen 0 start & end
ya(0) = y2
xb(0) = x1
yb(0) = y1
xa(1) = x2 : rem LineGen 1 start & end
ya(1) = y2
xb(1) = x0
yb(1) = y0
xa(2) = x0 : rem LineGen 2 start & end
ya(2) = y0
xb(2) = x1
yb(2) = y1
EndIf
For i = 0 to 2 : Rem Setup all 3 line gens
setup_linegen_num ( i )
Next i
REM the integers 'next_face' and 'raster_X_pos' will be used for something.
next_face = 1
run_linegen_num ( 0, ya(0)+1, color_val ) : Rem start the triangle's first line
run_linegen_num ( 1, ya(0)+1, color_val ) : Rem start the triangle's second line
If ( yb(0) - ya(0) > 2 ) Then :REM If the triangles height is more than 2 pixels
For raster_Y_pos = ya(0)+1 to yb(0)-1
run_linegen_num ( 0, raster_Y_pos, color_val ) :REM draw first triangle line until raster_Y_pos
run_linegen_num ( next_face, raster_Y_pos, color_val ) :REM draw second or third triangle line until raster_Y_pos
Rem Only if there are any empty pixels to fill inbetween the 2 triangle edges, raster fill them in
If ( (xa(0)+2) <= xa(next_face) ) Then : Rem Check one direction
For raster_X_pos = xa(0) + 1 to xa(next_face) - 1
draw_pixel ( raster_X_pos, raster_Y_pos, color_val )
Next raster_X_pos
End If
If ( (xa(0)-2) >= xa(next_face) ) Then : Rem Check opposite direction
For raster_X_pos = xa(next_face) + 1 to xa(0) - 1
draw_pixel ( raster_X_pos, raster_Y_pos, color_val )
Next raster_X_pos
End If
Rem If the second triangle line reached it's end, finish second line and switch over to the third triangle line
If ( raster_Y_pos = yb(1) ) Then run_linegen_num ( 1, -1, color_val ) : next_face = 2
Next raster_Y_pos
EndIf
run_linegen_num ( 0, yb(0)+1, color_val ) : Rem finish the triangle's first line
run_linegen_num ( 2, yb(0)+1, color_val ) : Rem finish the triangle's third line
Locate 1,1 : show_pset = 0
End Sub
Sub setup_linegen_num ( byval i as integer )
Rem bounding box's width and height for the three line generators
Rem And set the loop's sign
dx(i) = xb(i) - xa(i)
dy(i) = yb(i) - ya(i)
If (dx(i) < 0) Then
dx(i) = -dx(i)
sx(i) = -1
Else
sx(i) = 1
End If
If (dy(i) > 0) Then
dy(i) = -dy(i)
sy(i) = 1
Else
sy(i) = -1
End If
magic(i) = 0
errd(i) = dx(i) + dy(i)
is_done(i) = 0
End Sub
Sub run_linegen_num ( byval i as integer, byval stop_Y_pos as integer, byval color_val as UByte )
While (is_done(i) = 0 and stop_Y_pos<>ya(i) )
draw_pixel (xa(i), ya(i), color_val)
Rem Reached the End
If (xa(i) = xb(i) And ya(i) = yb(i) ) Then
is_done(i) = 1
Else
is_done(i) = 0
End If
Rem Line 1 carried
magic(i) = errd(i) shl 1
if (magic(i) > dy(i)) Then
errd(i) += dy(i)
xa(i) += sx(i)
End If
if (magic(i) < dx(i)) Then
errd(i) += dx(i)
ya(i) += sy(i)
End If
Wend
End Sub
|
dim a
a = array( "great eastern", "roe", "stirling", "albany", "leach")
wscript.echo join(a,", ")
bubbleSort a
wscript.echo join(a,", ")
|
class ambiguous
dim sRule
public property let rule( x )
sRule = x
end property
public default function amb(p1, p2)
amb = eval(sRule)
end function
end class
|
' Q B a s i c G o r i l l a s
'
' Copyright (C) Microsoft Corporation 1990
'
' Your mission is to hit your opponent with the exploding banana
' by varying the angle and power of your throw, taking into account
' wind speed, gravity, and the city skyline.
'
' Speed of this game is determined by the constant SPEEDCONST. If the
' program is too slow or too fast adjust the "CONST SPEEDCONST = 500" line
' below. The larger the number the faster the game will go.
'
' To run this game, press Shift+F5.
'
' To exit QBasic, press Alt, F, X.
'
' To get help on a BASIC keyword, move the cursor to the keyword and press
' F1 or click the right mouse button.
'
'Set default data type to integer for faster game play
DEFINT A-Z
'Sub Declarations
DECLARE SUB DoSun (Mouth)
DECLARE SUB SetScreen ()
DECLARE SUB EndGame ()
DECLARE SUB Center (Row, Text$)
DECLARE SUB Intro ()
DECLARE SUB SparklePause ()
DECLARE SUB GetInputs (Player1$, Player2$, NumGames)
DECLARE SUB PlayGame (Player1$, Player2$, NumGames)
DECLARE SUB DoExplosion (x#, y#)
DECLARE SUB MakeCityScape (BCoor() AS ANY)
DECLARE SUB PlaceGorillas (BCoor() AS ANY)
DECLARE SUB UpdateScores (Record(), PlayerNum, Results)
DECLARE SUB DrawGorilla (x, y, arms)
DECLARE SUB GorillaIntro (Player1$, Player2$)
DECLARE SUB Rest (t#)
DECLARE SUB VictoryDance (Player)
DECLARE SUB ClearGorillas ()
DECLARE SUB DrawBan (xc#, yc#, r, bc)
DECLARE FUNCTION Scl (n!)
DECLARE FUNCTION GetNum# (Row, Col)
DECLARE FUNCTION DoShot (PlayerNum, x, y)
DECLARE FUNCTION ExplodeGorilla (x#, y#)
DECLARE FUNCTION Getn# (Row, Col)
DECLARE FUNCTION PlotShot (StartX, StartY, Angle#, Velocity, PlayerNum)
DECLARE FUNCTION CalcDelay! ()
'Make all arrays Dynamic
'$DYNAMIC
'User-Defined TYPEs
TYPE XYPoint
XCoor AS INTEGER
YCoor AS INTEGER
END TYPE
'Constants
CONST SPEEDCONST = 500
CONST TRUE = -1
CONST FALSE = NOT TRUE
CONST HITSELF = 1
CONST BACKATTR = 0
CONST OBJECTCOLOR = 1
CONST WINDOWCOLOR = 14
CONST SUNATTR = 3
CONST SUNHAPPY = FALSE
CONST SUNSHOCK = TRUE
CONST RIGHTUP = 1
CONST LEFTUP = 2
CONST ARMSDOWN = 3
'Global Variables
DIM SHARED GorillaX(1 TO 2) 'Location of the two gorillas
DIM SHARED GorillaY(1 TO 2)
DIM SHARED LastBuilding
DIM SHARED pi#
DIM SHARED LBan&(x), RBan&(x), UBan&(x), DBan&(x) 'Graphical picture of banana
DIM SHARED GorD&(120) 'Graphical picture of Gorilla arms down
DIM SHARED GorL&(120) 'Gorilla left arm raised
DIM SHARED GorR&(120) 'Gorilla right arm raised
DIM SHARED gravity#
DIM SHARED Wind
'Screen Mode Variables
DIM SHARED ScrHeight
DIM SHARED ScrWidth
DIM SHARED Mode
DIM SHARED MaxCol
'Screen Color Variables
DIM SHARED ExplosionColor
DIM SHARED SunColor
DIM SHARED BackColor
DIM SHARED SunHit
DIM SHARED SunHt
DIM SHARED GHeight
DIM SHARED MachSpeed AS SINGLE
DEF FnRan (x) = INT(RND(1) * x) + 1
DEF SEG = 0 ' Set NumLock to ON
KeyFlags = PEEK(1047)
IF (KeyFlags AND 32) = 0 THEN
POKE 1047, KeyFlags OR 32
END IF
DEF SEG
GOSUB InitVars
Intro
GetInputs Name1$, Name2$, NumGames
GorillaIntro Name1$, Name2$
PlayGame Name1$, Name2$, NumGames
DEF SEG = 0 ' Restore NumLock state
POKE 1047, KeyFlags
DEF SEG
END
CGABanana:
'BananaLeft
DATA 327686, -252645316, 60
'BananaDown
DATA 196618, -1057030081, 49344
'BananaUp
DATA 196618, -1056980800, 63
'BananaRight
DATA 327686, 1010580720, 240
EGABanana:
'BananaLeft
DATA 458758,202116096,471604224,943208448,943208448,943208448,471604224,202116096,0
'BananaDown
DATA 262153, -2134835200, -2134802239, -2130771968, -2130738945,8323072, 8323199, 4063232, 4063294
'BananaUp
DATA 262153, 4063232, 4063294, 8323072, 8323199, -2130771968, -2130738945, -2134835200,-2134802239
'BananaRight
DATA 458758, -1061109760, -522133504, 1886416896, 1886416896, 1886416896,-522133504,-1061109760,0
InitVars:
pi# = 4 * ATN(1#)
'This is a clever way to pick the best graphics mode available
ON ERROR GOTO ScreenModeError
Mode = 9
SCREEN Mode
ON ERROR GOTO PaletteError
IF Mode = 9 THEN PALETTE 4, 0 'Check for 64K EGA
ON ERROR GOTO 0
MachSpeed = CalcDelay
IF Mode = 9 THEN
ScrWidth = 640
ScrHeight = 350
GHeight = 25
RESTORE EGABanana
REDIM LBan&(8), RBan&(8), UBan&(8), DBan&(8)
FOR i = 0 TO 8
READ LBan&(i)
NEXT i
FOR i = 0 TO 8
READ DBan&(i)
NEXT i
FOR i = 0 TO 8
READ UBan&(i)
NEXT i
FOR i = 0 TO 8
READ RBan&(i)
NEXT i
SunHt = 39
ELSE
ScrWidth = 320
ScrHeight = 200
GHeight = 12
RESTORE CGABanana
REDIM LBan&(2), RBan&(2), UBan&(2), DBan&(2)
REDIM GorL&(20), GorD&(20), GorR&(20)
FOR i = 0 TO 2
READ LBan&(i)
NEXT i
FOR i = 0 TO 2
READ DBan&(i)
NEXT i
FOR i = 0 TO 2
READ UBan&(i)
NEXT i
FOR i = 0 TO 2
READ RBan&(i)
NEXT i
MachSpeed = MachSpeed * 1.3
SunHt = 20
END IF
RETURN
ScreenModeError:
IF Mode = 1 THEN
CLS
LOCATE 10, 5
PRINT "Sorry, you must have CGA, EGA color, or VGA graphics to play GORILLA.BAS"
END
ELSE
Mode = 1
RESUME
END IF
PaletteError:
Mode = 1 '64K EGA cards will run in CGA mode.
RESUME NEXT
REM $STATIC
'CalcDelay:
' Checks speed of the machine.
FUNCTION CalcDelay!
s! = TIMER
DO
i! = i! + 1
LOOP UNTIL TIMER - s! >= .5
CalcDelay! = i!
END FUNCTION
' Center:
' Centers and prints a text string on a given row
' Parameters:
' Row - screen row number
' Text$ - text to be printed
'
SUB Center (Row, Text$)
Col = MaxCol \ 2
LOCATE Row, Col - (LEN(Text$) / 2 + .5)
PRINT Text$;
END SUB
' DoExplosion:
' Produces explosion when a shot is fired
' Parameters:
' X#, Y# - location of explosion
'
SUB DoExplosion (x#, y#)
PLAY "MBO0L32EFGEFDC"
Radius = ScrHeight / 50
IF Mode = 9 THEN Inc# = .5 ELSE Inc# = .41
FOR c# = 0 TO Radius STEP Inc#
CIRCLE (x#, y#), c#, ExplosionColor
NEXT c#
FOR c# = Radius TO 0 STEP (-1 * Inc#)
CIRCLE (x#, y#), c#, BACKATTR
FOR i = 1 TO 100
NEXT i
Rest .005
NEXT c#
END SUB
' DoShot:
' Controls banana shots by accepting player input and plotting
' shot angle
' Parameters:
' PlayerNum - Player
' x, y - Player's gorilla position
'
FUNCTION DoShot (PlayerNum, x, y)
'Input shot
IF PlayerNum = 1 THEN
LocateCol = 1
ELSE
IF Mode = 9 THEN
LocateCol = 66
ELSE
LocateCol = 26
END IF
END IF
LOCATE 2, LocateCol
PRINT "Angle:";
Angle# = GetNum#(2, LocateCol + 7)
LOCATE 3, LocateCol
PRINT "Velocity:";
Velocity = GetNum#(3, LocateCol + 10)
IF PlayerNum = 2 THEN
Angle# = 180 - Angle#
END IF
'Erase input
FOR i = 1 TO 4
LOCATE i, 1
PRINT SPACE$(30 \ (80 \ MaxCol));
LOCATE i, (50 \ (80 \ MaxCol))
PRINT SPACE$(30 \ (80 \ MaxCol));
NEXT
SunHit = FALSE
PlayerHit = PlotShot(x, y, Angle#, Velocity, PlayerNum)
IF PlayerHit = 0 THEN
DoShot = FALSE
ELSE
DoShot = TRUE
IF PlayerHit = PlayerNum THEN PlayerNum = 3 - PlayerNum
VictoryDance PlayerNum
END IF
END FUNCTION
' DoSun:
' Draws the sun at the top of the screen.
' Parameters:
' Mouth - If TRUE draws "O" mouth else draws a smile mouth.
'
SUB DoSun (Mouth)
'set position of sun
x = ScrWidth \ 2: y = Scl(25)
'clear old sun
LINE (x - Scl(22), y - Scl(18))-(x + Scl(22), y + Scl(18)), BACKATTR, BF
'draw new sun:
'body
CIRCLE (x, y), Scl(12), SUNATTR
PAINT (x, y), SUNATTR
'rays
LINE (x - Scl(20), y)-(x + Scl(20), y), SUNATTR
LINE (x, y - Scl(15))-(x, y + Scl(15)), SUNATTR
LINE (x - Scl(15), y - Scl(10))-(x + Scl(15), y + Scl(10)), SUNATTR
LINE (x - Scl(15), y + Scl(10))-(x + Scl(15), y - Scl(10)), SUNATTR
LINE (x - Scl(8), y - Scl(13))-(x + Scl(8), y + Scl(13)), SUNATTR
LINE (x - Scl(8), y + Scl(13))-(x + Scl(8), y - Scl(13)), SUNATTR
LINE (x - Scl(18), y - Scl(5))-(x + Scl(18), y + Scl(5)), SUNATTR
LINE (x - Scl(18), y + Scl(5))-(x + Scl(18), y - Scl(5)), SUNATTR
'mouth
IF Mouth THEN 'draw "o" mouth
CIRCLE (x, y + Scl(5)), Scl(2.9), 0
PAINT (x, y + Scl(5)), 0, 0
ELSE 'draw smile
CIRCLE (x, y), Scl(8), 0, (210 * pi# / 180), (330 * pi# / 180)
END IF
'eyes
CIRCLE (x - 3, y - 2), 1, 0
CIRCLE (x + 3, y - 2), 1, 0
PSET (x - 3, y - 2), 0
PSET (x + 3, y - 2), 0
END SUB
'DrawBan:
' Draws the banana
'Parameters:
' xc# - Horizontal Coordinate
' yc# - Vertical Coordinate
' r - rotation position (0-3). ( \_/ ) /-\
' bc - if TRUE then DrawBan draws the banana ELSE it erases the banana
SUB DrawBan (xc#, yc#, r, bc)
SELECT CASE r
CASE 0
IF bc THEN PUT (xc#, yc#), LBan&, PSET ELSE PUT (xc#, yc#), LBan&, XOR
CASE 1
IF bc THEN PUT (xc#, yc#), UBan&, PSET ELSE PUT (xc#, yc#), UBan&, XOR
CASE 2
IF bc THEN PUT (xc#, yc#), DBan&, PSET ELSE PUT (xc#, yc#), DBan&, XOR
CASE 3
IF bc THEN PUT (xc#, yc#), RBan&, PSET ELSE PUT (xc#, yc#), RBan&, XOR
END SELECT
END SUB
'DrawGorilla:
' Draws the Gorilla in either CGA or EGA mode
' and saves the graphics data in an array.
'Parameters:
' x - x coordinate of gorilla
' y - y coordinate of the gorilla
' arms - either Left up, Right up, or both down
SUB DrawGorilla (x, y, arms)
DIM i AS SINGLE ' Local index must be single precision
'draw head
LINE (x - Scl(4), y)-(x + Scl(2.9), y + Scl(6)), OBJECTCOLOR, BF
LINE (x - Scl(5), y + Scl(2))-(x + Scl(4), y + Scl(4)), OBJECTCOLOR, BF
'draw eyes/brow
LINE (x - Scl(3), y + Scl(2))-(x + Scl(2), y + Scl(2)), 0
'draw nose if ega
IF Mode = 9 THEN
FOR i = -2 TO -1
PSET (x + i, y + 4), 0
PSET (x + i + 3, y + 4), 0
NEXT i
END IF
'neck
LINE (x - Scl(3), y + Scl(7))-(x + Scl(2), y + Scl(7)), OBJECTCOLOR
'body
LINE (x - Scl(8), y + Scl(8))-(x + Scl(6.9), y + Scl(14)), OBJECTCOLOR, BF
LINE (x - Scl(6), y + Scl(15))-(x + Scl(4.9), y + Scl(20)), OBJECTCOLOR, BF
'legs
FOR i = 0 TO 4
CIRCLE (x + Scl(i), y + Scl(25)), Scl(10), OBJECTCOLOR, 3 * pi# / 4, 9 * pi# / 8
CIRCLE (x + Scl(-6) + Scl(i - .1), y + Scl(25)), Scl(10), OBJECTCOLOR, 15 * pi# / 8, pi# / 4
NEXT
'chest
CIRCLE (x - Scl(4.9), y + Scl(10)), Scl(4.9), 0, 3 * pi# / 2, 0
CIRCLE (x + Scl(4.9), y + Scl(10)), Scl(4.9), 0, pi#, 3 * pi# / 2
FOR i = -5 TO -1
SELECT CASE arms
CASE 1
'Right arm up
CIRCLE (x + Scl(i - .1), y + Scl(14)), Scl(9), OBJECTCOLOR, 3 * pi# / 4, 5 * pi# / 4
CIRCLE (x + Scl(4.9) + Scl(i), y + Scl(4)), Scl(9), OBJECTCOLOR, 7 * pi# / 4, pi# / 4
GET (x - Scl(15), y - Scl(1))-(x + Scl(14), y + Scl(28)), GorR&
CASE 2
'Left arm up
CIRCLE (x + Scl(i - .1), y + Scl(4)), Scl(9), OBJECTCOLOR, 3 * pi# / 4, 5 * pi# / 4
CIRCLE (x + Scl(4.9) + Scl(i), y + Scl(14)), Scl(9), OBJECTCOLOR, 7 * pi# / 4, pi# / 4
GET (x - Scl(15), y - Scl(1))-(x + Scl(14), y + Scl(28)), GorL&
CASE 3
'Both arms down
CIRCLE (x + Scl(i - .1), y + Scl(14)), Scl(9), OBJECTCOLOR, 3 * pi# / 4, 5 * pi# / 4
CIRCLE (x + Scl(4.9) + Scl(i), y + Scl(14)), Scl(9), OBJECTCOLOR, 7 * pi# / 4, pi# / 4
GET (x - Scl(15), y - Scl(1))-(x + Scl(14), y + Scl(28)), GorD&
END SELECT
NEXT i
END SUB
'ExplodeGorilla:
' Causes gorilla explosion when a direct hit occurs
'Parameters:
' X#, Y# - shot location
FUNCTION ExplodeGorilla (x#, y#)
YAdj = Scl(12)
XAdj = Scl(5)
SclX# = ScrWidth / 320
SclY# = ScrHeight / 200
IF x# < ScrWidth / 2 THEN PlayerHit = 1 ELSE PlayerHit = 2
PLAY "MBO0L16EFGEFDC"
FOR i = 1 TO 8 * SclX#
CIRCLE (GorillaX(PlayerHit) + 3.5 * SclX# + XAdj, GorillaY(PlayerHit) + 7 * SclY# + YAdj), i, ExplosionColor, , , -1.57
LINE (GorillaX(PlayerHit) + 7 * SclX#, GorillaY(PlayerHit) + 9 * SclY# - i)-(GorillaX(PlayerHit), GorillaY(PlayerHit) + 9 * SclY# - i), ExplosionColor
NEXT i
FOR i = 1 TO 16 * SclX#
IF i < (8 * SclX#) THEN CIRCLE (GorillaX(PlayerHit) + 3.5 * SclX# + XAdj, GorillaY(PlayerHit) + 7 * SclY# + YAdj), (8 * SclX# + 1) - i, BACKATTR, , , -1.57
CIRCLE (GorillaX(PlayerHit) + 3.5 * SclX# + XAdj, GorillaY(PlayerHit) + YAdj), i, i MOD 2 + 1, , , -1.57
NEXT i
FOR i = 24 * SclX# TO 1 STEP -1
CIRCLE (GorillaX(PlayerHit) + 3.5 * SclX# + XAdj, GorillaY(PlayerHit) + YAdj), i, BACKATTR, , , -1.57
FOR Count = 1 TO 200
NEXT
NEXT i
ExplodeGorilla = PlayerHit
END FUNCTION
'GetInputs:
' Gets user inputs at beginning of game
'Parameters:
' Player1$, Player2$ - player names
' NumGames - number of games to play
SUB GetInputs (Player1$, Player2$, NumGames)
COLOR 7, 0
CLS
LOCATE 8, 15
LINE INPUT "Name of Player 1 (Default = 'Player 1'): "; Player1$
IF Player1$ = "" THEN
Player1$ = "Player 1"
ELSE
Player1$ = LEFT$(Player1$, 10)
END IF
LOCATE 10, 15
LINE INPUT "Name of Player 2 (Default = 'Player 2'): "; Player2$
IF Player2$ = "" THEN
Player2$ = "Player 2"
ELSE
Player2$ = LEFT$(Player2$, 10)
END IF
DO
LOCATE 12, 56: PRINT SPACE$(25);
LOCATE 12, 13
INPUT "Play to how many total points (Default = 3)"; game$
NumGames = VAL(LEFT$(game$, 2))
LOOP UNTIL NumGames > 0 AND LEN(game$) < 3 OR LEN(game$) = 0
IF NumGames = 0 THEN NumGames = 3
DO
LOCATE 14, 53: PRINT SPACE$(28);
LOCATE 14, 17
INPUT "Gravity in Meters/Sec (Earth = 9.8)"; grav$
gravity# = VAL(grav$)
LOOP UNTIL gravity# > 0 OR LEN(grav$) = 0
IF gravity# = 0 THEN gravity# = 9.8
END SUB
'GetNum:
' Gets valid numeric input from user
'Parameters:
' Row, Col - location to echo input
FUNCTION GetNum# (Row, Col)
Result$ = ""
Done = FALSE
WHILE INKEY$ <> "": WEND 'Clear keyboard buffer
DO WHILE NOT Done
LOCATE Row, Col
PRINT Result$; CHR$(95); " ";
Kbd$ = INKEY$
SELECT CASE Kbd$
CASE "0" TO "9"
Result$ = Result$ + Kbd$
CASE "."
IF INSTR(Result$, ".") = 0 THEN
Result$ = Result$ + Kbd$
END IF
CASE CHR$(13)
IF VAL(Result$) > 360 THEN
Result$ = ""
ELSE
Done = TRUE
END IF
CASE CHR$(8)
IF LEN(Result$) > 0 THEN
Result$ = LEFT$(Result$, LEN(Result$) - 1)
END IF
CASE ELSE
IF LEN(Kbd$) > 0 THEN
BEEP
END IF
END SELECT
LOOP
LOCATE Row, Col
PRINT Result$; " ";
GetNum# = VAL(Result$)
END FUNCTION
'GorillaIntro:
' Displays gorillas on screen for the first time
' allows the graphical data to be put into an array
'Parameters:
' Player1$, Player2$ - The names of the players
'
SUB GorillaIntro (Player1$, Player2$)
LOCATE 16, 34: PRINT "--------------"
LOCATE 18, 34: PRINT "V = View Intro"
LOCATE 19, 34: PRINT "P = Play Game"
LOCATE 21, 35: PRINT "Your Choice?"
DO WHILE Char$ = ""
Char$ = INKEY$
LOOP
IF Mode = 1 THEN
x = 125
y = 100
ELSE
x = 278
y = 175
END IF
SCREEN Mode
SetScreen
IF Mode = 1 THEN Center 5, "Please wait while gorillas are drawn."
VIEW PRINT 9 TO 24
IF Mode = 9 THEN PALETTE OBJECTCOLOR, BackColor
DrawGorilla x, y, ARMSDOWN
CLS 2
DrawGorilla x, y, LEFTUP
CLS 2
DrawGorilla x, y, RIGHTUP
CLS 2
VIEW PRINT 1 TO 25
IF Mode = 9 THEN PALETTE OBJECTCOLOR, 46
IF UCASE$(Char$) = "V" THEN
Center 2, "Q B A S I C G O R I L L A S"
Center 5, " STARRING: "
P$ = Player1$ + " AND " + Player2$
Center 7, P$
PUT (x - 13, y), GorD&, PSET
PUT (x + 47, y), GorD&, PSET
Rest 1
PUT (x - 13, y), GorL&, PSET
PUT (x + 47, y), GorR&, PSET
PLAY "t120o1l16b9n0baan0bn0bn0baaan0b9n0baan0b"
Rest .3
PUT (x - 13, y), GorR&, PSET
PUT (x + 47, y), GorL&, PSET
PLAY "o2l16e-9n0e-d-d-n0e-n0e-n0e-d-d-d-n0e-9n0e-d-d-n0e-"
Rest .3
PUT (x - 13, y), GorL&, PSET
PUT (x + 47, y), GorR&, PSET
PLAY "o2l16g-9n0g-een0g-n0g-n0g-eeen0g-9n0g-een0g-"
Rest .3
PUT (x - 13, y), GorR&, PSET
PUT (x + 47, y), GorL&, PSET
PLAY "o2l16b9n0baan0g-n0g-n0g-eeen0o1b9n0baan0b"
Rest .3
FOR i = 1 TO 4
PUT (x - 13, y), GorL&, PSET
PUT (x + 47, y), GorR&, PSET
PLAY "T160O0L32EFGEFDC"
Rest .1
PUT (x - 13, y), GorR&, PSET
PUT (x + 47, y), GorL&, PSET
PLAY "T160O0L32EFGEFDC"
Rest .1
NEXT
END IF
END SUB
'Intro:
' Displays game introduction
SUB Intro
SCREEN 0
WIDTH 80, 25
MaxCol = 80
COLOR 15, 0
CLS
Center 4, "Q B a s i c G O R I L L A S"
COLOR 7
Center 6, "Copyright (C) Microsoft Corporation 1990"
Center 8, "Your mission is to hit your opponent with the exploding"
Center 9, "banana by varying the angle and power of your throw, taking"
Center 10, "into account wind speed, gravity, and the city skyline."
Center 11, "The wind speed is shown by a directional arrow at the bottom"
Center 12, "of the playing field, its length relative to its strength."
Center 24, "Press any key to continue"
PLAY "MBT160O1L8CDEDCDL4ECC"
SparklePause
IF Mode = 1 THEN MaxCol = 40
END SUB
'MakeCityScape:
' Creates random skyline for game
'Parameters:
' BCoor() - a user-defined type array which stores the coordinates of
' the upper left corner of each building.
SUB MakeCityScape (BCoor() AS XYPoint)
x = 2
'Set the sloping trend of the city scape. NewHt is new building height
Slope = FnRan(6)
SELECT CASE Slope
CASE 1: NewHt = 15 'Upward slope
CASE 2: NewHt = 130 'Downward slope
CASE 3 TO 5: NewHt = 15 '"V" slope - most common
CASE 6: NewHt = 130 'Inverted "V" slope
END SELECT
IF Mode = 9 THEN
BottomLine = 335 'Bottom of building
HtInc = 10 'Increase value for new height
DefBWidth = 37 'Default building height
RandomHeight = 120 'Random height difference
WWidth = 3 'Window width
WHeight = 6 'Window height
WDifV = 15 'Counter for window spacing - vertical
WDifh = 10 'Counter for window spacing - horizontal
ELSE
BottomLine = 190
HtInc = 6
NewHt = NewHt * 20 \ 35 'Adjust for CGA
DefBWidth = 18
RandomHeight = 54
WWidth = 1
WHeight = 2
WDifV = 5
WDifh = 4
END IF
CurBuilding = 1
DO
SELECT CASE Slope
CASE 1
NewHt = NewHt + HtInc
CASE 2
NewHt = NewHt - HtInc
CASE 3 TO 5
IF x > ScrWidth \ 2 THEN
NewHt = NewHt - 2 * HtInc
ELSE
NewHt = NewHt + 2 * HtInc
END IF
CASE 4
IF x > ScrWidth \ 2 THEN
NewHt = NewHt + 2 * HtInc
ELSE
NewHt = NewHt - 2 * HtInc
END IF
END SELECT
'Set width of building and check to see if it would go off the screen
BWidth = FnRan(DefBWidth) + DefBWidth
IF x + BWidth > ScrWidth THEN BWidth = ScrWidth - x - 2
'Set height of building and check to see if it goes below screen
BHeight = FnRan(RandomHeight) + NewHt
IF BHeight < HtInc THEN BHeight = HtInc
'Check to see if Building is too high
IF BottomLine - BHeight <= MaxHeight + GHeight THEN BHeight = MaxHeight + GHeight - 5
'Set the coordinates of the building into the array
BCoor(CurBuilding).XCoor = x
BCoor(CurBuilding).YCoor = BottomLine - BHeight
IF Mode = 9 THEN BuildingColor = FnRan(3) + 4 ELSE BuildingColor = 2
'Draw the building, outline first, then filled
LINE (x - 1, BottomLine + 1)-(x + BWidth + 1, BottomLine - BHeight - 1), BACKGROUND, B
LINE (x, BottomLine)-(x + BWidth, BottomLine - BHeight), BuildingColor, BF
'Draw the windows
c = x + 3
DO
FOR i = BHeight - 3 TO 7 STEP -WDifV
IF Mode <> 9 THEN
WinColr = (FnRan(2) - 2) * -3
ELSEIF FnRan(4) = 1 THEN
WinColr = 8
ELSE
WinColr = WINDOWCOLOR
END IF
LINE (c, BottomLine - i)-(c + WWidth, BottomLine - i + WHeight), WinColr, BF
NEXT
c = c + WDifh
LOOP UNTIL c >= x + BWidth - 3
x = x + BWidth + 2
CurBuilding = CurBuilding + 1
LOOP UNTIL x > ScrWidth - HtInc
LastBuilding = CurBuilding - 1
'Set Wind speed
Wind = FnRan(10) - 5
IF FnRan(3) = 1 THEN
IF Wind > 0 THEN
Wind = Wind + FnRan(10)
ELSE
Wind = Wind - FnRan(10)
END IF
END IF
'Draw Wind speed arrow
IF Wind <> 0 THEN
WindLine = Wind * 3 * (ScrWidth \ 320)
LINE (ScrWidth \ 2, ScrHeight - 5)-(ScrWidth \ 2 + WindLine, ScrHeight - 5), ExplosionColor
IF Wind > 0 THEN ArrowDir = -2 ELSE ArrowDir = 2
LINE (ScrWidth / 2 + WindLine, ScrHeight - 5)-(ScrWidth / 2 + WindLine + ArrowDir, ScrHeight - 5 - 2), ExplosionColor
LINE (ScrWidth / 2 + WindLine, ScrHeight - 5)-(ScrWidth / 2 + WindLine + ArrowDir, ScrHeight - 5 + 2), ExplosionColor
END IF
END SUB
'PlaceGorillas:
' PUTs the Gorillas on top of the buildings. Must have drawn
' Gorillas first.
'Parameters:
' BCoor() - user-defined TYPE array which stores upper left coordinates
' of each building.
SUB PlaceGorillas (BCoor() AS XYPoint)
IF Mode = 9 THEN
XAdj = 14
YAdj = 30
ELSE
XAdj = 7
YAdj = 16
END IF
SclX# = ScrWidth / 320
SclY# = ScrHeight / 200
'Place gorillas on second or third building from edge
FOR i = 1 TO 2
IF i = 1 THEN BNum = FnRan(2) + 1 ELSE BNum = LastBuilding - FnRan(2)
BWidth = BCoor(BNum + 1).XCoor - BCoor(BNum).XCoor
GorillaX(i) = BCoor(BNum).XCoor + BWidth / 2 - XAdj
GorillaY(i) = BCoor(BNum).YCoor - YAdj
PUT (GorillaX(i), GorillaY(i)), GorD&, PSET
NEXT i
END SUB
'PlayGame:
' Main game play routine
'Parameters:
' Player1$, Player2$ - player names
' NumGames - number of games to play
SUB PlayGame (Player1$, Player2$, NumGames)
DIM BCoor(0 TO 30) AS XYPoint
DIM TotalWins(1 TO 2)
J = 1
FOR i = 1 TO NumGames
CLS
RANDOMIZE (TIMER)
CALL MakeCityScape(BCoor())
CALL PlaceGorillas(BCoor())
DoSun SUNHAPPY
Hit = FALSE
DO WHILE Hit = FALSE
J = 1 - J
LOCATE 1, 1
PRINT Player1$
LOCATE 1, (MaxCol - 1 - LEN(Player2$))
PRINT Player2$
Center 23, LTRIM$(STR$(TotalWins(1))) + ">Score<" + LTRIM$(STR$(TotalWins(2)))
Tosser = J + 1: Tossee = 3 - J
'Plot the shot. Hit is true if Gorilla gets hit.
Hit = DoShot(Tosser, GorillaX(Tosser), GorillaY(Tosser))
'Reset the sun, if it got hit
IF SunHit THEN DoSun SUNHAPPY
IF Hit = TRUE THEN CALL UpdateScores(TotalWins(), Tosser, Hit)
LOOP
SLEEP 1
NEXT i
SCREEN 0
WIDTH 80, 25
COLOR 7, 0
MaxCol = 80
CLS
Center 8, "GAME OVER!"
Center 10, "Score:"
LOCATE 11, 30: PRINT Player1$; TAB(50); TotalWins(1)
LOCATE 12, 30: PRINT Player2$; TAB(50); TotalWins(2)
Center 24, "Press any key to continue"
SparklePause
COLOR 7, 0
CLS
END SUB
'PlayGame:
' Plots banana shot across the screen
'Parameters:
' StartX, StartY - starting shot location
' Angle - shot angle
' Velocity - shot velocity
' PlayerNum - the banana thrower
FUNCTION PlotShot (StartX, StartY, Angle#, Velocity, PlayerNum)
Angle# = Angle# / 180 * pi# 'Convert degree angle to radians
Radius = Mode MOD 7
InitXVel# = COS(Angle#) * Velocity
InitYVel# = SIN(Angle#) * Velocity
oldx# = StartX
oldy# = StartY
'draw gorilla toss
IF PlayerNum = 1 THEN
PUT (StartX, StartY), GorL&, PSET
ELSE
PUT (StartX, StartY), GorR&, PSET
END IF
'throw sound
PLAY "MBo0L32A-L64CL16BL64A+"
Rest .1
'redraw gorilla
PUT (StartX, StartY), GorD&, PSET
adjust = Scl(4) 'For scaling CGA
xedge = Scl(9) * (2 - PlayerNum) 'Find leading edge of banana for check
Impact = FALSE
ShotInSun = FALSE
OnScreen = TRUE
PlayerHit = 0
NeedErase = FALSE
StartXPos = StartX
StartYPos = StartY - adjust - 3
IF PlayerNum = 2 THEN
StartXPos = StartXPos + Scl(25)
direction = Scl(4)
ELSE
direction = Scl(-4)
END IF
IF Velocity < 2 THEN 'Shot too slow - hit self
x# = StartX
y# = StartY
pointval = OBJECTCOLOR
END IF
DO WHILE (NOT Impact) AND OnScreen
Rest .02
'Erase old banana, if necessary
IF NeedErase THEN
NeedErase = FALSE
CALL DrawBan(oldx#, oldy#, oldrot, FALSE)
END IF
x# = StartXPos + (InitXVel# * t#) + (.5 * (Wind / 5) * t# ^ 2)
y# = StartYPos + ((-1 * (InitYVel# * t#)) + (.5 * gravity# * t# ^ 2)) * (ScrHeight / 350)
IF (x# >= ScrWidth - Scl(10)) OR (x# <= 3) OR (y# >= ScrHeight - 3) THEN
OnScreen = FALSE
END IF
IF OnScreen AND y# > 0 THEN
'check it
LookY = 0
LookX = Scl(8 * (2 - PlayerNum))
DO
pointval = POINT(x# + LookX, y# + LookY)
IF pointval = 0 THEN
Impact = FALSE
IF ShotInSun = TRUE THEN
IF ABS(ScrWidth \ 2 - x#) > Scl(20) OR y# > SunHt THEN ShotInSun = FALSE
END IF
ELSEIF pointval = SUNATTR AND y# < SunHt THEN
IF NOT SunHit THEN DoSun SUNSHOCK
SunHit = TRUE
ShotInSun = TRUE
ELSE
Impact = TRUE
END IF
LookX = LookX + direction
LookY = LookY + Scl(6)
LOOP UNTIL Impact OR LookX <> Scl(4)
IF NOT ShotInSun AND NOT Impact THEN
'plot it
rot = (t# * 10) MOD 4
CALL DrawBan(x#, y#, rot, TRUE)
NeedErase = TRUE
END IF
oldx# = x#
oldy# = y#
oldrot = rot
END IF
t# = t# + .1
LOOP
IF pointval <> OBJECTCOLOR AND Impact THEN
CALL DoExplosion(x# + adjust, y# + adjust)
ELSEIF pointval = OBJECTCOLOR THEN
PlayerHit = ExplodeGorilla(x#, y#)
END IF
PlotShot = PlayerHit
END FUNCTION
'Rest:
' pauses the program
SUB Rest (t#)
s# = TIMER
t2# = MachSpeed * t# / SPEEDCONST
DO
LOOP UNTIL TIMER - s# > t2#
END SUB
'Scl:
' Pass the number in to scaling for cga. If the number is a decimal, then we
' want to scale down for cga or scale up for ega. This allows a full range
' of numbers to be generated for scaling.
' (i.e. for 3 to get scaled to 1, pass in 2.9)
FUNCTION Scl (n!)
IF n! <> INT(n!) THEN
IF Mode = 1 THEN n! = n! - 1
END IF
IF Mode = 1 THEN
Scl = CINT(n! / 2 + .1)
ELSE
Scl = CINT(n!)
END IF
END FUNCTION
'SetScreen:
' Sets the appropriate color statements
SUB SetScreen
IF Mode = 9 THEN
ExplosionColor = 2
BackColor = 1
PALETTE 0, 1
PALETTE 1, 46
PALETTE 2, 44
PALETTE 3, 54
PALETTE 5, 7
PALETTE 6, 4
PALETTE 7, 3
PALETTE 9, 63 'Display Color
ELSE
ExplosionColor = 2
BackColor = 0
COLOR BackColor, 2
END IF
END SUB
'SparklePause:
' Creates flashing border for intro and game over screens
SUB SparklePause
COLOR 4, 0
A$ = "* * * * * * * * * * * * * * * * * "
WHILE INKEY$ <> "": WEND 'Clear keyboard buffer
WHILE INKEY$ = ""
FOR A = 1 TO 5
LOCATE 1, 1 'print horizontal sparkles
PRINT MID$(A$, A, 80);
LOCATE 22, 1
PRINT MID$(A$, 6 - A, 80);
FOR b = 2 TO 21 'Print Vertical sparkles
c = (A + b) MOD 5
IF c = 1 THEN
LOCATE b, 80
PRINT "*";
LOCATE 23 - b, 1
PRINT "*";
ELSE
LOCATE b, 80
PRINT " ";
LOCATE 23 - b, 1
PRINT " ";
END IF
NEXT b
NEXT A
WEND
END SUB
'UpdateScores:
' Updates players' scores
'Parameters:
' Record - players' scores
' PlayerNum - player
' Results - results of player's shot
SUB UpdateScores (Record(), PlayerNum, Results)
IF Results = HITSELF THEN
Record(ABS(PlayerNum - 3)) = Record(ABS(PlayerNum - 3)) + 1
ELSE
Record(PlayerNum) = Record(PlayerNum) + 1
END IF
END SUB
'VictoryDance:
' gorilla dances after he has eliminated his opponent
'Parameters:
' Player - which gorilla is dancing
SUB VictoryDance (Player)
FOR i# = 1 TO 4
PUT (GorillaX(Player), GorillaY(Player)), GorL&, PSET
PLAY "MFO0L32EFGEFDC"
Rest .2
PUT (GorillaX(Player), GorillaY(Player)), GorR&, PSET
PLAY "MFO0L32EFGEFDC"
Rest .2
NEXT
END SUB
|
<filename>Task/The-Twelve-Days-of-Christmas/VBA/the-twelve-days-of-christmas.vba
Sub Main()
Dim i As Integer, c As Integer, j As Integer, strReturn() As String
Dim s, n
s = Split(SING_, "$")
n = Split(NUMBERS_, " ")
ReDim strReturn(UBound(s))
For i = LBound(s) To UBound(s)
strReturn(i) = Replace(BASE_, "(X)", n(i))
For j = c To 0 Step -1
strReturn(i) = strReturn(i) & s(j) & vbCrLf
Next
c = c + 1
Next i
strReturn(UBound(strReturn)) = Replace(strReturn(UBound(strReturn)), "and" & vbCrLf & "A", vbCrLf & "And a")
Debug.Print Join(strReturn, vbCrLf)
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
Dim t_age(4,1)
t_age(0,0) = 27 : t_age(0,1) = "Jonah"
t_age(1,0) = 18 : t_age(1,1) = "Alan"
t_age(2,0) = 28 : t_age(2,1) = "Glory"
t_age(3,0) = 18 : t_age(3,1) = "Popeye"
t_age(4,0) = 28 : t_age(4,1) = "Alan"
Dim t_nemesis(4,1)
t_nemesis(0,0) = "Jonah" : t_nemesis(0,1) = "Whales"
t_nemesis(1,0) = "Jonah" : t_nemesis(1,1) = "Spiders"
t_nemesis(2,0) = "Alan" : t_nemesis(2,1) = "Ghosts"
t_nemesis(3,0) = "Alan" : t_nemesis(3,1) = "Zombies"
t_nemesis(4,0) = "Glory" : t_nemesis(4,1) = "Buffy"
Call hash_join(t_age,1,t_nemesis,0)
Sub hash_join(table_1,index_1,table_2,index_2)
Set hash = CreateObject("Scripting.Dictionary")
For i = 0 To UBound(table_1)
hash.Add i,Array(table_1(i,0),table_1(i,1))
Next
For j = 0 To UBound(table_2)
For Each key In hash.Keys
If hash(key)(index_1) = table_2(j,index_2) Then
WScript.StdOut.WriteLine hash(key)(0) & "," & hash(key)(1) &_
" = " & table_2(j,0) & "," & table_2(j,1)
End If
Next
Next
End Sub
|
<reponame>npocmaka/Windows-Server-2003<gh_stars>10-100
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form1
Caption = "GetAs Tester"
ClientHeight = 10350
ClientLeft = 60
ClientTop = 345
ClientWidth = 13410
LinkTopic = "Form1"
ScaleHeight = 10350
ScaleWidth = 13410
StartUpPosition = 3 'Windows Default
Begin VB.Frame ValueFrame
Caption = "Values"
Height = 8295
Left = 7560
TabIndex = 5
Top = 1680
Width = 5655
Begin MSFlexGridLib.MSFlexGrid Values
Height = 7575
Left = 240
TabIndex = 6
Top = 360
Width = 5175
_ExtentX = 9128
_ExtentY = 13361
_Version = 393216
Rows = 1
FixedCols = 0
GridColor = 255
SelectionMode = 1
AllowUserResizing= 1
End
End
Begin MSFlexGridLib.MSFlexGrid PropList
Height = 7575
Left = 600
TabIndex = 4
Top = 2040
Width = 6135
_ExtentX = 10821
_ExtentY = 13361
_Version = 393216
Rows = 1
Cols = 4
FixedCols = 0
GridColor = 16384
SelectionMode = 1
AllowUserResizing= 1
End
Begin VB.CommandButton Go
Caption = "Go"
Default = -1 'True
Height = 855
Left = 7560
TabIndex = 3
Top = 600
Width = 1455
End
Begin VB.Frame Properties
Caption = "Properties"
Height = 8295
Left = 240
TabIndex = 2
Top = 1680
Width = 6975
End
Begin VB.TextBox ObjectPath
Height = 375
Left = 480
TabIndex = 0
Text = "winmgmts:root\default:__cimomidentification=@"
Top = 840
Width = 6495
End
Begin VB.Frame Frame1
Caption = "Object Path"
Height = 975
Left = 240
TabIndex = 1
Top = 480
Width = 6975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim obj As SWbemObjectEx
Private Sub Form_Load()
PropList.ColWidth(0) = 2500
PropList.ColWidth(1) = 2000
PropList.ColWidth(2) = 1000
PropList.ColWidth(3) = 550
PropList.Row = 0
PropList.Col = 0
PropList.Text = "Property"
PropList.Col = 1
PropList.Text = "Type"
PropList.Col = 2
PropList.Text = "Array"
PropList.Col = 3
PropList.Text = "NULL"
PropList.AddItem ""
Values.ColWidth(0) = 2000
Values.ColWidth(1) = 3100
Values.Row = 0
Values.Col = 0
Values.Text = "Coercion Type"
Values.Col = 1
Values.Text = "Value"
Values.AddItem ""
End Sub
Private Sub Go_Click()
On Error GoTo ErrHandler:
Dim prop As SWbemPropertyEx
While PropList.Rows > 2
PropList.RemoveItem (PropList.Rows - 1)
Wend
While Values.Rows > 2
Values.RemoveItem (Values.Rows - 1)
Wend
ValueFrame.Caption = "Values"
Set obj = GetObject(ObjectPath.Text)
PropList.Row = 0
For Each prop In obj.Properties_
PropList.AddItem prop.Name & vbTab & CIMTypeToString(prop.cimType) & vbTab & prop.IsArray _
& vbTab & IsNull(prop.value)
Next
Exit Sub
ErrHandler:
MsgBox Err.Description + ": 0x" + Hex(Err.Number), vbOKOnly, "Error"
End Sub
Public Function CIMTypeToString(cimType) As String
Select Case cimType
Case wbemCimtypeBoolean:
CIMTypeToString = "wbemCimtypeBoolean"
Case wbemCimtypeChar16:
CIMTypeToString = "wbemCimtypeChar16"
Case wbemCimtypeDatetime:
CIMTypeToString = "wbemCimtypeDatetime"
Case wbemCimtypeObject:
CIMTypeToString = "wbemCimtypeObject"
Case wbemCimtypeIllegal:
CIMTypeToString = "wbemCimtypeIllegal"
Case wbemCimtypeReal32:
CIMTypeToString = "wbemCimtypeReal32"
Case wbemCimtypeReal64:
CIMTypeToString = "wbemCimtypeReal64"
Case wbemCimtypeReference:
CIMTypeToString = "wbemCimtypeReference"
Case wbemCimtypeSint16:
CIMTypeToString = "wbemCimtypeSint16"
Case wbemCimtypeSint32:
CIMTypeToString = "wbemCimtypeSint32"
Case wbemCimtypeSint64:
CIMTypeToString = "wbemCimtypeSint64"
Case wbemCimtypeSint8:
CIMTypeToString = "wbemCimtypeSint8"
Case wbemCimtypeString:
CIMTypeToString = "wbemCimtypeString"
Case wbemCimtypeUint16:
CIMTypeToString = "wbemCimtypeUint16"
Case wbemCimtypeUint32:
CIMTypeToString = "wbemCimtypeUint32"
Case wbemCimtypeUint64:
CIMTypeToString = "wbemCimtypeUint64"
Case wbemCimtypeUint8:
CIMTypeToString = "wbemCimtypeUint8"
Case wbemCimtypeIUnknown:
CIMTypeToString = "wbemCimtypeIUnknown"
End Select
End Function
Private Sub PropList_Click()
Dim propertyName As String
If PropList.Row > 1 Then
propertyName = PropList.Text
If Len(propertyName) > 0 Then
ValueFrame.Caption = "Values for " & propertyName
While Values.Rows > 2
Values.RemoveItem (Values.Rows - 1)
Wend
' Now do the coercion of the value
Dim property As SWbemPropertyEx
Set property = obj.Properties_(propertyName)
GetAs property, wbemCimtypeBoolean
GetAs property, wbemCimtypeChar16
GetAs property, wbemCimtypeDatetime
GetAs property, wbemCimtypeObject
GetAs property, wbemCimtypeIllegal
GetAs property, wbemCimtypeReal32
GetAs property, wbemCimtypeReal64
GetAs property, wbemCimtypeReference
GetAs property, wbemCimtypeSint16
GetAs property, wbemCimtypeSint32
GetAs property, wbemCimtypeSint64
GetAs property, wbemCimtypeSint8
GetAs property, wbemCimtypeString
GetAs property, wbemCimtypeUint16
GetAs property, wbemCimtypeUint32
GetAs property, wbemCimtypeUint64
GetAs property, wbemCimtypeUint8
GetAs property, wbemCimtypeIUnknown
End If
End If
End Sub
Private Sub GetAs(property, cimType)
On Error Resume Next
Dim value
Err.Clear
If (cimType <> wbemCimtypeObject) And (cimType <> wbemCimtypeIUnknown) Then
value = property.GetAs(cimType)
Else
Set value = property.GetAs(cimType)
End If
If Err <> 0 Then
Values.AddItem CIMTypeToString(cimType) & vbTab & Err.Description
Else
If (cimType <> wbemCimtypeObject) And (cimType <> wbemCimtypeIUnknown) Then
Values.AddItem CIMTypeToString(cimType) & vbTab & value
Else
Values.AddItem CIMTypeToString(cimType) & vbTab & "<object>"
End If
End If
Exit Sub
End Sub
Private Sub PropList_RowColChange()
PropList_Click
End Sub
|
Public Sub trig()
Pi = WorksheetFunction.Pi()
Debug.Print Sin(Pi / 2)
Debug.Print Sin(90 * Pi / 180)
Debug.Print Cos(0)
Debug.Print Cos(0 * Pi / 180)
Debug.Print Tan(Pi / 4)
Debug.Print Tan(45 * Pi / 180)
Debug.Print WorksheetFunction.Asin(1) * 2
Debug.Print WorksheetFunction.Asin(1) * 180 / Pi
Debug.Print WorksheetFunction.Acos(0) * 2
Debug.Print WorksheetFunction.Acos(0) * 180 / Pi
Debug.Print Atn(1) * 4
Debug.Print Atn(1) * 180 / Pi
End Sub
|
<reponame>npocmaka/Windows-Server-2003
Out "Starting..."
Set oLoc = CreateObject("WbemScripting.SWbemLocatorEx")
Set oDT = CreateObject("WbemScripting.SWbemDateTime")
Out "Created LocatorEx"
Set oObj = oLoc.Open("umi://nw01t1/ldap/.dc=com/.dc=microsoft/.dc=nttest/.dc=nw01t1dom/.cn=Users/.cn=TimeStamp", _
"nw01t1domnb\administrator", "nw01t1domnb")
Out "Bound to .CN=TimeStamp"
Out "Got Object " & oObj.Path_
Set oProps = oObj.Properties_
Out "accountExpires = " & oProps("accountExpires").Value & " (Should be 7/7/2000)"
'oDT.SetFileTIme oObj.accountExpires
'WScript.Echo oDT.GetFileTime
'WScript.Echo oDT.GetVarDate
Out "badPasswordTime = " & oProps("badPasswordTime").Value & " (Should be ~7pm 5/24/2000)"
oDT.SetFileTIme oObj.badPasswordTime
WScript.Echo oDT.GetFileTime
WScript.Echo oDT.GetVarDate
oDT.SetFileTIme oObj.badPasswordTime, false
WScript.Echo oDT.GetFileTime (false)
WScript.Echo oDT.GetVarDate
'Out "lastLogon = " & oProps("lastLogon").Value & " (Should be ~7pm 5/24/2000)"
'Out "pwdLastSet = " & oProps("pwdLastSet").Value & " (Should be ~7pm 5/24/2000)"
Sub Out(sLine)
WScript.Echo sLine
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
Option Explicit
Sub Main()
Dim p As String
p = length_encoding("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW")
Debug.Print p
Debug.Print length_decoding(p)
End Sub
Private Function length_encoding(S As String) As String
Dim F As String, r As String, a As String, n As Long, c As Long, k As Long
r = Left(S, 1)
c = 1
For n = 2 To Len(S)
If r <> Mid(S, n, 1) Then
a = a & c & r
r = Mid(S, n, 1)
c = 1
Else
c = c + 1
End If
Next
length_encoding = a & c & r
End Function
Private Function length_decoding(S As String) As String
Dim F As Long, r As String, a As String
For F = 1 To Len(S)
If IsNumeric(Mid(S, F, 1)) Then
r = r & Mid(S, F, 1)
Else
a = a & String(CLng(r), Mid(S, F, 1))
r = vbNullString
End If
Next
length_decoding = a
End Function
|
Sub varargs(ParamArray a())
For n = 0 To UBound(a)
Debug.Print a(n&)
Next
End Sub
|
<filename>Task/Null-object/VBA/null-object.vba
Public Sub Main()
Dim c As VBA.Collection
' initial state: Nothing
Debug.Print c Is Nothing
' create an instance
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
' release the instance
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
'
L_Welcome_MsgBox_Message_Text = "This script demonstrates how to access snapin property sheets 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
set WshShell = CreateObject("WScript.Shell")
snapins.Add "{58221c66-ea27-11cf-adcf-00aa00a80033}" ' the services snap-in
snapins.Add "{975797FC-4E2A-11D0-B702-00C04FD8DBF7}" ' eventlog snapin
' Get rootnode of the snapin
Set SnapNode1 = namespace.GetChild(rootnode)
view.ActiveScopeNode = SnapNode1
' Show properties of some services.
Call EnumerateAndShowProperties(view, SnapNode1)
' Now select eventlog snapin root, its scopenodes are in resultpane
Set SnapNode1 = namespace.GetNext(SnapNode1)
view.ActiveScopeNode = SnapNode1
' Show their (Application Log,...) properties.
Call EnumerateAndShowProperties(view, SnapNode1)
' Now select Application Log and show its properties.
Set SnapNode1 = namespace.GetChild(SnapNode1)
view.ActiveScopeNode = SnapNode1
view.DisplayScopeNodePropertySheet
WScript.Sleep 1000
WshShell.SendKeys "{ESC}" ' Close the prop sheet
' Now show the properties of LV items (VList)
Call EnumerateAndShowProperties(view, SnapNode1)
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
' ********************************************************************************
' *
' * EnumerateAndShowProperties
' *
Sub EnumerateAndShowProperties(view, SnapNode1)
Dim ResultItem
Dim Nodes
Set Nodes = view.ListItems
i = 0
' Now enumerate result pane items and ask for prop sheet
For Each ResultItem In Nodes
view.Select ResultItem
view.DisplaySelectionPropertySheet
WScript.Sleep 1000
WshShell.SendKeys "{ESC}" ' Close the prop sheet
view.Deselect ResultItem
i = i + 1
If i > 4 Then
Exit For
End If
Next
WshShell.SendKeys "{ESC}" ' Close the prop sheet
' view.SelectAll
End Sub
|
On Error Resume Next
Set t_Service = GetObject("winmgmts://./root/default")
Set t_Class = t_Service.Get("foo")
If Err = 0 Then
WScript.Echo "Connected OK"
Else
WScript.Echo "Error"
WScript.Echo Err.Number
WScript.Echo Err.Description
WScript.Echo Err.Source
'WScript.Echo "Failure: " + Err.Number + " " + Err.Description
Err.Clear
End If
|
Function ICE61()
Const UPGRADE_ATTRIBUTE_DETECTONLY = 2
Const UPGRADE_ATTRIBUTE_MININCLUSIVE = 256
Const UPGRADE_ATTRIBUTE_MAXINCLUSIVE = 512
Const UPGRADE_ATTRIBUTE_ALLINCLUSIVE = 768
Const colUpgradeCode = 1
Const colVersionMin = 2
Const colVersionMax = 3
Const colLanguage = 4
Const colAttributes = 5
Const colRemove = 6
Const colActionProperty = 7
On Error Resume Next
ICE61 = 1
'Give creation data
Set recinfo = installer.createrecord(1)
recinfo.StringData(0) = "ICE61" & Chr(9) & "3" & Chr(9) & "Created 05/03/1999. Last Modified 04/19/2001"
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
'Give description of test
recinfo.StringData(0) = "ICE61" & Chr(9) & "3" & Chr(9) & "Verifies various elements of the Upgrade table"
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
'Is there a Upgrade table in the database?
iStat = Database.TablePersistent("Upgrade")
If 1 <> iStat Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "3" & Chr(9) & "Table: 'Upgrade' missing. This product is not enabled for upgrading so ICE61 is not necessary."
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
Exit Function
End If
'Is there a Property table in the database?
iStat = Database.TablePersistent("Property")
If 1 <> iStat Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "2" & Chr(9) & "Table: 'Property' missing. ICE61 cannot continue its validation."
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
Exit Function
End If
'process Upgrade table
Set View = Database.OpenView("SELECT * FROM `Upgrade`")
View.Execute
Set recinfo = View.Fetch
If recinfo Is Nothing Then
Set recinfo = installer.createrecord(1)
recinfo.StringData(0) = "ICE61" & Chr(9) & "3" & Chr(9) & "Table: 'Upgrade' is empty. This database will not upgrade any product."
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
Exit Function
End If
'verify that all ActionProperty properties are not pre-authored
Set View = Database.OpenView("SELECT * FROM `Upgrade`, `Property` WHERE `ActionProperty`= `Property`")
View.Execute
Set recinfo = View.Fetch
While Not recinfo Is Nothing
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.ActionProperty [7] cannot be authored in the Property table." _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "ActionProperty" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
Set recinfo = View.Fetch
Wend
'verify that all ActionProperty properties are Public Properties
Set View = Database.OpenView("SELECT * FROM `Upgrade`")
View.Execute
Set recinfo = View.Fetch
While Not recinfo Is Nothing
If recinfo.StringData(colActionProperty) <> UCase(recinfo.StringData(colActionProperty)) Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.ActionProperty [7] must not contain lowercase letters." _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "ActionProperty" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
Set recinfo = View.Fetch
Wend
'verify that all ActionProperty properties are included in the SecureCustomProperties value
Set View = Database.OpenView("SELECT `Value` FROM `Property` WHERE `Property`= 'SecureCustomProperties'")
View.Execute
Set recinfo = View.Fetch
If recinfo Is Nothing Then
sSecureCustomProperties = ""
Else
sSecureCustomProperties = ";" & recinfo.StringData(1) & ";"
End If
Set View = Database.OpenView("SELECT * FROM `Upgrade`")
View.Execute
Set recinfo = View.Fetch
While Not recinfo Is Nothing
If InStr(sSecureCustomProperties, ";" & recinfo.StringData(colActionProperty) & ";") = 0 Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.ActionProperty [7] must be added to the SecureCustomProperties property." _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "ActionProperty" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
Set recinfo = View.Fetch
Wend
'verify that all ActionProperty properties are only used once
Set View = Database.OpenView("SELECT * FROM `Upgrade` ORDER BY `ActionProperty`")
View.Execute
sTestString = ""
Set recinfo = View.Fetch
While Not recinfo Is Nothing
If sTestString = recinfo.StringData(colActionProperty) Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.ActionProperty [7] may be used in only one record of the Upgrade table." _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "ActionProperty" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
sTestString = recinfo.StringData(colActionProperty)
Set recinfo = View.Fetch
Wend
'verify that all MinVersions are less than MaxVersions and that they are not both null
Dim bWrongVersionFormat
Set View = Database.OpenView("SELECT * FROM `Upgrade`")
View.Execute
Set recinfo = View.Fetch
While Not recinfo Is Nothing
If (Len(recinfo.StringData(colVersionMax)) > 0) And (Len(recinfo.StringData(colVersionMin)) > 0) Then
bWrongVersionFormat = False
If VersionStringToLong(recinfo.StringData(colVersionMax)) = -1 Then
bWrongVersionFormat = True
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.VersionMax [3] format is wrong" _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "VersionMax" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
If VersionStringToLong(recinfo.StringData(colVersionMin)) = -1 Then
bWrongVersionFormat = True
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.VersionMin [2] format is wrong" _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "VersionMin" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
If Not bWrongVersionFormat And VersionStringToLong(recinfo.StringData(colVersionMax)) < VersionStringToLong(recinfo.StringData(colVersionMin)) Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.VersionMax cannot be less than Upgrade.VersionMin. ([7])" _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "VersionMin" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
ElseIf Not bWrongVersionFormat And (VersionStringToLong(recinfo.StringData(colVersionMax)) = VersionStringToLong(recinfo.StringData(colVersionMin))) AND Not ((recinfo.integerdata(colAttributes) And UPGRADE_ATTRIBUTE_ALLINCLUSIVE) = UPGRADE_ATTRIBUTE_ALLINCLUSIVE) Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.VersionMax cannot be equal to Upgrade.VersionMin unless both Min and Max are inclusive, otherwise no version will match. ([7])" _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "VersionMin" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
ElseIf Len(recinfo.StringData(colVersionMax)) = 0 And Len(recinfo.StringData(colVersionMin)) = 0 Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.VersionMin and Upgrade.VersionMax cannot both be null. UpgradeCode is " & recinfo.StringData(colUpgradeCode) _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "UpgradeCode" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
Set recinfo = View.Fetch
Wend
'verify that no attempt is made to uninstall a newer product
sUC = "": sPV = "": lPV = 0
Set View = Database.OpenView("SELECT `Value` FROM `Property` WHERE `Property`= 'UpgradeCode'")
View.Execute
Set recinfo = View.Fetch
If recinfo Is Nothing Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Property: An UpgradeCode must be authored in the Property table." _
& Chr(9) & Chr(9) & "Property" & Chr(9) & "Value" & Chr(9) & "UpgradeCode"
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
Else
sUC = recinfo.StringData(1)
End If
Set View = Database.OpenView("SELECT `Value` FROM `Property` WHERE `Property`= 'ProductVersion'")
View.Execute
Set recinfo = View.Fetch
If recinfo Is Nothing Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Property: A ProductVersion must be authored in the Property table." _
& Chr(9) & Chr(9) & "Property" & Chr(9) & "Value" & Chr(9) & "ProductVersion"
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
Else
sPV = recinfo.StringData(1): lPV = VersionStringToLong(sPV)
End If
Set View = Database.OpenView("SELECT * FROM `Upgrade` WHERE `UpgradeCode`= '" & sUC & "'")
View.Execute
Set recinfo = View.Fetch
While Not recinfo Is Nothing
If Not ((recinfo.integerdata(colAttributes) And UPGRADE_ATTRIBUTE_DETECTONLY) = UPGRADE_ATTRIBUTE_DETECTONLY) Then
If Len(recinfo.StringData(colVersionMax)) Then
If (((recinfo.integerdata(colAttributes) And UPGRADE_ATTRIBUTE_MAXINCLUSIVE) And VersionStringToLong(recinfo.StringData(colVersionMax)) >= lPV) Or ((Not (recinfo.integerdata(colAttributes) And UPGRADE_ATTRIBUTE_MAXINCLUSIVE) And VersionStringToLong(recinfo.StringData(colVersionMax)) > lPV))) Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "2" & Chr(9) & "This product should remove only older versions of itself. The Maximum version is not less than the current product. ([3] " & sPV & ")" _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "Attributes" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
Else
recinfo.StringData(0) = "ICE61" & Chr(9) & "2" & Chr(9) & "This product should remove only older versions of itself. No Maximum version was detected for the current product. ([7])" _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "Attributes" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
End If
Set recinfo = View.Fetch
Wend
'Verify that UpgradeCode contains valid GUIDs.
Set View = Database.OpenView("SELECT * FROM `Upgrade`")
View.Execute
Set recinfo = View.Fetch
While Not recinfo Is Nothing
If Not IsValidGUID(recinfo.StringData(colUpgradeCode)) Then
recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "In Upgrade table UpgradeCode [1] is not a valid GUID" _
& Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "UpgradeCode" & Chr(9) & recinfo.StringData(colUpgradeCode) _
& Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
& Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
'Debug.Print recinfo.formattext
Message &H3000000, recinfo
ICE61 = 1
End If
Set recinfo = View.Fetch
Wend
End Function
'Returns -1 if the version number format is wrong
Function VersionStringToLong(strng)
Dim i, iPos, sAccum, sTemp
On Error Resume Next
sTemp = strng
While Left(sTemp, 1) <> ""
If InStr("0123456789.", Left(sTemp, 1)) = 0 Then VersionStringToLong = -1: Exit Function
sTemp = Mid(sTemp, 2)
Wend
sTemp = strng
iPos = InStr(sTemp & ".", ".")
If CInt(Left(sTemp, iPos - 1)) >= 255 Then VersionStringToLong = -1: Exit Function
sAccum = "&H" & Right("00" & Hex(CInt(Left(sTemp, iPos - 1))), 2)
If Err.Number > 0 Then VersionStringToLong = -1: Exit Function
sTemp = Mid(sTemp & ".", iPos + 1)
If sTemp <> "" Then
iPos = InStr(sTemp & ".", ".")
If CInt(Left(sTemp, iPos - 1)) >= 255 Then VersionStringToLong = -1: Exit Function
sAccum = sAccum & Right("00" & Hex(CInt(Left(sTemp, iPos - 1))), 2)
If Err.Number > 0 Then VersionStringToLong = -1: Exit Function
sTemp = Mid(sTemp & ".", iPos + 1)
If sTemp <> "" Then
iPos = InStr(sTemp & ".", ".")
If CInt(Left(sTemp, iPos - 1)) >= 65535 Then VersionStringToLong = -1: Exit Function
sAccum = sAccum & Right("0000" & Hex(CInt(Left(sTemp, iPos - 1))), 4)
If Err.Number > 0 Then VersionStringToLong = -1: Exit Function
End If
End If
VersionStringToLong = CLng(sAccum)
Exit Function
End Function
Function IsValidGUID(sGuid)
'If sGuid's length is not 38, it's not valid.
If Len(sGuid) <> 38 Then
IsValidGUID = False
Exit Function
End If
'If sGuid doesn't begin with "{", end with "}", or contains any non-hex digits then it is not valid
For i = 1 to 38
If i = 1 Then
If Mid(sGuid, i, 1) <> "{" Then
IsValidGUID = False
Exit Function
End If
ElseIf i = 38 Then
If Mid(sGuid, i, 1) <> "}" Then
IsValidGUID = False
Exit Function
End If
ElseIf i = 10 Or i = 15 Or i = 20 Or i = 25 Then
If Mid(sGuid, i, 1) <> "-" Then
IsValidGUID = False
Exit Function
End If
Else
If InStr("0123456789ABCDEF", Mid(sGuid, i, 1)) = 0 Then
IsValidGUID = False
Exit Function
End If
End If
Next
IsValidGUID = True
Exit Function
End Function
|
<reponame>LaudateCorpus1/RosettaCodeData
Public Function RangeExtraction(AList) As String
'AList is a variant that is an array, assumed filled with numbers in ascending order
Const RangeDelim = "-" 'range delimiter
Dim result As String
Dim InRange As Boolean
Dim Posn, ub, lb, rangestart, rangelen As Integer
result = ""
'find dimensions of AList
ub = UBound(AList)
lb = LBound(AList)
Posn = lb
While Posn < ub
rangestart = Posn
rangelen = 0
InRange = True
'try to extend the range
While InRange
rangelen = rangelen + 1
If Posn = ub Then
InRange = False
Else
InRange = (AList(Posn + 1) = AList(Posn) + 1)
Posn = Posn + 1
End If
Wend
If rangelen > 2 Then 'output the range if it has more than 2 elements
result = result & "," & Format$(AList(rangestart)) & RangeDelim & Format$(AList(rangestart + rangelen - 1))
Else 'output the separate elements
For i = rangestart To rangestart + rangelen - 1
result = result & "," & Format$(AList(i))
Next
End If
Posn = rangestart + rangelen
Wend
RangeExtraction = Mid$(result, 2) 'get rid of first comma!
End Function
Public Sub RangeTest()
'test function RangeExtraction
'first test with a Variant array
Dim MyList As Variant
MyList = Array(0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39)
Debug.Print "a) "; RangeExtraction(MyList)
'next test with an array of integers
Dim MyOtherList(1 To 20) As Integer
MyOtherList(1) = -6
MyOtherList(2) = -3
MyOtherList(3) = -2
MyOtherList(4) = -1
MyOtherList(5) = 0
MyOtherList(6) = 1
MyOtherList(7) = 3
MyOtherList(8) = 4
MyOtherList(9) = 5
MyOtherList(10) = 7
MyOtherList(11) = 8
MyOtherList(12) = 9
MyOtherList(13) = 10
MyOtherList(14) = 11
MyOtherList(15) = 14
MyOtherList(16) = 15
MyOtherList(17) = 17
MyOtherList(18) = 18
MyOtherList(19) = 19
MyOtherList(20) = 20
Debug.Print "b) "; RangeExtraction(MyOtherList)
End Sub
|
With CreateObject("Scripting.FileSystemObject")
WScript.Echo .GetFile("input.txt").Size
WScript.Echo .GetFile("\input.txt").Size
End With
|
<gh_stars>10-100
'***************************************************************************
'This script tests the manipulation of property values, in the case that the
'property is an array type
'***************************************************************************
Set Service = GetObject("winmgmts:root/default")
On Error Resume Next
Set aClass = Service.Get()
aClass.Path_.Class = "ARRAYPROP00"
Set Property = aClass.Properties_.Add ("p1", 19, true)
Property.Value = Array (12, 787, 34124)
str = "The initial value of p1 is {"
for x=LBound(aClass.Properties_("p1")) to UBound(aClass.Properties_("p1"))
str = str & aClass.Properties_("p1")(x)
if x <> UBound(aClass.Properties_("p1")) Then
str = str & ", "
End if
next
str = str & "}"
WScript.Echo str
'****************************************
'First pass of tests works on non-dot API
'****************************************
WScript.Echo ""
WScript.Echo "PASS 1 - Use Non-Dot Notation"
WScript.Echo ""
'Verify we can report the value of an element of the property value
v = aClass.Properties_("p1")
WScript.Echo "By indirection the first element of p1 had value:",v(0)
'Verify we can report the value directly
WScript.Echo "By direct access the first element of p1 has value:", aClass.Properties_("p1")(0)
'Verify we can set the value of a single property value element
aClass.Properties_("p1")(1) = 234
WScript.Echo "After direct assignment the first element of p1 has value:", aClass.Properties_("p1")(1)
'Verify we can set the value of a single property value element
Set v = aClass.Properties_("p1")
v(1) = 345
WScript.Echo "After indirect assignment the first element of p1 has value:", aClass.Properties_("p1")(1)
'Verify we can set the value of an entire property value
aClass.Properties_("p1") = Array (5, 34, 178871)
WScript.Echo "After direct array assignment the first element of p1 has value:", aClass.Properties_("p1")(1)
str = "After direct assignment the entire value of p1 is {"
for x=LBound(aClass.Properties_("p1")) to UBound(aClass.Properties_("p1"))
str = str & aClass.Properties_("p1")(x)
if x <> UBound(aClass.Properties_("p1")) Then
str = str & ", "
End if
next
str = str & "}"
WScript.Echo str
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
'****************************************
'Second pass of tests works on dot API
'****************************************
WScript.Echo ""
WScript.Echo "PASS 2 - Use Dot Notation"
WScript.Echo ""
'Verify we can report the array of a property using the dot notation
str = "By direct access via the dot notation the entire value of p1 is {"
for x=LBound(aClass.p1) to UBound(aClass.p1)
str = str & aClass.p1(x)
if x <> UBound(aClass.p1) Then
str = str & ", "
End if
next
str = str & "}"
WScript.Echo str
'Verify we can report the value of a property array element using the "dot" notation
WScript.Echo "By direct access the first element of p1 has value:", aClass.p1(0)
'Verify we can report the value of a property array element using the "dot" notation
v = aClass.p1
WScript.Echo "By indirect access the first element of p1 has value:", v(0)
'Verify we can set the value of a property array element using the "dot" notation
WScript.Echo "By direct access the second element of p1 has been set to:", aClass.p1(2)
aClass.p1(2) = 8889
WScript.Echo "By direct access the second element of p1 has been set to:", aClass.p1(2)
'Verify we can set the entire array value using dot notation
aClass.p1 = Array (412, 3, 544)
str = "By direct access via the dot notation the entire value of p1 has been set to {"
for x=LBound(aClass.p1) to UBound(aClass.p1)
str = str & aClass.p1(x)
if x <> UBound(aClass.p1) Then
str = str & ", "
End if
next
str = str & "}"
WScript.Echo str
'Service.Put (aClass)
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
|
wscript.echo eef(pangram("a quick brown fox jumps over the lazy dog"), "is a pangram", "is not a pangram")
wscript.echo eef(pangram(""), "is a pangram", "is not a pangram")"
|
<gh_stars>10-100
VERSION 5.00
Begin VB.Form Form1
Caption = "Derivation Browser"
ClientHeight = 5400
ClientLeft = 60
ClientTop = 345
ClientWidth = 7305
LinkTopic = "Form1"
ScaleHeight = 5400
ScaleWidth = 7305
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Button
Caption = "OK"
Default = -1 'True
Height = 375
Left = 2520
TabIndex = 4
Top = 1560
Width = 2295
End
Begin VB.Frame Frame1
Caption = "Derivation"
Height = 2775
Left = 480
TabIndex = 2
Top = 2160
Width = 6255
Begin VB.ListBox Derivation
Enabled = 0 'False
Height = 2010
Left = 360
TabIndex = 3
Top = 360
Width = 5655
End
End
Begin VB.Frame Object
Caption = "Object"
Height = 975
Left = 480
TabIndex = 0
Top = 360
Width = 6255
Begin VB.TextBox ObjectPath
Height = 495
Left = 240
TabIndex = 1
Text = "Win32_LogicalDisk"
Top = 360
Width = 5775
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Button_Click()
Derivation.Clear
Dim Disk As SWbemObject
Set Disk = GetObject("winmgmts:" & ObjectPath.Text)
Dim D As Variant
D = Disk.Derivation_
Dim V As String
For x = LBound(D) To UBound(D)
Derivation.AddItem (D(x))
Next
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
Private Function Knuth(a As Variant) As Variant
Dim t As Variant, i As Integer
If Not IsMissing(a) Then
For i = UBound(a) To LBound(a) + 1 Step -1
j = Int((UBound(a) - LBound(a) + 1) * Rnd + LBound(a))
t = a(i)
a(i) = a(j)
a(j) = t
Next i
End If
Knuth = a
End Function
Private Function inOrder(s As Variant)
i = 2
Do While i <= UBound(s)
If s(i) < s(i - 1) Then
inOrder = False
Exit Function
End If
i = i + 1
Loop
inOrder = True
End Function
Private Function bogosort(ByVal s As Variant) As Variant
Do While Not inOrder(s)
Debug.Print Join(s, ", ")
s = Knuth(s)
Loop
bogosort = s
End Function
Public Sub main()
Debug.Print Join(bogosort(Knuth([{1,2,3,4,5,6}])), ", ")
End Sub
|
Include "%INCLUDE%\StrFuncs.vbs"
Function Include ( ByVal file )
Dim wso: Set wso = CreateObject("Wscript.Shell")
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
ExecuteGlobal(fso.OpenTextFile(wso.ExpandEnvironmentStrings(file)).ReadAll)
End Function
|
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()
'***************************************************************************
'This script tests the manipulation of property values, in the case that the
'property is an array type
'***************************************************************************
Dim Service As SWbemServices
Dim Class As SWbemObject
Dim P As SWbemProperty
Set Service = GetObject("winmgmts:root/default")
On Error Resume Next
Set Class = Service.Get()
Class.Path_.Class = "ARRAYPROP00"
Set P = Class.Properties_.Add("p1", wbemCimtypeUint32, True)
P.Value = Array(1, 2, 3)
myStr = "The initial value of p1 is {"
For x = LBound(P.Value) To UBound(P.Value)
myStr = myStr & Class.Properties_("p1")(x)
If x <> UBound(Class.Properties_("p1").Value) Then
myStr = myStr & ", "
End If
Next
myStr = myStr & "}"
Debug.Print myStr
'****************************************
'First pass of tests works on non-dot API
'****************************************
'Verify we can report the value of an element of the property value
v = Class.Properties_("p1")
Debug.Print "By indirection the first element of p1 had value:" & v(0)
'Verify we can report the value directly
Debug.Print "By direct access the first element of p1 has value:" & Class.Properties_("p1")(0)
'Verify we can set the value of a single property value element
' this won't work because VB will use the vtable interface
Class.Properties_("p1")(1) = 234
Debug.Print "After direct assignment the first element of p1 has value:" & Class.Properties_("p1")(1)
'Verify we can set the value of a single property value element
'this does work because v is typeless and VB therefore uses the dispatch interface
Set v = Class.Properties_("p1")
v(1) = 345
Debug.Print "After indirect assignment the first element of p1 has value:" & Class.Properties_("p1")(1)
'Verify we can set the value of an entire property value
Class.Properties_("p1") = Array(5, 34, 178871)
Debug.Print "After direct array assignment the first element of p1 has value:" & Class.Properties_("p1")(1)
myStr = "After direct assignment the entire value of p1 is {"
For x = LBound(P.Value) To UBound(P.Value)
myStr = myStr & Class.Properties_("p1")(x)
If x <> UBound(P.Value) Then
myStr = myStr & ", "
End If
Next
myStr = myStr & "}"
Debug.Print myStr
If Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End If
'****************************************
'Second pass of tests works on dot API
'****************************************
'Verify we can report the array of a property using the dot notation
myStr = "By direct access via the dot notation the entire value of p1 is {"
For x = LBound(Class.p1) To UBound(Class.p1)
myStr = myStr & Class.p1(x)
If x <> UBound(Class.p1) Then
myStr = myStr & ", "
End If
Next
myStr = myStr & "}"
Debug.Print myStr
'Verify we can report the value of a property array element using the "dot" notation
Debug.Print "By direct access the first element of p1 has value:" & Class.p1(0)
'Verify we can report the value of a property array element using the "dot" notation
v = Class.p1
Debug.Print "By direct access the first element of p1 has value:" & v(0)
'Verify we can set the value of a property array element using the "dot" notation
Class.p1(2) = 8889
Debug.Print "By direct access the second element of p1 has been set to:" & Class.p1(2)
'Verify we can set the entire array value using dot notation
Class.p1 = Array(412, 3, 544)
myStr = "By direct access via the dot notation the entire value of p1 has been set to {"
For x = LBound(Class.p1) To UBound(Class.p1)
myStr = myStr & Class.p1(x)
If x <> UBound(Class.p1) Then
myStr = myStr & ", "
End If
Next
myStr = myStr & "}"
Debug.Print myStr
'Service.Put (Class)
If Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End If
'Set C = S.Get("a")
'v = C.p(0)
'C.p = vbEmpty
'VV = C.p(0)
'S.Put C
End Sub
|
<gh_stars>1-10
If condition1 Then
statement
End If
If condition1 Then
statement
ElseIf condition2 Then
statement
...
ElseIf conditionN Then
statement
Else
statement
End If
|
<reponame>npocmaka/Windows-Server-2003<gh_stars>10-100
' Script: createBackupSched.vbs
' Description: Implements backup schedule for UDDI database
' Author: <NAME> (<EMAIL>)
' Date: 10/11/00
' Changes:
' 11-13-2000: lrdohert - added WITH INIT option to backup jobs as per bug 712
Option Explicit
Dim oXML
Dim oSQLServer, oBackupDevice, oJobServer, oJob, oJobSchedule, oJobStep
Dim strServer, strDatabase, strBackupDir
Dim strDbBackupDevName, strDbJobName, strBaseLogBackupDevName, strBaseLogJobName
Dim dtNow
strDbBackupDevName = "UDDI_DB_BACKUP_DEV"
strDbJobName = "UDDI_DB_BACKUP_JOB"
strBaseLogBackupDevName = "UDDI_LOG_BACKUP_DEV"
strBaseLogJobName = "UDDI_LOG_BACKUP_JOB"
WScript.Echo "Starting createBackupSched.vbs exection....."
Err.Clear
If WScript.arguments.Count <> 3 Then
WScript.Echo "Msg: Invalid number of arguments passed."
WScript.Quit
End If
strServer = WScript.Arguments(0)
strDatabase = WScript.Arguments(1)
strBackupDir = WScript.Arguments(2)
' Connect to SQL Server
Set oSQLServer = CreateObject("SQLDMO.SQLServer2")
With oSQLServer
.LoginSecure = True
.Connect strServer
End With
' Delete old backup devices
For Each oBackupDevice In oSQLServer.BackupDevices
If oBackupDevice.Name = strDbBackupDevName Then
oBackupDevice.Remove
End If
Next
' Create new database backup device
Set oBackupDevice = CreateObject("SQLDMO.BackupDevice")
With oBackupDevice
.Name = strDbBackupDevName
.Type = 2 ' SQLDMO_Device_DiskDump
.PhysicalLocation = strBackupDir + "\" + strDbBackupDevName + ".bak"
End With
oSQLServer.BackupDevices.Add(oBackupDevice)
' Create transaction log backup devices
CreateLogDumpDevices strBackupDir, strBaseLogBackupDevName, 23
'
' Connect to SQL Agent
'
Set oJobServer = oSQLServer.JobServer
' Check to see if SQL Agent is running
If oJobServer.Status <> 1 Then
WScript.Echo "Msg: SQL Agent is not running. Cannot create backup schedule."
WScript.Quit
End If
' Delete old jobs if they exist
For Each oJob In oJobServer.Jobs
If oJob.Name = strDbJobName Then
oJob.Remove
End If
Next
' Create new Database Backup Job
Set oJob = CreateObject("SQLDMO.Job")
With oJob
.Name = strDbJobName
End With
oJobServer.Jobs.Add(oJob)
Set oJob=oJobServer.Jobs(strDbJobName)
Set oJobSchedule = CreateObject("SQLDMO.JobSchedule")
dtNow = Now()
With oJobSchedule
.Name = "Daily"
.Schedule.ActiveStartDate=(DatePart("yyyy",dtNow) * 10000) + (DatePart("m",dtNow) * 100) + DatePart("d",dtNow)
.Schedule.ActiveStartTimeOfDay=000000
.Schedule.FrequencyType=4 ' SQLDMOFreq_Daily
.Schedule.FrequencyInterval=1
End With
oJob.JobSchedules.Add(oJobSchedule)
Set oJobStep = CreateObject("SQLDMO.JobStep")
With oJobStep
.Name="BACKUP DATABASE"
.Command="BACKUP DATABASE " + strDatabase + " TO " + strDbBackupDevName + " WITH INIT"
.StepID=1
End With
oJob.JobSteps.Add(oJobStep)
oJob.ApplyToTargetServer "(local)"
' Create the backup log jobs
CreateLogBackupJobs strDatabase, strBaseLogJobName, strBaseLogBackupDevName, 23
' Run the database backup job
Set oJob = oJobServer.Jobs(strDbJobName)
oJob.Invoke
WScript.Echo "Ending createBackupSched.vbs exection......"
Sub CreateLogDumpDevices(strBackupDir, strBaseName, intNumLogs)
Dim i
Dim strI
For i = 1 to intNumLogs
If Len(CStr(i)) = 1 Then
strI = "0" + CStr(i)
Else
strI = Cstr(i)
End If
' Delete backup device if it exists
For Each oBackupDevice In oSQLServer.BackupDevices
If oBackupDevice.Name = (strBaseName + "_" + strI) Then
oBackupDevice.Remove
End If
Next
Set oBackupDevice = CreateObject("SQLDMO.BackupDevice")
With oBackupDevice
.Name = strBaseName + "_" + strI
.Type = 2 ' SQLDMO_Device_DiskDump
.PhysicalLocation = strBackupDir + "\" + strBaseName + "_" + strI + ".bak"
End With
oSQLServer.BackupDevices.Add(oBackupDevice)
Next
End Sub
Sub CreateLogBackupJobs(strDatabase, strBaseJobName, strBaseDevName, intNumJobs)
Dim i
Dim strJobName, strDevName
Dim dtNow
For i = 1 to intNumJobs
If Len(CStr(i)) = 1 Then
strJobName = strBaseJobName + "_0" + CStr(i)
strDevName = strBaseDevName + "_0" + CStr(i)
Else
strJobName = strBaseJobName + "_" + CStr(i)
strDevName = strBaseDevName + "_" + CStr(i)
End If
' Delete old jobs if they exist
For Each oJob In oJobServer.Jobs
If oJob.Name = strJobName Then
oJob.Remove
End If
Next
' Create new Log Backup Job
Set oJob = CreateObject("SQLDMO.Job")
With oJob
.Name = strJobName
End With
oJobServer.Jobs.Add(oJob)
Set oJob=oJobServer.Jobs(strJobName)
Set oJobSchedule = CreateObject("SQLDMO.JobSchedule")
dtNow = Now()
With oJobSchedule
.Name = "Daily"
.Schedule.ActiveStartDate=(DatePart("yyyy",dtNow) * 10000) + (DatePart("m",dtNow) * 100) + DatePart("d",dtNow)
.Schedule.ActiveStartTimeOfDay=(i * 10000)
.Schedule.FrequencyType=4 ' SQLDMOFreq_Daily
.Schedule.FrequencyInterval=1
End With
oJob.JobSchedules.Add(oJobSchedule)
Set oJobStep = CreateObject("SQLDMO.JobStep")
With oJobStep
.Name=strDevName
.Command="BACKUP LOG " + strDatabase + " TO " + strDevName + " WITH INIT"
.StepID=1
End With
oJob.JobSteps.Add(oJobStep)
oJob.ApplyToTargetServer "(local)"
Next
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData
Private Function call_fn(f As String, n As Long) As Long
call_fn = Application.Run(f, f, n)
End Function
Private Function Y(f As String) As String
Y = f
End Function
Private Function fac(self As String, n As Long) As Long
If n > 1 Then
fac = n * call_fn(self, n - 1)
Else
fac = 1
End If
End Function
Private Function fib(self As String, n As Long) As Long
If n > 1 Then
fib = call_fn(self, n - 1) + call_fn(self, n - 2)
Else
fib = n
End If
End Function
Private Sub test(name As String)
Dim f As String: f = Y(name)
Dim i As Long
Debug.Print name
For i = 1 To 10
Debug.Print call_fn(f, i);
Next i
Debug.Print
End Sub
Public Sub main()
test "fac"
test "fib"
End Sub
|
'***************************************************************************
'This script tests the enumeration of subclasses using XML/HTTP
'***************************************************************************
On Error Resume Next
Dim objLocator
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
' Replace the first argument to this function with the URL of your WMI XML/HTTP server
' For the local machine, use the URL as below
Dim objService
Set objService = objLocator.ConnectServer("[http://localhost/cimom]", "root\cimv2")
for each subclass in objService.SubclassesOf ("cim_UserDevice")
WScript.Echo "Subclass name:", subclass.Path_.Class
next
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
|
<filename>Task/Order-two-numerical-lists/VBA/order-two-numerical-lists.vba
Private Function order(list1 As Variant, list2 As Variant) As Boolean
i = 1
Do While list1(i) <= list2(i)
i = i + 1
If i > UBound(list1) Then
order = True
Exit Function
End If
If i > UBound(list2) Then
order = False
Exit Function
End If
Loop
order = False
End Function
Public Sub main()
Debug.Print order([{1, 2, 3, 4}], [{1,2,0,1,2}])
Debug.Print order([{1, 2, 3, 4}], [{1,2,3}])
Debug.Print order([{1, 2, 3}], [{1,2,3,4}])
End Sub
|
'YYYY-MM-DD format
WScript.StdOut.WriteLine Year(Date) & "-" & Right("0" & Month(Date),2) & "-" & Right("0" & Day(Date),2)
'Weekday_Name, Month_Name DD, YYYY format
WScript.StdOut.WriteLine FormatDateTime(Now,1)
|
Function CountStringInString(stLookIn As String, stLookFor As String)
CountStringInString = UBound(Split(stLookIn, stLookFor))
End Function
|
function shuffle( a )
dim i
dim r
randomize timer
for i = lbound( a ) to ubound( a )
r = int( rnd * ( ubound( a ) + 1 ) )
if r <> i then
swap a(i), a(r)
end if
next
shuffle = a
end function
sub swap( byref a, byref b )
dim tmp
tmp = a
a = b
b = tmp
end sub
|
Attribute VB_Name = "Module1"
Option Explicit
Sub Main()
End Sub
|
Function multsum35(n)
For i = 1 To n - 1
If i Mod 3 = 0 Or i Mod 5 = 0 Then
multsum35 = multsum35 + i
End If
Next
End Function
WScript.StdOut.Write multsum35(CLng(WScript.Arguments(0)))
WScript.StdOut.WriteLine
|
<reponame>LaudateCorpus1/RosettaCodeData
'stack test
Public Sub stacktest()
Dim aStack As New Stack
With aStack
'push and pop some value
.Push 45
.Push 123.45
.Pop
.Push "a string"
.Push "another string"
.Pop
.Push Cos(0.75)
Debug.Print "stack size is "; .Size
While Not .IsEmpty
Debug.Print "pop: "; .Pop
Wend
Debug.Print "stack size is "; .Size
'try to continue popping
.Pop
End With
End Sub
|
<filename>Task/Palindrome-detection/VBA/palindrome-detection.vba
Public Function isPalindrome(aString as string) as Boolean
dim tempstring as string
tempstring = Lcase(Replace(aString, " ", ""))
isPalindrome = (tempstring = Reverse(tempstring))
End Function
|
<reponame>npocmaka/Windows-Server-2003<gh_stars>10-100
'----------------------------------------------------------------------
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
' Abstract:
' prnjobs.vbs - job control script for WMI on Whistler
' used to pause, resume, cancel and list jobs
'
' Usage:
' prnjobs [-zmxl?] [-s server] [-p printer] [-j jobid] [-u user name] [-w password]
'
' Examples:
' prnjobs -z -j jobid -p printer
' prnjobs -l -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 kActionPause = 1
const kActionResume = 2
const kActionCancel = 3
const kActionList = 4
const kErrorSuccess = 0
const KErrorFailure = 1
const kNameSpace = "root\cimv2"
'
' Job status constants
'
const kJobPaused = 1
const kJobError = 2
const kJobDeleting = 4
const kJobSpooling = 8
const kJobPrinting = 16
const kJobOffline = 32
const kJobPaperOut = 64
const kJobPrinted = 128
const kJobDeleted = 256
const kJobBlockedDevq = 512
const kJobUserInt = 1024
const kJobRestarted = 2048
const kJobComplete = 4096
'
' 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:"
'
' General usage messages
'
const L_Help_Help_General01_Text = "Usage: prnjobs [-zmxl?] [-s server][-p printer][-j jobid][-u user name][-w password]"
const L_Help_Help_General02_Text = "Arguments:"
const L_Help_Help_General03_Text = "-j - job id"
const L_Help_Help_General04_Text = "-l - list all jobs"
const L_Help_Help_General05_Text = "-m - resume the job"
const L_Help_Help_General06_Text = "-p - printer name"
const L_Help_Help_General07_Text = "-s - server name"
const L_Help_Help_General08_Text = "-u - user name"
const L_Help_Help_General09_Text = "-w - password"
const L_Help_Help_General10_Text = "-x - cancel the job"
const L_Help_Help_General11_Text = "-z - pause the job"
const L_Help_Help_General12_Text = "-? - display command usage"
const L_Help_Help_General13_Text = "Examples:"
const L_Help_Help_General14_Text = "prnjobs -z -p printer -j jobid"
const L_Help_Help_General15_Text = "prnjobs -l -p printer"
const L_Help_Help_General16_Text = "prnjobs -l"
'
' 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 = "Unable to enumerate print jobs"
const L_Text_Msg_General02_Text = "Number of print jobs enumerated"
const L_Text_Msg_General03_Text = "Unable to set print job"
const L_Text_Msg_General04_Text = "Unable to get SWbemLocator object"
const L_Text_Msg_General05_Text = "Unable to connect to WMI service"
'
' Print job properties
'
const L_Text_Msg_Job01_Text = "Job id"
const L_Text_Msg_Job02_Text = "Printer"
const L_Text_Msg_Job03_Text = "Document"
const L_Text_Msg_Job04_Text = "Data type"
const L_Text_Msg_Job05_Text = "Driver name"
const L_Text_Msg_Job06_Text = "Description"
const L_Text_Msg_Job07_Text = "Elapsed time"
const L_Text_Msg_Job08_Text = "Machine name"
const L_Text_Msg_Job09_Text = "Notify"
const L_Text_Msg_Job10_Text = "Owner"
const L_Text_Msg_Job11_Text = "Pages printed"
const L_Text_Msg_Job12_Text = "Parameters"
const L_Text_Msg_Job13_Text = "Size"
const L_Text_Msg_Job14_Text = "Start time"
const L_Text_Msg_Job15_Text = "Until time"
const L_Text_Msg_Job16_Text = "Status"
const L_Text_Msg_Job17_Text = "Time submitted"
const L_Text_Msg_Job18_Text = "Total pages"
'
' Job status strings
'
const L_Text_Msg_Status01_Text = "The driver cannot print the job"
const L_Text_Msg_Status02_Text = "Sent to the printer"
const L_Text_Msg_Status03_Text = "Job has been deleted"
const L_Text_Msg_Status04_Text = "Job is being deleted"
const L_Text_Msg_Status05_Text = "An error is associated with the job"
const L_Text_Msg_Status06_Text = "Printer is offline"
const L_Text_Msg_Status07_Text = "Printer is out of paper"
const L_Text_Msg_Status08_Text = "Job is paused"
const L_Text_Msg_Status09_Text = "Job has printed"
const L_Text_Msg_Status10_Text = "Job is printing"
const L_Text_Msg_Status11_Text = "Job has been restarted"
const L_Text_Msg_Status12_Text = "Job is spooling"
const L_Text_Msg_Status13_Text = "Printer has an error that requires user intervention"
'
' Action strings
'
const L_Text_Action_General01_Text = "Pause"
const L_Text_Action_General02_Text = "Resume"
const L_Text_Action_General03_Text = "Cancel"
'
' Debug messages
'
const L_Text_Dbg_Msg01_Text = "In function ListJobs"
const L_Text_Dbg_Msg02_Text = "In function ExecJob"
const L_Text_Dbg_Msg03_Text = "In function ParseCommandLine"
main
'
' Main execution starts here
'
sub main
dim iAction
dim iRetval
dim strServer
dim strPrinter
dim strJob
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
iRetval = ParseCommandLine(iAction, strServer, strPrinter, strJob, strUser, strPassword)
if iRetval = kErrorSuccess then
select case iAction
case kActionPause
iRetval = ExecJob(strServer, strJob, strPrinter, strUser, strPassword, L_Text_Action_General01_Text)
case kActionResume
iRetval = ExecJob(strServer, strJob, strPrinter, strUser, strPassword, L_Text_Action_General02_Text)
case kActionCancel
iRetval = ExecJob(strServer, strJob, strPrinter, strUser, strPassword, L_Text_Action_General03_Text)
case kActionList
iRetval = ListJobs(strServer, strPrinter, strUser, strPassword)
case else
Usage(true)
exit sub
end select
end if
end sub
'
' Enumerate all print jobs on a printer
'
function ListJobs(strServer, strPrinter, strUser, strPassword)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg01_Text
dim Jobs
dim oJob
dim oService
dim iRetval
dim strTemp
dim iTotal
if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then
set Jobs = oService.InstancesOf("Win32_PrintJob")
else
ListJobs = kErrorFailure
exit function
end if
if Err.Number <> kErrorSuccess then
wscript.echo L_Text_Msg_General01_Text & L_Space_Text & L_Error_Text & L_Space_Text _
& L_Hex_Text & hex(Err.Number) & L_Space_Text & Err.Description
ListJobs = kErrorFailure
exit function
end if
iTotal = 0
for each oJob in Jobs
'
' oJob.Name has the form "printer name, job id". We are isolating the printer name
'
strTemp = Mid(oJob.Name, 1, InStr(1, oJob.Name, ",", 1)-1 )
'
' If no printer was specified, then enumerate all jobs
'
if strPrinter = null or strPrinter = "" or LCase(strTemp) = LCase(strPrinter) then
iTotal = iTotal + 1
wscript.echo L_Empty_Text
wscript.echo L_Text_Msg_Job01_Text & L_Space_Text & oJob.JobId
wscript.echo L_Text_Msg_Job02_Text & L_Space_Text & strTemp
wscript.echo L_Text_Msg_Job03_Text & L_Space_Text & oJob.Document
wscript.echo L_Text_Msg_Job04_Text & L_Space_Text & oJob.DataType
wscript.echo L_Text_Msg_Job05_Text & L_Space_Text & oJob.DriverName
wscript.echo L_Text_Msg_Job06_Text & L_Space_Text & oJob.Description
wscript.echo L_Text_Msg_Job07_Text & L_Space_Text & Mid(CStr(oJob.ElapsedTime), 9, 2) & ":" _
& Mid(CStr(oJob.ElapsedTime), 11, 2) & ":" _
& Mid(CStr(oJob.ElapsedTime), 13, 2)
wscript.echo L_Text_Msg_Job08_Text & L_Space_Text & oJob.HostPrintQueue
wscript.echo L_Text_Msg_Job09_Text & L_Space_Text & oJob.Notify
wscript.echo L_Text_Msg_Job10_Text & L_Space_Text & oJob.Owner
wscript.echo L_Text_Msg_Job11_Text & L_Space_Text & oJob.PagesPrinted
wscript.echo L_Text_Msg_Job12_Text & L_Space_Text & oJob.Parameters
wscript.echo L_Text_Msg_Job13_Text & L_Space_Text & oJob.Size
if CStr(oJob.StartTime) <> "********000000.000000+000" and _
CStr(oJob.UntilTime) <> "********000000.000000+000" then
wscript.echo L_Text_Msg_Job14_Text & L_Space_Text & Mid(Mid(CStr(oJob.StartTime), 9, 4), 1, 2) & "h" _
& Mid(Mid(CStr(oJob.StartTime), 9, 4), 3, 2)
wscript.echo L_Text_Msg_Job15_Text & L_Space_Text & Mid(Mid(CStr(oJob.UntilTime), 9, 4), 1, 2) & "h" _
& Mid(Mid(CStr(oJob.UntilTime), 9, 4), 3, 2)
end if
wscript.echo L_Text_Msg_Job16_Text & L_Space_Text & JobStatusToString(oJob.StatusMask)
wscript.echo L_Text_Msg_Job17_Text & L_Space_Text & Mid(CStr(oJob.TimeSubmitted), 5, 2) & "/" _
& Mid(CStr(oJob.TimeSubmitted), 7, 2) & "/" _
& Mid(CStr(oJob.TimeSubmitted), 1, 4) & " " _
& Mid(CStr(oJob.TimeSubmitted), 9, 2) & ":" _
& Mid(CStr(oJob.TimeSubmitted), 11, 2) & ":" _
& Mid(CStr(oJob.TimeSubmitted), 13, 2)
wscript.echo L_Text_Msg_Job19_Text & L_Space_Text & oJob.TotalPages
Err.Clear
end if
next
wscript.echo L_Empty_Text
wscript.echo L_Text_Msg_General02_Text & L_Space_Text & iTotal
ListJobs = kErrorSuccess
end function
'
' Convert the job status from bit mask to string
'
function JobStatusToString(Status)
on error resume next
dim strString
strString = L_Empty_Text
if (Status and kJobPaused) = kJobPaused then strString = strString & L_Text_Msg_Status08_Text & L_Space_Text end if
if (Status and kJobError) = kJobError then strString = strString & L_Text_Msg_Status05_Text & L_Space_Text end if
if (Status and kJobDeleting) = kJobDeleting then strString = strString & L_Text_Msg_Status04_Text & L_Space_Text end if
if (Status and kJobSpooling) = kJobSpooling then strString = strString & L_Text_Msg_Status12_Text & L_Space_Text end if
if (Status and kJobPrinting) = kJobPrinting then strString = strString & L_Text_Msg_Status10_Text & L_Space_Text end if
if (Status and kJobOffline) = kJobOffline then strString = strString & L_Text_Msg_Status06_Text & L_Space_Text end if
if (Status and kJobPaperOut) = kJobPaperOut then strString = strString & L_Text_Msg_Status07_Text & L_Space_Text end if
if (Status and kJobPrinted) = kJobPrinted then strString = strString & L_Text_Msg_Status09_Text & L_Space_Text end if
if (Status and kJobDeleted) = kJobDeleted then strString = strString & L_Text_Msg_Status03_Text & L_Space_Text end if
if (Status and kJobBlockedDevq) = kJobBlockedDevq then strString = strString & L_Text_Msg_Status01_Text & L_Space_Text end if
if (Status and kJobUserInt) = kJobUserInt then strString = strString & L_Text_Msg_Status13_Text & L_Space_Text end if
if (Status and kJobRestarted) = kJobRestarted then strString = strString & L_Text_Msg_Status11_Text & L_Space_Text end if
if (Status and kJobComplete) = kJobComplete then strString = strString & L_Text_Msg_Status02_Text & L_Space_Text end if
JobStatusToString = strString
end function
'
' Pause/Resume/Cancel jobs
'
function ExecJob(strServer, strJob, strPrinter, strUser, strPassword, strCommand)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg02_Text
dim oJob
dim oService
dim iRetval
dim uResult
dim strName
'
' Build up the key. The key for print jobs is "printer-name, job-id"
'
strName = strPrinter & ", " & strJob
iRetval = kErrorFailure
if WmiConnect(strServer, kNameSpace, strUser, strPassword, oService) then
set oJob = oService.Get("Win32_PrintJob.Name='" & strName & "'")
else
ExecJob = kErrorFailure
exit function
end if
'
' Check if getting job instance succeeded
'
if Err.Number = kErrorSuccess then
uResult = kErrorSuccess
select case strCommand
case L_Text_Action_General01_Text
uResult = oJob.Pause()
case L_Text_Action_General02_Text
uResult = oJob.Resume()
case L_Text_Action_General03_Text
oJob.Delete_()
case else
Usage(true)
end select
if Err.Number = kErrorSuccess then
if uResult = kErrorSuccess then
wscript.echo L_Success_Text & L_Space_Text & strCommand & L_Space_Text _
& L_Text_Msg_Job01_Text & L_Space_Text & strJob _
& L_Space_Text & L_Printer_Text & L_Space_Text & strPrinter
iRetval = kErrorSuccess
else
wscript.echo L_Failed_Text & L_Space_Text & strCommand & L_Space_Text _
& L_Text_Error_General03_Text & L_Space_Text & uResult
end if
else
wscript.echo L_Text_Msg_General03_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
else
wscript.echo L_Text_Msg_General03_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
ExecJob = iRetval
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, strJob, strUser, strPassword)
on error resume next
DebugPrint kDebugTrace, L_Text_Dbg_Msg03_Text
dim oArgs
dim iIndex
iAction = kActionUnknown
iIndex = 0
set oArgs = wscript.Arguments
while iIndex < oArgs.Count
select case oArgs(iIndex)
case "-z"
iAction = kActionPause
case "-m"
iAction = kActionResume
case "-x"
iAction = kActionCancel
case "-l"
iAction = kActionList
case "-p"
iIndex = iIndex + 1
strPrinter = oArgs(iIndex)
case "-s"
iIndex = iIndex + 1
strServer = RemoveBackslashes(oArgs(iIndex))
case "-j"
iIndex = iIndex + 1
strJob = oArgs(iIndex)
case "-u"
iIndex = iIndex + 1
strUser = oArgs(iIndex)
case "-w"
iIndex = iIndex + 1
strPassword = oArgs(iIndex)
case "-?"
Usage(true)
exit function
case else
Usage(true)
exit function
end select
iIndex = iIndex + 1
wend
if Err.Number = 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_Empty_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_Empty_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
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_General05_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_General04_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
'' SIG '' Begin signature block
'' SIG '' MIIZMAYJKoZIhvcNAQcCoIIZITCCGR0CAQExDjAMBggq
'' SIG '' hkiG9w0CBQUAMGYGCisGAQQBgjcCAQSgWDBWMDIGCisG
'' SIG '' AQQBgjcCAR4wJAIBAQQQTvApFpkntU2P5azhDxfrqwIB
'' SIG '' AAIBAAIBAAIBAAIBADAgMAwGCCqGSIb3DQIFBQAEENjz
'' SIG '' 96n5MChPNOn81WwOE+igghQ4MIICvDCCAiUCEEoZ0jiM
'' SIG '' glkcpV1zXxVd3KMwDQYJKoZIhvcNAQEEBQAwgZ4xHzAd
'' SIG '' BgNVBAoTFlZlcmlTaWduIFRydXN0IE5ldHdvcmsxFzAV
'' SIG '' BgNVBAsTDlZlcmlTaWduLCBJbmMuMSwwKgYDVQQLEyNW
'' SIG '' ZXJpU2lnbiBUaW1lIFN0YW1waW5nIFNlcnZpY2UgUm9v
'' SIG '' dDE0MDIGA1UECxMrTk8gTElBQklMSVRZIEFDQ0VQVEVE
'' SIG '' LCAoYyk5NyBWZXJpU2lnbiwgSW5jLjAeFw05NzA1MTIw
'' SIG '' MDAwMDBaFw0wNDAxMDcyMzU5NTlaMIGeMR8wHQYDVQQK
'' SIG '' ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMRcwFQYDVQQL
'' SIG '' Ew5WZXJpU2lnbiwgSW5jLjEsMCoGA1UECxMjVmVyaVNp
'' SIG '' Z24gVGltZSBTdGFtcGluZyBTZXJ2aWNlIFJvb3QxNDAy
'' SIG '' BgNVBAsTK05PIExJQUJJTElUWSBBQ0NFUFRFRCwgKGMp
'' SIG '' OTcgVmVyaVNpZ24sIEluYy4wgZ8wDQYJKoZIhvcNAQEB
'' SIG '' BQADgY0AMIGJAoGBANMuIPBofCwtLoEcsQaypwu3EQ1X
'' SIG '' 2lPYdePJMyqy1PYJWzTz6ZD+CQzQ2xtauc3n9oixncCH
'' SIG '' Jet9WBBzanjLcRX9xlj2KatYXpYE/S1iEViBHMpxlNUi
'' SIG '' WC/VzBQFhDa6lKq0TUrp7jsirVaZfiGcbIbASkeXarSm
'' SIG '' NtX8CS3TtDmbAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEA
'' SIG '' YVUOPnvHkhJ+ERCOIszUsxMrW+hE5At4nqR+86cHch7i
'' SIG '' We/MhOOJlEzbTmHvs6T7Rj1QNAufcFb2jip/F87lY795
'' SIG '' aQdzLrCVKIr17aqp0l3NCsoQCY/Os68olsR5KYSS3P+6
'' SIG '' Z0JIppAQ5L9h+JxT5ZPRcz/4/Z1PhKxV0f0RY2MwggQC
'' SIG '' MIIDa6ADAgECAhAIem1cb2KTT7rE/UPhFBidMA0GCSqG
'' SIG '' SIb3DQEBBAUAMIGeMR8wHQYDVQQKExZWZXJpU2lnbiBU
'' SIG '' cnVzdCBOZXR3b3JrMRcwFQYDVQQLEw5WZXJpU2lnbiwg
'' SIG '' SW5jLjEsMCoGA1UECxMjVmVyaVNpZ24gVGltZSBTdGFt
'' SIG '' cGluZyBTZXJ2aWNlIFJvb3QxNDAyBgNVBAsTK05PIExJ
'' SIG '' QUJJTElUWSBBQ0NFUFRFRCwgKGMpOTcgVmVyaVNpZ24s
'' SIG '' IEluYy4wHhcNMDEwMjI4MDAwMDAwWhcNMDQwMTA2MjM1
'' SIG '' OTU5WjCBoDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4x
'' SIG '' HzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdvcmsx
'' SIG '' OzA5BgNVBAsTMlRlcm1zIG9mIHVzZSBhdCBodHRwczov
'' SIG '' L3d3dy52ZXJpc2lnbi5jb20vcnBhIChjKTAxMScwJQYD
'' SIG '' VQQDEx5WZXJpU2lnbiBUaW1lIFN0YW1waW5nIFNlcnZp
'' SIG '' Y2UwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
'' SIG '' AQDAemGH67KnA2MbKxph3oC3FR2gi5A9uyeShBQ564XO
'' SIG '' KZIGZkikA0+N6E+n8K9e0S8Zx5HxtZ57kSHO6f/jTvD8
'' SIG '' r5VYuGMt5o72KRjNcI5Qw+2Wu0DbviXoQlXW9oXyBueL
'' SIG '' mRwx8wMP1EycJCrcGxuPgvOw76dN4xSn4I/Wx2jCYVip
'' SIG '' ctT4MEhP2S9vYyDZicqCe8JLvCjFgWjn5oJArEY6oPk/
'' SIG '' Ns1Mu1RCWnple/6E5MdHVKy5PeyAxxr3xDOBgckqlft/
'' SIG '' XjqHkBTbzC518u9r5j2pYL5CAapPqluoPyIxnxIV+XOh
'' SIG '' HoKLBCvqRgJMbY8fUC6VSyp4BoR0PZGPLEcxAgMBAAGj
'' SIG '' gbgwgbUwQAYIKwYBBQUHAQEENDAyMDAGCCsGAQUFBzAB
'' SIG '' hiRodHRwOi8vb2NzcC52ZXJpc2lnbi5jb20vb2NzcC9z
'' SIG '' dGF0dXMwCQYDVR0TBAIwADBEBgNVHSAEPTA7MDkGC2CG
'' SIG '' SAGG+EUBBwEBMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8v
'' SIG '' d3d3LnZlcmlzaWduLmNvbS9ycGEwEwYDVR0lBAwwCgYI
'' SIG '' KwYBBQUHAwgwCwYDVR0PBAQDAgbAMA0GCSqGSIb3DQEB
'' SIG '' BAUAA4GBAC3zT2NgLBja9SQPUrMM67O8Z4XCI+2PRg3P
'' SIG '' Gk2+83x6IDAyGGiLkrsymfCTuDsVBid7PgIGAKQhkoQT
'' SIG '' CsWY5UBXxQUl6K+vEWqp5TvL6SP2lCldQFXzpVOdyDY6
'' SIG '' OWUIc3OkMtKvrL/HBTz/RezD6Nok0c5jrgmn++Ib4/1B
'' SIG '' CmqWMIIEEjCCAvqgAwIBAgIPAMEAizw8iBHRPvZj7N9A
'' SIG '' MA0GCSqGSIb3DQEBBAUAMHAxKzApBgNVBAsTIkNvcHly
'' SIG '' aWdodCAoYykgMTk5NyBNaWNyb3NvZnQgQ29ycC4xHjAc
'' SIG '' BgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEhMB8G
'' SIG '' A1UEAxMYTWljcm9zb2Z0IFJvb3QgQXV0aG9yaXR5MB4X
'' SIG '' DTk3MDExMDA3MDAwMFoXDTIwMTIzMTA3MDAwMFowcDEr
'' SIG '' MCkGA1UECxMiQ29weXJpZ2h0IChjKSAxOTk3IE1pY3Jv
'' SIG '' c29mdCBDb3JwLjEeMBwGA1UECxMVTWljcm9zb2Z0IENv
'' SIG '' cnBvcmF0aW9uMSEwHwYDVQQDExhNaWNyb3NvZnQgUm9v
'' SIG '' dCBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IB
'' SIG '' DwAwggEKAoIBAQCpAr3BcOY78k4bKJ+XeF4w6qKpjSVf
'' SIG '' +P6VTKO3/p2iID58UaKboo9gMmvRQmR57qx2yVTa8uuc
'' SIG '' hhyPn4Rms8VremIj1h083g8BkuiWxL8tZpqaaCaZ0Dos
'' SIG '' vwy1WCbBRucKPjiWLKkoOajsSYNC44QPu5psVWGsgnyh
'' SIG '' YC13TOmZtGQ7mlAcMQgkFJ+p55ErGOY9mGMUYFgFZZ8d
'' SIG '' N1KH96fvlALGG9O/VUWziYC/OuxUlE6u/ad6bXROrxjM
'' SIG '' lgkoIQBXkGBpN7tLEgc8Vv9b+6RmCgim0oFWV++2O14W
'' SIG '' gXcE2va+roCV/rDNf9anGnJcPMq88AijIjCzBoXJsyB3
'' SIG '' E4XfAgMBAAGjgagwgaUwgaIGA1UdAQSBmjCBl4AQW9Bw
'' SIG '' 72lyniNRfhSyTY7/y6FyMHAxKzApBgNVBAsTIkNvcHly
'' SIG '' aWdodCAoYykgMTk5NyBNaWNyb3NvZnQgQ29ycC4xHjAc
'' SIG '' BgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEhMB8G
'' SIG '' A1UEAxMYTWljcm9zb2Z0IFJvb3QgQXV0aG9yaXR5gg8A
'' SIG '' wQCLPDyIEdE+9mPs30AwDQYJKoZIhvcNAQEEBQADggEB
'' SIG '' AJXoC8CN85cYNe24ASTYdxHzXGAyn54Lyz4FkYiPyTrm
'' SIG '' IfLwV5MstaBHyGLv/NfMOztaqTZUaf4kbT/JzKreBXzd
'' SIG '' MY09nxBwarv+Ek8YacD80EPjEVogT+pie6+qGcgrNyUt
'' SIG '' vmWhEoolD2Oj91Qc+SHJ1hXzUqxuQzIH/YIX+OVnbA1R
'' SIG '' 9r3xUse958Qw/CAxCYgdlSkaTdUdAqXxgOADtFv0sd3I
'' SIG '' V+5lScdSVLa0AygS/5DW8AiPfriXxas3LOR65Kh343ag
'' SIG '' ANBqP8HSNorgQRKoNWobats14dQcBOSoRQTIWjM4bk0c
'' SIG '' DWK3CqKM09VUP0bNHFWmcNsSOoeTdZ+n0qAwggSLMIID
'' SIG '' c6ADAgECAgphBiqNAAAAAAALMA0GCSqGSIb3DQEBBQUA
'' SIG '' MIGmMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGlu
'' SIG '' Z3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMV
'' SIG '' TWljcm9zb2Z0IENvcnBvcmF0aW9uMSswKQYDVQQLEyJD
'' SIG '' b3B5cmlnaHQgKGMpIDIwMDAgTWljcm9zb2Z0IENvcnAu
'' SIG '' MSMwIQYDVQQDExpNaWNyb3NvZnQgQ29kZSBTaWduaW5n
'' SIG '' IFBDQTAeFw0wMTAzMjkyMTI3MjZaFw0wMjA1MjkyMTM3
'' SIG '' MjZaMIGhMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2Fz
'' SIG '' aGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UE
'' SIG '' ChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSswKQYDVQQL
'' SIG '' EyJDb3B5cmlnaHQgKGMpIDIwMDEgTWljcm9zb2Z0IENv
'' SIG '' cnAuMR4wHAYDVQQDExVNaWNyb3NvZnQgQ29ycG9yYXRp
'' SIG '' b24wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAI4W
'' SIG '' b9oX0+NFlbKs0+XPMT0dxIe7TkgF+YtWqSuHY8hE2jDJ
'' SIG '' FLzreBq6xOricgBMRmab3mJGbp73RLrous/C1fU7lke4
'' SIG '' UV7Rd2cie1MqLeoij3xO/wK1GzOg6pXrGLp2+WHSAAuU
'' SIG '' YDQ7SYYss9mOky4ta/3jVaq4qm7gcPSiYAYvAgMBAAGj
'' SIG '' ggFAMIIBPDAOBgNVHQ8BAf8EBAMCBsAwEwYDVR0lBAww
'' SIG '' CgYIKwYBBQUHAwMwHQYDVR0OBBYEFO+QQN5P4BuzRdgH
'' SIG '' A3uZ+XUZZjUaMIGpBgNVHSMEgaEwgZ6AFClcuRu2zTPu
'' SIG '' u55Zffflyi7EDTQooXSkcjBwMSswKQYDVQQLEyJDb3B5
'' SIG '' cmlnaHQgKGMpIDE5OTcgTWljcm9zb2Z0IENvcnAuMR4w
'' SIG '' HAYDVQQLExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xITAf
'' SIG '' BgNVBAMTGE1pY3Jvc29mdCBSb290IEF1dGhvcml0eYIQ
'' SIG '' aguZT8AA3qoR1NhAmqi+5jBKBgNVHR8EQzBBMD+gPaA7
'' SIG '' hjlodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpL2Ny
'' SIG '' bC9wcm9kdWN0cy9Db2RlU2lnblBDQS5jcmwwDQYJKoZI
'' SIG '' hvcNAQEFBQADggEBAARnzM/dcU1Hwo6DaRJrol+WJgfo
'' SIG '' j9jTnlrbJ2kdHfQ8VShT3REkJ5KuWVZA6cRNnezbq36U
'' SIG '' mz0gLDXyJ07AyDm3ZWPRNWbaU71BfllKpFK39f3IvaF7
'' SIG '' BriY2Jju0Qs0dWYN3EGPw7CShFfBQnqFxpET21St3n5B
'' SIG '' 3CCv6RvJwjIxxY3py/qDS8FYkzLE1+PNeqvffQicxoU7
'' SIG '' 6EGBOLF4Gbw4981rws6qTJAdg8bmAYloqueP6AdQKjLd
'' SIG '' 18+9zHrZOg//skSKV8gaN2QHF317cktGBqEoWyNXHmr9
'' SIG '' kSIzQNF1SxIBbgYhhDZvqCoMfz6uNSv2t30LCBPlV/NL
'' SIG '' rY8gv7gwggTJMIIDsaADAgECAhBqC5lPwADeqhHU2ECa
'' SIG '' qL7mMA0GCSqGSIb3DQEBBAUAMHAxKzApBgNVBAsTIkNv
'' SIG '' cHlyaWdodCAoYykgMTk5NyBNaWNyb3NvZnQgQ29ycC4x
'' SIG '' HjAcBgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEh
'' SIG '' MB8GA1UEAxMYTWljcm9zb2Z0IFJvb3QgQXV0aG9yaXR5
'' SIG '' MB4XDTAwMTIxMDA4MDAwMFoXDTA1MTExMjA4MDAwMFow
'' SIG '' gaYxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5n
'' SIG '' dG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVN
'' SIG '' aWNyb3NvZnQgQ29ycG9yYXRpb24xKzApBgNVBAsTIkNv
'' SIG '' cHlyaWdodCAoYykgMjAwMCBNaWNyb3NvZnQgQ29ycC4x
'' SIG '' IzAhBgNVBAMTGk1pY3Jvc29mdCBDb2RlIFNpZ25pbmcg
'' SIG '' UENBMIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0AMIIBCAKC
'' SIG '' AQEAooQVU9gLMA40lf86G8LzL3ttNyNN89KM5f2v/cUC
'' SIG '' NB8kx+Wh3FTsfgJ0R6vbMlgWFFEpOPF+srSMOke1OU5u
'' SIG '' VMIxDDpt+83Ny1CcG66n2NlKJj+1xcuPluJJ8m3Y6ZY+
'' SIG '' 3gXP8KZVN60vYM2AYUKhSVRKDxi3S9mTmTBaR3VktNO7
'' SIG '' 3barDJ1PuHM7GDqqtIeMsIiwTU8fThG1M4DfDTpkb0TH
'' SIG '' NL1Kk5u8ph35BSNOYCmPzCryhJqZrajbCnB71jRBkKW3
'' SIG '' ZsdcGx2jMw6bVAMaP5iQuMznPQR0QxyP9znms6xIemsq
'' SIG '' DmIBYTl2bv0+mAdLFPEBRv0VAOBH2k/kBeSAJQIBA6OC
'' SIG '' ASgwggEkMBMGA1UdJQQMMAoGCCsGAQUFBwMDMIGiBgNV
'' SIG '' HQEEgZowgZeAEFvQcO9pcp4jUX4Usk2O/8uhcjBwMSsw
'' SIG '' KQYDVQQLEyJDb3B5cmlnaHQgKGMpIDE5OTcgTWljcm9z
'' SIG '' b2Z0IENvcnAuMR4wHAYDVQQLExVNaWNyb3NvZnQgQ29y
'' SIG '' cG9yYXRpb24xITAfBgNVBAMTGE1pY3Jvc29mdCBSb290
'' SIG '' IEF1dGhvcml0eYIPAMEAizw8iBHRPvZj7N9AMBAGCSsG
'' SIG '' AQQBgjcVAQQDAgEAMB0GA1UdDgQWBBQpXLkbts0z7rue
'' SIG '' WX335couxA00KDAZBgkrBgEEAYI3FAIEDB4KAFMAdQBi
'' SIG '' AEMAQTALBgNVHQ8EBAMCAUYwDwYDVR0TAQH/BAUwAwEB
'' SIG '' /zANBgkqhkiG9w0BAQQFAAOCAQEARVjimkF//J2/SHd3
'' SIG '' rozZ5hnFV7QavbS5XwKhRWo5Wfm5J5wtTZ78ouQ4ijhk
'' SIG '' IkLfuS8qz7fWBsrrKr/gGoV821EIPfQi09TAbYiBFURf
'' SIG '' ZINkxKmULIrbkDdKD7fo1GGPdnbh2SX/JISVjQRWVJSh
'' SIG '' HDo+grzupYeMHIxLeV+1SfpeMmk6H1StdU3fZOcwPNtk
'' SIG '' SUT7+8QcQnHmoD1F7msAn6xCvboRs1bk+9WiKoHYH06i
'' SIG '' Vb4nj3Cmomwb/1SKgryBS6ahsWZ6qRenywbAR+ums+kx
'' SIG '' FVM9KgS//3NI3IsnQ/xj6O4kh1u+NtHoMfUy2V7feXq6
'' SIG '' MKxphkr7jBG/G41UWTGCBGIwggReAgEBMIG1MIGmMQsw
'' SIG '' CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQ
'' SIG '' MA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9z
'' SIG '' b2Z0IENvcnBvcmF0aW9uMSswKQYDVQQLEyJDb3B5cmln
'' SIG '' aHQgKGMpIDIwMDAgTWljcm9zb2Z0IENvcnAuMSMwIQYD
'' SIG '' VQQDExpNaWNyb3NvZnQgQ29kZSBTaWduaW5nIFBDQQIK
'' SIG '' YQYqjQAAAAAACzAMBggqhkiG9w0CBQUAoIGwMBkGCSqG
'' SIG '' SIb3DQEJAzEMBgorBgEEAYI3AgEEMBwGCisGAQQBgjcC
'' SIG '' AQsxDjAMBgorBgEEAYI3AgEVMB8GCSqGSIb3DQEJBDES
'' SIG '' BBCCJIA8Xa3hbMOmcmENDlALMFQGCisGAQQBgjcCAQwx
'' SIG '' RjBEoCaAJABXAE0ASQAgAHAAcgBpAG4AdABlAHIAIABz
'' SIG '' AGMAcgBpAHAAdKEagBhodHRwOi8vd3d3Lm1pY3Jvc29m
'' SIG '' dC5jb20wDQYJKoZIhvcNAQEBBQAEgYANXx8X9wO7H87A
'' SIG '' jfhHKZfnx58x5L+Wff0SS1HLRzHBKV5h02E67RTQ0xa5
'' SIG '' GYdNf5uoRws+OsuyqtI/R1rtTkkIQcJ8ZsTWRBzr9H2+
'' SIG '' h517hBwXeU/wpyh16QBREIdbpXdFD+RWAF6iTYvffyvI
'' SIG '' vdsT8wBcB0w0Fd4pA7BYP0bLMKGCAkwwggJIBgkqhkiG
'' SIG '' 9w0BCQYxggI5MIICNQIBATCBszCBnjEfMB0GA1UEChMW
'' SIG '' VmVyaVNpZ24gVHJ1c3QgTmV0d29yazEXMBUGA1UECxMO
'' SIG '' VmVyaVNpZ24sIEluYy4xLDAqBgNVBAsTI1ZlcmlTaWdu
'' SIG '' IFRpbWUgU3RhbXBpbmcgU2VydmljZSBSb290MTQwMgYD
'' SIG '' VQQLEytOTyBMSUFCSUxJVFkgQUNDRVBURUQsIChjKTk3
'' SIG '' IFZlcmlTaWduLCBJbmMuAhAIem1cb2KTT7rE/UPhFBid
'' SIG '' MAwGCCqGSIb3DQIFBQCgWTAYBgkqhkiG9w0BCQMxCwYJ
'' SIG '' KoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wMTEyMDcy
'' SIG '' MDIzMDlaMB8GCSqGSIb3DQEJBDESBBAC9RKfRgIH0QcN
'' SIG '' Ajx0z4CdMA0GCSqGSIb3DQEBAQUABIIBAJl0lzJa+J4Z
'' SIG '' AuprvTpIZZEdMp+8fyma4ZOWcZTf1WJ2QN7qeFo6xsQR
'' SIG '' sfSqpaxP2MC6OCGSLsqHZ/PmPPNBfKXRLtQpTEyMPFEy
'' SIG '' j/zCIR3KKkmIs7AZzX/f9jwWAfhhrFXoEZCRwjFEVLOx
'' SIG '' l4WHuyd8qIq/lxgU4xuAQlIoJ6xkLFzTjoAOAVHlDtV8
'' SIG '' F6Hzz3owO7t8L32O/TSX6qrFH5gHvcKtA8gb2SN7xL3X
'' SIG '' ydIL/AbyYQc8zKXTBL41y/gq6pv+vsHyquzVICcDhAXf
'' SIG '' xi+gjqPdfk69eMMYw/4BQN13l20fojIcBAbORHrxfYDy
'' SIG '' egHLtsfcnY79dVKneR+cDKM=
'' SIG '' End signature block
|
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
ZigZag(Cint(WScript.Arguments(0)))
Function ZigZag(n)
Dim arrZ()
ReDim arrZ(n-1,n-1)
i = 1
j = 1
For e = 0 To (n^2) - 1
arrZ(i-1,j-1) = e
If ((i + j ) And 1) = 0 Then
If j < n Then
j = j + 1
Else
i = i + 2
End If
If i > 1 Then
i = i - 1
End If
Else
If i < n Then
i = i + 1
Else
j = j + 2
End If
If j > 1 Then
j = j - 1
End If
End If
Next
For k = 0 To n-1
For l = 0 To n-1
WScript.StdOut.Write Right(" " & arrZ(k,l),3)
Next
WScript.StdOut.WriteLine
Next
End Function
|
<gh_stars>10-100
REM
REM LOCALIZATION
REM
L_SWITCH_MESSAGEID = "-m"
L_SWITCH_SERVER = "-s"
L_SWITCH_INSTANCE_ID = "-i"
L_DESC_PROGRAM = "rcancel - Cancel message in NNTP virtual servers"
L_DESC_MESSAGEID = """<message-id>"" Specify message to cancel"
L_DESC_SERVER = "<server> Specify computer to configure"
L_DESC_INSTANCE_ID = "<virtual server id> Specufy virtual server id"
L_DESC_EXAMPLES = "Examples:"
L_DESC_EXAMPLE1 = "rcancel.vbs -m ""<<EMAIL>.<EMAIL>@nntpserver.microsoft.com>"""
L_ERR_INVALID_INSTANCE_ID = "Invalid instance identifier."
L_ERR_INVALID_MESSAGEID = "Invalid message identifier."
L_ERR_CANCEL_ERROR = "Error canceling message: "
L_ERR_CANCEL_SUCCESS = "Message canceled."
REM
REM END LOCALIZATION
REM
REM
REM --- Globals ---
REM
dim g_dictParms
dim g_admin
set g_dictParms = CreateObject ( "Scripting.Dictionary" )
REM
REM --- Set argument defaults ---
REM
g_dictParms(L_SWITCH_MESSAGEID) = ""
g_dictParms(L_SWITCH_SERVER) = ""
g_dictParms(L_SWITCH_INSTANCE_ID) = "1"
REM
REM --- Begin Main Program ---
REM
if NOT ParseCommandLine ( g_dictParms, WScript.Arguments ) then
usage
WScript.Quit ( 0 )
end if
set g_admin = CreateObject("NntpAdm.Groups")
server = g_dictParms(L_SWITCH_SERVER)
instance = g_dictParms(L_SWITCH_INSTANCE_ID)
messageid = g_dictParms(L_SWITCH_MESSAGEID)
REM
REM Check arguments
REM
if ( messageid = "" ) then
usage
WScript.Quit 0
end if
if NOT IsNumeric (instance) then
WScript.Echo L_ERR_INVALID_INSTANCE_ID
WScript.Quit 0
end if
if ( Left(messageid,1) <> "<" OR Right(messageid,1) <> ">" ) then
WScript.echo L_ERR_INVALID_MESSAGEID
WScript.Quit 0
end if
REM
REM Cancel message
REM
g_admin.Server = server
g_admin.ServiceInstance = instance
g_admin.CancelMessage( messageid )
REM
REM Show Result
REM
if (err.number <> 0) then
WScript.echo L_ERR_CANCEL_ERROR
WScript.echo Err.Description & " (Error 0x" & Hex(Err.Number) & ")"
else
WScript.echo L_ERR_CANCEL_SUCCESS
end if
WScript.Quit 0
REM
REM
REM --- End Main Program ---
REM
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 Usage ()
REM prints out the description of the command line arguments
REM
Sub Usage
WScript.Echo L_DESC_PROGRAM
WScript.Echo vbTab & L_SWITCH_MESSAGEID & " " & L_DESC_MESSAGEID
WScript.Echo vbTab & L_SWITCH_SERVER & " " & L_DESC_SERVER
WScript.Echo vbTab & L_SWITCH_INSTANCE_ID & " " & L_DESC_INSTANCE_ID
WScript.Echo
WScript.Echo L_DESC_EXAMPLES
WScript.Echo L_DESC_EXAMPLE1
WScript.Echo L_DESC_EXAMPLE2
end sub
|
REM VBScript Test Custom Action
Const hkClassesRoot = 0
Const hkCurrentUser = 1
Const hkLocalMachine = 2
MsgBox "ProductCode = " & Session.Property("ProductCode") & " Language = " & Session.Language
Function Action1
MsgBox "Processor Speed = " & Session.Application.RegistryValue(hkLocalMachine, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz")
Action1 = 1
End Function
|
<filename>base/cluster/admin/msclus/vbscript/deleteresource.vbs
Option Explicit
Main
Sub Main
On Error Resume Next
Dim oCluster
Dim oTestRes
Dim sCluster
Set oCluster = CreateObject("MSCluster.Cluster")
sCluster = InputBox( "Cluster to open?" )
oCluster.Open( sCluster )
Set oTestRes = oCluster.Resources.Item("Dummy")
oTestRes.Delete()
If Err.Number <> 0 Then
If Err.Number = 424 Then
MsgBox "Dummy resource does not exist!"
Else
MsgBox "Error return is " & Err.Number
End If
End If
' This will return "Invalid procedure call or argument" if the resource
' does not exist!
End Sub
|
' Windows Installer database table import for use with Windows Scripting Host
' Copyright (c) 1999-2000, Microsoft Corporation
' Demonstrates the use of the Database.Import method and MsiDatabaseImport 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 < 3) Then
Wscript.Echo "Windows Installer database table import utility" &_
vbNewLine & " 1st argument is the path to MSI database (installer package)" &_
vbNewLine & " 2nd argument is the path to folder containing the imported files" &_
vbNewLine & " Subseqent arguments are names of archive files to import" &_
vbNewLine & " Wildcards, such as *.idt, can be used to import multiple files" &_
vbNewLine & " Specify /c or -c anywhere before file list to create new database" &_
vbNewLine &_
vbNewLine & "Copyright (C) Microsoft Corporation, 1999-2000. 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
Dim openMode:openMode = msiOpenDatabaseModeTransact
Dim databasePath:databasePath = NextArgument
Dim folder:folder = NextArgument
' Open database and process list of files
Dim database, table
Set database = installer.OpenDatabase(databasePath, openMode) : CheckError
While iArg < argCount
table = NextArgument
' Check file name for wildcard specification
If (InStr(1,table,"*",vbTextCompare) <> 0) Or (InStr(1,table,"?",vbTextCompare) <> 0) Then
' Obtain list of files matching wildcard specification
Dim WshShell, fileSys, file, tempFilePath
Set WshShell = Wscript.CreateObject("Wscript.Shell") : CheckError
tempFilePath = WshShell.ExpandEnvironmentStrings("%TEMP%") & "\dir.tmp"
WshShell.Run "cmd.exe /U /c dir /b " & folder & "\" & table & ">" & tempFilePath, 0, True : CheckError
Set fileSys = CreateObject("Scripting.FileSystemObject") : CheckError
Set file = fileSys.OpenTextFile(tempFilePath, ForReading, False, TristateTrue) : CheckError
' Import each file in directory list
Do While file.AtEndOfStream <> True
table = file.ReadLine
database.Import folder, table : CheckError
Loop
Else
database.Import folder, table : CheckError
End If
Wend
database.Commit 'commit changes if no import errors
Wscript.Quit 0
Function NextArgument
Dim arg, chFlag
Do
arg = Wscript.Arguments(iArg)
iArg = iArg + 1
chFlag = AscW(arg)
If (chFlag = AscW("/")) Or (chFlag = AscW("-")) Then
chFlag = UCase(Right(arg, Len(arg)-1))
If chFlag = "C" Then
openMode = msiOpenDatabaseModeCreate
Else
Wscript.Echo "Invalid option flag:", arg : Wscript.Quit 1
End If
Else
Exit Do
End If
Loop
NextArgument = arg
End Function
Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
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
End If
Wscript.Echo message
Wscript.Quit 2
End Sub
|
Attribute VB_Name = "crypto"
'//+----------------------------------------------------------------------------
'//
'// File: crypto.bas
'//
'// Module: pbadmin.exe
'//
'// Synopsis: Functions to encrypt a database so as to hide passwords
'//
'// Copyright (c) 1997-1999 Microsoft Corporation
'//
'// Author: 11-Jul-2000 SumitC Created
'//
'//+----------------------------------------------------------------------------
Option Explicit
'//+----------------------------------------------------------------------------
'//
'// Function: DBPassword, generates a password
'//
'//+----------------------------------------------------------------------------
Public Function DBPassword() As String
Dim pw As String
Dim i As Integer
On Error GoTo Err:
pw = "<PASSWORD>"
pw = Mid(pw, 1, 9) + Chr(Asc(Mid(pw, 10, 1)) + 2) + Mid(pw, 11)
pw = Mid(pw, 5) + Left(pw, 4)
For i = 4 To 12 Step 2
pw = Mid(pw, 1, i - 1) + Chr(Asc(Mid(pw, i, 1)) + 1) + Mid(pw, i + 1)
Next i
DBPassword = ";<PASSWORD>=" + pw
Err:
' If Err <> 0 Then MsgBox "manip failed with " & Err.Description
End Function
'//+----------------------------------------------------------------------------
'//
'// Function: ConvertDatabaseIfNeeded, compacts/encrypts db if not already done
'//
'//+----------------------------------------------------------------------------
Public Sub ConvertDatabaseIfNeeded(Workspace As Object, szDBName As String, Options As Variant, fReadOnly As Variant)
Dim db As Database
On Error Resume Next
' first try to open the db without using a password
Set db = Workspace.OpenDatabase(szDBName, Options, fReadOnly)
If Err.Number = 0 Then
' db opened without a password. Needs to be converted
db.Close
On Error GoTo CompactErr
DBEngine.CompactDatabase szDBName, "TempConversionDatabase.mdb", dbLangGeneral, dbEncrypt, DBPassword
' rename the new db (play it safe, make sure the renames succeed first)
Name szDBName As "DeleteThis.mdb"
Name "TempConversionDatabase.mdb" As szDBName
Kill "DeleteThis.mdb"
End If
On Error GoTo CompactErr
' check that the db will open using the password
Set db = Workspace.OpenDatabase(szDBName, Options, fReadOnly, DBPassword)
db.Close
CompactErr:
'If Err <> 0 Then MsgBox "Failed to convert db with error: " & Err.Description
Exit Sub
OpenErr:
'If Err <> 0 Then MsgBox "Failed to open db with error: " & Err.Description
Exit Sub
End Sub
|
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2265
ClientLeft = 60
ClientTop = 600
ClientWidth = 2175
LinkTopic = "Form1"
ScaleHeight = 2265
ScaleWidth = 2175
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdRnd
Caption = "Random"
Height = 495
Left = 120
TabIndex = 2
Top = 1680
Width = 1215
End
Begin VB.CommandButton cmdInc
Caption = "Increment"
Height = 495
Left = 120
TabIndex = 1
Top = 1080
Width = 1215
End
Begin VB.TextBox txtValue
Height = 495
Left = 120
TabIndex = 0
Text = "0"
Top = 240
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'-----user-written code begins here; everything above this line is hidden in the IDE-----
Private Sub Form_Load()
Randomize Timer
End Sub
Private Sub cmdRnd_Click()
If MsgBox("Random?", vbYesNo) Then txtValue.Text = Int(Rnd * 11)
End Sub
Private Sub cmdInc_Click()
If Val(txtValue.Text) < 10 Then txtValue.Text = Val(txtValue.Text) + 1
End Sub
Private Sub txtValue_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 43, 45, 48 To 57
'backspace, +, -, or number
Case Else
KeyAscii = 0
End Select
End Sub
|
<reponame>npocmaka/Windows-Server-2003
'////////////////////////////////////////////////////////////////////////////
'
' Copyright (c) 1999-2000 Microsoft Corp. All Rights Reserved.
'
' File name:
'
' cmi.vbs
'
' Abstract:
'
' Windows Embedded Prototype Script for Printers
'
' Remarks:
'
' CMI helper functions and event handlers.
'
' Author:
'
' <NAME> (lzhu) 12-25-2000
'
'////////////////////////////////////////////////////////////////////////////
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Cmi helper functions
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'////////////////////////////////////////////////////////////////////////////////////
'
' Function name:
'
' fillComponentFlagArray
'
' Function description:
'
' This function fills componentFlagArray
'
' Arguments:
'
' oResouces -- Resouces collection
' componentFlagArray -- an array of flags that indicate which component
' is mapped
'
'///////////////////////////////////////////////////////////////////////////////////
Sub fillComponentFlagArray(oResources, componentFlagArray)
Dim oRes
Dim bMapped
Dim strFileName
' get all the mapped components
For Each oRes In oResources ' For each resource..
If 0 = StrComp(oRes.Type.Name, "File", 1) Then
strFileName = oRes.Properties("DstName")
bMapped = mapIt(strFileName, componentFlagArray)
If (bMapped) Then
TraceState strFileName, " is mapped"
Else
TraceState strFileName, " is not mapped"
End If
End If
Next
End Sub
'////////////////////////////////////////////////////////////////////////////////////
'
' Function name:
'
' mapComponents
'
' Function description:
'
' This function maps components using componentFlagArray
'
' Arguments:
'
' oDependencies -- Dependency collection
' componentFlagArray -- an array of flags that indicate which component
' is mapped
'
'///////////////////////////////////////////////////////////////////////////////////
Sub mapComponents(oDependencies, componentFlagArray)
Dim strComponentVIGUID
Dim iclass
Dim iMinRevision
Dim iType
Dim i
' add the mapped components to the dependencies collection
For i = 0 To (g_nComponents - 1)
If componentFlagArray(i) Then
strComponentVIGUID = g_componentTuples(i).strComponentVIGUID
iclass = g_componentTuples(i).enumClass
iType = g_componentTuples(i).enumType
iMinRevision = g_componentTuples(i).enumMinRevision
TraceState " Add dependency of ", strComponentVIGUID
oDependencies.Add iclass, iType, strComponentVIGUID, iMinRevision
End If
Next
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' These are cmi event handlers
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function cmiOnAddInstance()
TraceEnter "PrinterProto::cmiOnAddInstance"
TraceState "PrinterProto::cmiThis.Comment", cmiThis.Comment
' must call this method to populate the instance
cmiOnAddInstance = cmiSuper.cmiOnAddInstance
initializeTables ' safe to call it more than once
Dim componentFlagArray()
ReDim componentFlagArray(g_nComponents - 1)
' initialize componentFlagArray
initComponentFlagArray componentFlagArray
If Not isValid(componentFlagArray) Then
cmiOnAddInstance = False
Exit Function
End If
' fill componentFlagArray
fillComponentFlagArray cmiThis.Resources, componentFlagArray
' map all the components
mapComponents cmiThis.Dependencies, componentFlagArray
cmiOnAddInstance = True
TraceLeave "PrinterProto::cmiOnAddInstance"
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
' The following sample enumerates all instances of the class
' Win32_LogicalDisk, and counts the items returned.
Set objServices = GetObject("cim:root/cimv2")
Set objEnum = objServices.ExecQuery ("select * from Win32_LogicalDisk")
count = objEnum.Count
WScript.Echo count, "items retrieved"
|
<filename>Task/Binary-search/VBA/binary-search-3.vba<gh_stars>1-10
Public Function BinarySearch2(a, value)
'search for "value" in array a
'return index point if found, -1 if not found
low = LBound(a)
high = UBound(a)
Do While low <= high
midd = low + Int((high - low) / 2)
If a(midd) = value Then
BinarySearch2 = midd
Exit Function
ElseIf a(midd) > value Then
high = midd - 1
Else
low = midd + 1
End If
Loop
BinarySearch2 = -1 'not found
End Function
|
on error resume next
'Create a keyed class with a defaulted property
set service = GetObject("Winmgmts:")
set aclass = service.get
aclass.path_.class = "REMOVETEST00"
set property = aclass.properties_.add ("p", 19)
property.qualifiers_.add "key", true
aclass.properties_.add ("q", 19).Value = 12
aclass.put_
'create an instance and override the property
set instance = service.get ("RemoveTest00").spawninstance_
instance.properties_("q").Value = 24
instance.properties_("p").Value = 1
instance.put_
'retrieve the instance and remove the property
set instance = service.get ("removetest00=1")
set property = instance.properties_ ("q")
WScript.echo property.value, property.islocal
instance.properties_.remove "q"
set property = instance.properties_ ("q")
WScript.echo property.value, property.islocal
if err <> 0 then
WScript.Echo Err.Number, Err.Description, Err.Source
end if
|
<filename>Task/Associative-array-Iteration/VBScript/associative-array-iteration.vb<gh_stars>1-10
'instantiate the dictionary object
Set dict = CreateObject("Scripting.Dictionary")
'populate the dictionary or hash table
dict.Add 1,"larry"
dict.Add 2,"curly"
dict.Add 3,"moe"
'iterate key and value pairs
For Each key In dict.Keys
WScript.StdOut.WriteLine key & " - " & dict.Item(key)
Next
|
<reponame>LaudateCorpus1/RosettaCodeData
Set objFSO = CreateObject("Scripting.FileSystemObject")
'current directory
objFSO.CreateFolder(".\docs")
objFSO.CreateTextFile(".\docs\output.txt")
'root directory
objFSO.CreateFolder("\docs")
objFSO.CreateTextFile("\docs\output.txt")
|
<reponame>npocmaka/Windows-Server-2003
VERSION 5.00
Begin VB.Form ProdInfo
Caption = "Product Information"
ClientHeight = 5730
ClientLeft = 60
ClientTop = 345
ClientWidth = 6195
LinkTopic = "Form2"
ScaleHeight = 5730
ScaleWidth = 6195
StartUpPosition = 3 'Windows Default
Visible = 0 'False
Begin VB.TextBox txtName
Height = 375
Left = 1200
TabIndex = 0
Top = 240
Width = 3975
End
Begin VB.TextBox Description
Height = 375
Left = 1200
TabIndex = 1
Top = 840
Width = 3975
End
Begin VB.TextBox VMajor
Height = 375
Left = 1200
TabIndex = 2
Top = 1560
Width = 615
End
Begin VB.TextBox VMinor
Height = 375
Left = 3240
TabIndex = 3
Top = 1560
Width = 615
End
Begin VB.CommandButton cmdExecute
Caption = "Execute"
Default = -1 'True
Height = 375
Left = 5160
TabIndex = 4
Top = 5280
Width = 975
End
Begin VB.CommandButton Prev
Caption = "< &Prev"
Height = 375
Left = 3960
TabIndex = 5
Top = 5280
Width = 1095
End
Begin VB.CommandButton Exit
Caption = "Exit"
Height = 375
Left = 120
TabIndex = 6
Top = 5280
Width = 975
End
Begin VB.Label Label1
Caption = "Name:"
Height = 255
Index = 0
Left = 120
TabIndex = 10
Top = 360
Width = 495
End
Begin VB.Label Label2
Caption = "Description:"
Height = 255
Left = 120
TabIndex = 9
Top = 960
Width = 855
End
Begin VB.Label Label4
Caption = "Version major:"
Height = 255
Left = 120
TabIndex = 8
Top = 1680
Width = 1095
End
Begin VB.Label Label5
Caption = "Version minor:"
Height = 255
Left = 2160
TabIndex = 7
Top = 1680
Width = 1095
End
End
Attribute VB_Name = "ProdInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdExecute_Click()
On Error GoTo err:
Dim X As New SchemaDoc
Dim strUser
' Dim o As IADsOpenDSObject
Dim explorer As New InternetExplorer
'Copy the form contents to public variables
SaveData
frmXML.SaveData
VendorInfo.SaveData
Open strFile For Output As #1
'Print the heading
Print #1, "<sd:SchemaDoc xmlns:sd=" & Chr(34) & "http://www.microsoft.com/xml" & Chr(34) & ">"
'Print the vendor info
Print #1, "<sd:comment-Vendor>"
WriteXMLLine "VendorName", strVendName
WriteXMLLine "VendorAddress", strVendAddress
WriteXMLLine "VendorCity", strVendCity
WriteXMLLine "VendorStateOrProvince", strVendState
WriteXMLLine "VendorCountry", strVendCountry
WriteXMLLine "VendorPostalCode", strVendPostalCode
WriteXMLLine "VendorTelephone", strVendTelephone
WriteXMLLine "VendorEmail", strVendEmail
Print #1, "</sd:comment-Vendor>"
'Print the product info
Print #1, "<sd:comment-Product>"
WriteXMLLine "ProductName", strProdName
WriteXMLLine "ProductDescription", strProdDescription
WriteXMLLine "VersionMajor", strProdVMajor
WriteXMLLine "VersionMinor", strProdVMinor
Print #1, "</sd:comment-Product>"
Close #1
' Run the ADSXML DLL
'Set X = GetObject(strADSPath)
If strDomain <> "" Then
strUser = strDomain & "\"
End If
strUser = strUser & strUsername
X.SetPath_and_ID strADSPath, strUser, strPassword
X.CreateXMLDoc strFile, strPrefix
Set X = Nothing
' Add the XML termination tags for the file
Open strFile For Append As #1
Print #1, "</sd:SchemaDoc>"
Close #1
If (Len(strFile) > 0) Then
explorer.Navigate (strFile)
explorer.Visible = True
End If
err:
If (err <> 0) Then
MsgBox (err.Number & " : " & err.Description)
End If
End Sub
Private Sub Form_Load()
txtName = strProdName
Description = strProdDescription
VMajor = strProdVMajor
VMinor = strProdVMinor
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveData
frmXML.EndProgram
End Sub
Private Sub Exit_Click()
frmXML.EndProgram
End Sub
Private Sub Prev_Click()
VendorInfo.Left = ProdInfo.Left
VendorInfo.Top = ProdInfo.Top
VendorInfo.Visible = True
ProdInfo.Visible = False
End Sub
Private Sub SaveData()
strProdName = txtName
strProdDescription = Description
strProdVMajor = VMajor
strProdVMinor = VMinor
End Sub
|
'
L_Welcome_MsgBox_Message_Text = "This script demonstrates how to copy snapin items to clipboard 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 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 "{18731372-1D79-11D0-A29B-00C04FD909DD}" ' Sample snapin
snapins.Add "{53D6AB1D-2488-11D1-A28C-00C04FB94F17}" ' Certificates snapin
' Select sample snapin root
Set rootnode = namespace.GetRoot
Set SnapNode1 = namespace.GetChild(rootnode)
view.ActiveScopeNode = SnapNode1
' Now select the scope items in LV and try copy
view.Select view.ListItems.Item(1)
view.CopySelection
' Get "User Data" and try copy on scope item in scope pane (temp selection)
Set SnapNode1 = namespace.GetChild(SnapNode1)
view.CopyScopeNode SnapNode1
' Now select the "User Data" and try copy once again.
view.ActiveScopeNode = SnapNode1
view.CopyScopeNode
' Now navigate to the Certificates/Trusted Root Cert/Certificates node
Set SnapNode1 = namespace.GetChild(rootnode)
Set SnapNode1 = namespace.GetNext(SnapNode1)
' Select certificates root node
view.ActiveScopeNode = SnapNode1
' Select "Trusted Root cert..." node
Set SnapNode1 = namespace.GetChild(SnapNode1)
Set SnapNode1 = namespace.GetNext(SnapNode1)
view.ActiveScopeNode = SnapNode1
' Select "Certificates" node
Set SnapNode1 = namespace.GetChild(SnapNode1)
view.ActiveScopeNode = SnapNode1
Set Nodes = view.ListItems
' Now call copy on LV items
view.Select Nodes(1)
view.CopySelection
view.Deselect Nodes(1)
view.Select Nodes(4)
view.CopySelection
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>Task/Loops-Nested/VBA/loops-nested.vba
Public Sub LoopsNested()
Dim a(1 To 10, 1 To 10) As Integer
Randomize
For i = 1 To 10
For j = 1 To 10
a(i, j) = Int(20 * Rnd) + 1
Next j
Next i
For i = 1 To 10
For j = 1 To 10
If a(i, j) <> 20 Then
Debug.Print a(i, j),
Else
i = 10 'Upperbound iterator outerloop
Exit For 'Exit For exits only innerloop
End If
Next j
Debug.Print
Next i
End Sub
|
<filename>sdktools/supporttools/64bit/msi/installcab.vbs<gh_stars>10-100
Function InstallCab()
dim hcu
dim nBuild
dim strCab
dim strSource
dim strWindows
on error resume next
strSource = Session.Property( "SourceDir" )
nBuild = Session.Property( "WindowsBuild" )
strWindows = Session.Property( "WindowsFolder" )
strTargetPath = strWindows & "pchealth\helpctr\batch\"
if IsEmpty( nBuild ) then
InstallCab = 0
elseif nBuild = 2600 then
strCab = strSource & "sup_pro.cab"
else
strCab = strSource & "sup_srv.cab"
end if
set fso = createobject( "scripting.filesystemobject" )
if not fso is nothing then
fso.CopyFile strCab, strTargetPath
set fso = nothing
end if
' set hcu = CreateObject( "hcu.pchupdate" )
' if not hcu is nothing then
' hcu.UpdatePkg strCab, true
' set hcu = Nothing
' end if
InstallCab = 1
End Function
|
<filename>enduser/sakit/sak/plugins/appletalk/saappletalk/testzones.vbs<gh_stars>10-100
Call GetZones()
Public Function GetZones()
Dim oAppleTalk
Dim sZones
Dim s
Dim count
Set oAppleTalk = CreateObject("MSSAAppleTalk.AppleTalk")
'
' Set current zone
oAppleTalk.Zone("Foo") = "Peach"
'
' Display current zone
WScript.Echo "Current Zone: " + oAppleTalk.Zone("Foo")
'
' Get list of zones
sZones = oAppleTalk.GetZones("Foo")
'
' Display the list of zones
If ( IsArray(sZones) ) Then
For count = 0 to CInt(UBound(sZones))
s = CStr(sZones(count))
Call SA_TraceOut("Zone " , CStr(count) + ": " + CStr(s))
Next
Else
Call SA_TraceOut("GetZones", "sZones is not an array")
Exit Function
End If
Set oAppleTalk = Nothing
End Function
Function SA_TraceOut(ByVal sFn, ByVal sMsg)
WScript.Echo sFn + " " + sMsg
End Function
|
<gh_stars>10-100
' Utility to rewrite a Unicode text file as an ANSI text file
' For use with Windows Scripting Host, CScript.exe or WScript.exe
' Copyright (c) Microsoft Corporation. All rights reserved.
'
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
Dim argCount:argCount = Wscript.Arguments.Count
If argCount > 0 Then If InStr(1, Wscript.Arguments(0), "?", vbTextCompare) > 0 Then argCount = 0
If (argCount = 0) Then
Wscript.Echo "Utility to copy Unicode text file to an ANSI text file." &_
vbNewLine & "The 1st argument is the Unicode text file to read" &_
vbNewLine & "The 2nd argument is the ANSI text file to write" &_
vbNewLine & "If the 2nd argument is omitted, the Unicode file will be replaced" &_
vbNewLine &_
vbNewLine & "Copyright (C) Microsoft Corporation. All rights reserved."
Wscript.Quit 1
End If
Dim inFile, outFile, inStream, outStream, inLine, FileSys, WshShell
If argCount > 1 Then
outFile = Wscript.Arguments(1)
inFile = Wscript.Arguments(0)
Else
outFile = Wscript.Arguments(0)
inFile = outFile & ".tmp"
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run "cmd.exe /c copy " & outFile & " " & inFile, 0, True
End If
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set inStream = FileSys.OpenTextFile(inFile, ForReading, FailIfNotExist, OpenAsDefault)
Set outStream = FileSys.CreateTextFile(outFile, OverwriteIfExist, OpenAsASCII)
Do
inLine = inStream.ReadLine
outStream.WriteLine inLine
Loop Until inStream.AtEndOfStream
inStream.Close
outStream.Close
If argCount = 1 Then WshShell.Run "cmd.exe /c del " & inFile, 0
|
<filename>printscan/faxsrv/com/win2k/vbtest/route.frm
VERSION 5.00
Begin VB.Form RoutingMethodWindow
BorderStyle = 3 'Fixed Dialog
Caption = "Routing Method"
ClientHeight = 5595
ClientLeft = 45
ClientTop = 330
ClientWidth = 8160
BeginProperty Font
Name = "Comic Sans MS"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "route.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5595
ScaleWidth = 8160
ShowInTaskbar = 0 'False
Begin VB.TextBox RoutingData
BackColor = &H8000000F&
Enabled = 0 'False
Height = 495
Left = 2040
TabIndex = 18
Top = 4920
Width = 6015
End
Begin VB.CommandButton EnableDisable
Height = 495
Left = 4080
TabIndex = 16
Top = 1320
Width = 3975
End
Begin VB.TextBox ExtensionName
BackColor = &H8000000F&
Enabled = 0 'False
Height = 495
Left = 2040
TabIndex = 15
Top = 4320
Width = 6015
End
Begin VB.TextBox ImageName
BackColor = &H8000000F&
Enabled = 0 'False
Height = 495
Left = 2040
TabIndex = 14
Top = 3720
Width = 6015
End
Begin VB.TextBox FunctionName
BackColor = &H8000000F&
Enabled = 0 'False
Height = 495
Left = 2040
TabIndex = 13
Top = 3120
Width = 6015
End
Begin VB.TextBox FriendlyName
BackColor = &H8000000F&
Enabled = 0 'False
Height = 495
Left = 2040
TabIndex = 12
Top = 2520
Width = 6015
End
Begin VB.TextBox Guid
BackColor = &H8000000F&
Enabled = 0 'False
Height = 495
Left = 2040
TabIndex = 11
Top = 1920
Width = 6015
End
Begin VB.TextBox IsEnabled
BackColor = &H8000000F&
Enabled = 0 'False
Height = 495
Left = 2040
TabIndex = 10
Top = 1320
Width = 1935
End
Begin VB.TextBox DeviceName
BackColor = &H8000000F&
Enabled = 0 'False
Height = 495
Left = 2040
TabIndex = 2
Top = 720
Width = 6015
End
Begin VB.TextBox DeviceId
BackColor = &H8000000F&
Enabled = 0 'False
Height = 495
Left = 2040
TabIndex = 0
Top = 120
Width = 1935
End
Begin VB.Label Label9
Caption = "Routing Data:"
Height = 375
Left = 120
TabIndex = 17
Top = 5040
Width = 1815
End
Begin VB.Label Label8
Caption = "Extension Name:"
Height = 375
Left = 120
TabIndex = 9
Top = 4440
Width = 1815
End
Begin VB.Label Label7
Caption = "Image Name:"
Height = 375
Left = 120
TabIndex = 8
Top = 3840
Width = 1815
End
Begin VB.Label Label6
Caption = "Function Name:"
Height = 375
Left = 120
TabIndex = 7
Top = 3240
Width = 1815
End
Begin VB.Label Label5
Caption = "Friendly Name:"
Height = 375
Left = 120
TabIndex = 6
Top = 2640
Width = 1815
End
Begin VB.Label Label4
Caption = "Guid:"
Height = 375
Left = 120
TabIndex = 5
Top = 2040
Width = 1815
End
Begin VB.Label Label3
Caption = "Enabled:"
Height = 375
Left = 120
TabIndex = 4
Top = 1440
Width = 1815
End
Begin VB.Label Label2
Caption = "Device Name:"
Height = 375
Left = 120
TabIndex = 3
Top = 840
Width = 1815
End
Begin VB.Label Label1
Caption = "Device Id:"
Height = 375
Left = 120
TabIndex = 1
Top = 240
Width = 1815
End
End
Attribute VB_Name = "RoutingMethodWindow"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub EnableDisable_Click()
If Method.Enable = 0 Then
Method.Enable = 1
Else
Method.Enable = 0
End If
SetEnable
End Sub
Private Sub Form_Load()
Height = RoutingData.Top + RoutingData.Height + 600
Width = ExtensionName.Left + ExtensionName.Width + 250
End Sub
Public Sub MyInit()
DeviceId.Text = CStr(Method.DeviceId)
DeviceName.Text = Method.DeviceName
SetEnable
Guid.Text = Method.Guid
FriendlyName.Text = Method.FriendlyName
FunctionName.Text = Method.FunctionName
ImageName.Text = Method.ImageName
ExtensionName.Text = Method.ExtensionName
RoutingData.Text = Method.RoutingData
End Sub
Private Sub SetEnable()
If Method.Enable = 0 Then
IsEnabled.Text = CStr("No")
EnableDisable.Caption = CStr("Enable")
Else
IsEnabled.Text = CStr("Yes")
EnableDisable.Caption = CStr("Disable")
End If
End Sub
|
Function josephus(n,k,s)
Set prisoner = CreateObject("System.Collections.ArrayList")
For i = 0 To n - 1
prisoner.Add(i)
Next
index = -1
Do Until prisoner.Count = s
step_count = 0
Do Until step_count = k
If index+1 <= prisoner.Count-1 Then
index = index+1
Else
index = (index+1)-(prisoner.Count)
End If
step_count = step_count+1
Loop
prisoner.RemoveAt(index)
index = index-1
Loop
For j = 0 To prisoner.Count-1
If j < prisoner.Count-1 Then
josephus = josephus & prisoner(j) & ","
Else
josephus = josephus & prisoner(j)
End If
Next
End Function
'testing the function
WScript.StdOut.WriteLine josephus(5,2,1)
WScript.StdOut.WriteLine josephus(41,3,1)
WScript.StdOut.WriteLine josephus(41,3,3)
|
<reponame>LaudateCorpus1/RosettaCodeData<filename>Task/Pi/Visual-Basic/pi.vb<gh_stars>1-10
Option Explicit
Sub Main()
Const VECSIZE As Long = 3350
Const BUFSIZE As Long = 201
Dim buffer(1 To BUFSIZE) As Long
Dim vect(1 To VECSIZE) As Long
Dim more As Long, karray As Long, num As Long, k As Long, l As Long, n As Long
For n = 1 To VECSIZE
vect(n) = 2
Next n
For n = 1 To BUFSIZE
karray = 0
For l = VECSIZE To 1 Step -1
num = 100000 * vect(l) + karray * l
karray = num \ (2 * l - 1)
vect(l) = num - karray * (2 * l - 1)
Next l
k = karray \ 100000
buffer(n) = more + k
more = karray - k * 100000
Next n
Debug.Print CStr(buffer(1));
Debug.Print "."
l = 0
For n = 2 To BUFSIZE
Debug.Print Format$(buffer(n), "00000");
l = l + 1
If l = 10 Then
l = 0
Debug.Print 'line feed
End If
Next n
End Sub
|
<gh_stars>1-10
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
Public Function isSafe(i, j, n) As Boolean
Dim iMin As Integer
Dim jMin As Integer
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
Public Sub Sudoku()
'main routine
'to use, fill in the grid and
'type "Sudoku" in the Immediate panel of the Visual Basic for Applications window
Dim s(9) As String
'initialise grid using 9 strings,one per row
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(Val(Mid$(s(i), j, 1)))
Next j
Next i
'solve it!
Solve 1, 1
'print solution
Debug.Print "Solution:"
For i = 1 To 9
For j = 1 To 9
Debug.Print Format$(gridSolved(i, j)); " ";
Next j
Debug.Print
Next i
End Sub
|
<reponame>npocmaka/Windows-Server-2003
Dim s
Dim sink
Sub MYSINK_OnCompleted(iHResult, objErrorObject, objAsyncContext)
WScript.Echo "Done"
End Sub
Set locator = CreateObject("WbemScripting.SWbemLocator")
Set sink = WScript.CreateObject("WbemScripting.SWbemSink", "MYSINK_")
locator.OpenAsync sink, "umi://./winnt"
WScript.Echo "Hanging"
|
<filename>w/wsh.vbs
WScript.Echo "Fuck You Github"
WScript.Quit
|
<reponame>npocmaka/Windows-Server-2003
Option Explicit
'***********************************************************************
'
' ClusResGroups and related tests
'
'***********************************************************************
'
'Following are marks for lines to be included in translated script version of test
StartTest
'----------------------------------------------------------------------
Sub StartTest()
On Error Resume Next
Dim oLogView
'Set oLogView = CreateObject("Atl1.LogView")
'oLogView.logFileName = "d:\nt\private\cluster\admin\msclus\vbscript\vbResGroups.log"
'oLogView.logFileName = "d:\\projects\\msclust\\vb\\jsResGroups.log"
ResGroupsTest oLogView
End Sub
'-----------------------------------------------------------------------
Sub ResGroupsTest(oLogView)
On Error Resume Next
Dim oCluster
Dim collResGroups
'oLogView.AddResult1 1, "Creating object MSCluster.Cluster"
'JS_TRY<
Set oCluster = CreateObject("MSCluster.Cluster")
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "Cluster creation failed:" & Err.Description
Exit Sub
Else
'oLogView.AddResult1 8, "Instance of Cluster created"
End If
'JS_TRY<
oCluster.Open ("GALENB-CLUS")
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "Cluster open failed:" & Err.Description
Exit Sub
Else
'oLogView.AddResult1 8, "Cluster IGORPCLUS opened successfuly"
End If
'JS_TRY<
Set collResGroups = oCluster.ResourceGroups
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "Cluster:ResGroups failed:" & Err.Description
Exit Sub
Else
'oLogView.AddResult1 8, "Cluster:ResGroups retrieved"
End If
RunResGroupsTests oLogView, collResGroups
End Sub
'-----------------------------------------------------------------------
Sub RunResGroupsTests(oLogView, collResGroups)
On Error Resume Next
Dim count
Dim oResGroup
'JS_TRY<
count = collResGroups.count
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroups:Count failed:" & Err.Description
Exit Sub
Else
'oLogView.AddResult1 8, "ClusResGroups:Count: " & count
End If
'test collection's Refresh
TestRefresh oLogView, collResGroups
'---------- Create new group
'JS_TRY<
Set oResGroup = collResGroups.CreateItem("8TestGroup")
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroups:CreateItem(8TestGroup) failed:" & Err.Description
Exit Sub 'nothing to test
Else
'oLogView.AddResult1 8, "ClusResGroups:CreateItem(8TestGroup) succeeded"
TestResGroup oLogView, oResGroup
TestPreferredOwners oLogView, oResGroup
'JS_TRY<
collResGroups.DeleteItem ("8TestGroup")
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroups:DeleteItem(8TestGroup) failed:" & Err.Description
Err.Clear 'clean exit
Else
'oLogView.AddResult1 8, "ClusResGroups:DeleteItem(8TestGroup) succeeded"
End If
End If
End Sub
'-----------------------------------------------------------------------
Sub TestResGroup(oLogView, oResGroup)
On Error Resume Next
' all common stuff is tested in common test
Dim state
Dim oCluster
Dim groupName
'----------- test renaming
'oLogView.AddResult1 1, "Testing ClusResGroup.Name member"
'JS_TRY
groupName = oResGroup.Name
'JS_CATCH
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "Get ClusResGroup.Name failed:" & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroup.Name: " & groupName
'JS_TRY
oResGroup.Name = "8TestAnotherName"
'JS_CATCH
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "Renaming ClusResGroup.Name failed:" & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "New ClusResGroup.Name: " & oResGroup.Name
'JS_TRY
oResGroup.Name = groupName
'JS_CATCH
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "Renaming to original name failed:" & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "Original ClusResGroup.Name restored: " & groupName
End If
End If
End If
'----------- state
'JS_TRY<
state = oResGroup.state
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroup.State failed:" & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroup.State: " & state
'should be offline - freshly created
If state = 1 Then 'ClusterGroupOffline
TestGroupResources oLogView, oResGroup
Else
'oLogView.AddResult1 3, "Created group " & oResGroup.Name & " not in expected offline state. Current state: " & state
End If 'no offline
End If
End Sub
'-----------------------------------------------------------------------
Sub TestGroupResources(oLogView, oResGroup)
On Error Resume Next
Dim collResources
Dim oResource
Dim lCount
Dim oOwnerNode
Dim state
Dim oAnotherOwner 'this time as VARIANT
'JS_TRY<
Set collResources = oResGroup.Resources
lCount = collResources.count
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "Get ClusResGroup.Resources failed:" & Err.Description
Exit Sub
Else
'oLogView.AddResult1 8, "Get ClusResGroup.Resources succeeded. Number of resources: " & lCount
'add item
'JS_TRY<
Set oResource = collResources.CreateItem("8TestResource", "Generic Application", 0)
collResources.Refresh
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroupResource.CreateItem failed:" & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroupResource.CreateItem( Generic application) succeeded"
End If
If collResources.count <> 1 Then
'oLogView.AddResult1 2, "ClusResGroup.Resources.CreateItem: added resource not in collection"
Else
'oLogView.AddResult1 8, "ClusResGroup.Resources.CreateItem: count = 1"
End If
'JS_TRY<
collResources.DeleteItem ("8TestResource")
collResources.Refresh
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroup.Resources.DeleteItem failed: " & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroup.Resources.DeleteItem succeeded"
End If
If collResources.count <> 0 Then
'oLogView.AddResult1 2, "ClusResGroup.Resources.DeleteItem: refresh after DeleteItem failure"
Else
'oLogView.AddResult1 8, "ClusResGroup.Resources.DeleteItem Refresh count = 0"
End If
'------------ online
'JS_TRY<
MsgBox "Online"
oResGroup.Online( 10000 )
'JS_CATCH>
If Err.Number <> 0 Then
MsgBox "Online Error " & Err.Description
'oLogView.AddResult1 2, "ClusResGroup.Online failed: " & Err.Description
Err.Clear
Else
MsgBox "Online succeeded"
'oLogView.AddResult1 8, "ClusResGroup.Online succeeded"
End If
'------------ offline
'JS_TRY<
oResGroup.Offline 10000
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroup.Offline failed: " & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroup.Offline succeeded"
End If
'------------- OwnerNode
'JS_TRY<
Set oOwnerNode = oResGroup.OwnerNode
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroup.OwnerNode failed: " & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroup.OwnerNode succeeded"
End If
'------------- move
'JS_TRY<
oResGroup.Move 10000
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroup.Move failed: " & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroup.Move succeeded"
Set oAnotherOwner = oResGroup.OwnerNode
If oAnotherOwner.Name <> oOwnerNode.Name Then
'oLogView.AddResult1 8, "New owner of test group: " & oAnotherOwner.Name
Else
'oLogView.AddResult1 2, "New owner of test group after Move is the same as original: " & oAnotherOwner.Name
End If
End If
'move back
'JS_TRY<
oResGroup.Move 10000, oOwnerNode
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroup.Move to original node failed: " & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroup.Move to original node succeeded"
Set oAnotherOwner = oResGroup.OwnerNode
If oAnotherOwner.Name = oOwnerNode.Name Then
'oLogView.AddResult1 8, "New owner of test group is original node " & oAnotherOwner.Name
Else
'oLogView.AddResult1 2, "New owner of test group after Move differs original: " & oAnotherOwner.Name
End If
End If
Set oAnotherOwner = Nothing
'move it again and bring online on original node
'JS_TRY<
oResGroup.Move 10000
oResGroup.Online 10000, oOwnerNode
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroup.Move/Online failed: " & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroup.Move/Online succeeded"
'check that node is online on expected node
state = oResGroup.state
If state <> 0 Then 'ClusterGroupOnline
'oLogView.AddResult1 2, "State after ClusResGroup.Move/Online differs from expected online: " & state
Else
'oLogView.AddResult1 8, "State after ClusResGroup.Move/Online as expected: online"
End If
Set oAnotherOwner = oResGroup.OwnerNode
If oAnotherOwner.Name = oOwnerNode.Name Then
'oLogView.AddResult1 8, "New owner of test group is original node " & oAnotherOwner.Name
Else
'oLogView.AddResult1 2, "New owner of test group after Move differs original: " & oAnotherOwner.Name
End If
End If
oResGroup.Offline 10000
End If
End Sub
'-----------------------------------------------------------------------
Sub TestPreferredOwners(oLogView, oResGroup)
On Error Resume Next
Dim collPreferredOwnerNodes
Dim lCount
Dim oClusNode 'try this as VARIANT
'JS_TRY<
Set collPreferredOwnerNodes = oResGroup.PreferredOwnerNodes
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "Get ClusResGroup.PreferredOwnerNodes failed: " & Err.Description
Exit Sub
Else
TestRefresh oLogView, collPreferredOwnerNodes
'JS_TRY<
'check number of preferred owners in collection
lCount = collPreferredOwnerNodes.count
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.Count failed: " & Err.Description
Exit Sub
Else
'add node to the group
'JS_TRY<
Set oClusNode = oResGroup.OwnerNode
collPreferredOwnerNodes.InsertItem oClusNode
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.InsertItem failed: " & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroupPreferredOwnerNodes.InsertItem succeeded"
'check that Modified flag is set
If collPreferredOwnerNodes.Modified <> 0 Then 'we expect true here
'oLogView.AddResult1 8, "Flag ClusResGroupPreferredOwnerNodes.Modify set after InsertItem"
Else
'oLogView.AddResult1 3, "Flag ClusResGroupPreferredOwnerNodes.Modify NOT set after InsertItem"
End If
collPreferredOwnerNodes.Refresh
If collPreferredOwnerNodes.Modified <> 0 Then 'we expect false here
'oLogView.AddResult1 3, "Flag ClusResGroupPreferredOwnerNodes.Modify set after Refresh after InsertItem"
Else
'oLogView.AddResult1 8, "Flag ClusResGroupPreferredOwnerNodes.Modify not set after Refresh after InsertItem"
End If
'check number of items in collection
If collPreferredOwnerNodes.count = 1 Then
'oLogView.AddResult1 8, "ClusResGroupPreferredOwnerNodes.count is 1"
Else
'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.count is NOT 1: " & collPreferredOwnerNodes.count
End If
'--------- now remove item from collection
'JS_TRY<
collPreferredOwnerNodes.RemoveItem oClusNode.Name
'JS_CATCH>
If Err.Number <> 0 Then
'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.RemoveItem failed: " & Err.Description
Err.Clear
Else
'oLogView.AddResult1 8, "ClusResGroupPreferredOwnerNodes.RemoveItem succeeded"
'check that Modified flag is set
If collPreferredOwnerNodes.Modified <> 0 Then 'we expect true here
'oLogView.AddResult1 8, "Flag ClusResGroupPreferredOwnerNodes.Modify set after RemoveItem"
Else
'oLogView.AddResult1 3, "Flag ClusResGroupPreferredOwnerNodes.Modify NOT set after RemoveItem"
End If
collPreferredOwnerNodes.Refresh
If collPreferredOwnerNodes.Modified <> 0 Then 'we expect false here
'oLogView.AddResult1 3, "Flag ClusResGroupPreferredOwnerNodes.Modify set after Refresh after RemoveItem"
Else
'oLogView.AddResult1 8, "Flag ClusResGroupPreferredOwnerNodes.Modify not set after Refresh after RemoveItem"
End If
'check number of items in collection
If collPreferredOwnerNodes.count = 0 Then
'oLogView.AddResult1 8, "ClusResGroupPreferredOwnerNodes.count is 0"
Else
'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.count is NOT 0"
End If
End If
End If
End If
End If
End Sub
'-----------------------------------------------------------------------
'-----------------------------------------------------------------------
Sub TestRefresh(oLogObject, colCollection)
On Error Resume Next
Dim origCount
Dim afterCount
'JS_TRY<
origCount = colCollection.count
colCollection.Refresh
afterCount = colCollection.count
'JS_CATCH>
If Err.Number <> 0 Then
'oLogObject.AddResult1 2, "Refresh failed with error:" & Err.Description
Else
If origCount <> afterCount Then 'counts are not equal
'oLogObject.AddResult1 2, "Count changes after Refresh:" & origCount & " differs from " & afterCount
Else
'oLogObject.AddResult1 8, "Refresh succeeded"
End If
End If
End Sub
'----------------------- End of file -----------------------------------
'*****************************************************************************
'*
'* Translated by VB2script translator on Thu Feb 18 17:31:58 1999
'* from file resgroups.bas
'*
'*****************************************************************************
|
<reponame>npocmaka/Windows-Server-2003<filename>admin/wmi/wbem/scripting/test/whistler/objpath/umipath.vbs
set path = CreateObject("WbemScripting.SWbemObjectPathEX")
path.Path = "umi://./ldap/admin/users/foo"
WScript.Echo path.Path
if err <> 0 then
WScript. Hex(Err), Err.Description
end if
|
Option Explicit
Sub Test_a_function()
Dim a, i&
a = Array("abba", "mom", "dennis sinned", "Un roc lamina l animal cornu", "palindrome", "ba _ ab", "racecars", "racecar", "wombat", "in girum imus nocte et consumimur igni")
For i = 0 To UBound(a)
Debug.Print a(i) & " is a palidrome ? " & IsPalindrome(CStr(a(i)))
Next
End Sub
Function IsPalindrome(txt As String) As Boolean
Dim tempTxt As String
tempTxt = LCase(Replace(txt, " ", ""))
IsPalindrome = (tempTxt = StrReverse(tempTxt))
End Function
|
option explicit
dim a, b
wscript.stdout.write "A? "
a = wscript.stdin.readline
wscript.stdout.write "B? "
b = wscript.stdin.readline
a = int( a )
b = int( b )
dim op
for each op in split("+ - * / \ mod ^", " ")
wscript.echo "a",op,"b=",eval( "a " & op & " b")
next
|
VERSION 5.00
Begin VB.Form SimpleEditForm
BorderStyle = 3 'Fixed Dialog
Caption = "Edit Metabase Data"
ClientHeight = 3585
ClientLeft = 45
ClientTop = 330
ClientWidth = 5310
Icon = "SimpEdit.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3585
ScaleWidth = 5310
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.ComboBox NameCombo
Height = 315
Left = 1320
Sorted = -1 'True
Style = 2 'Dropdown List
TabIndex = 17
Top = 240
Width = 2535
End
Begin VB.TextBox IdText
Height = 285
Left = 3960
TabIndex = 16
Top = 240
Width = 1215
End
Begin VB.CommandButton OkButton
Caption = "OK"
Default = -1 'True
Height = 345
Left = 2520
TabIndex = 15
Top = 3120
Width = 1260
End
Begin VB.CommandButton CancelButton
Caption = "Cancel"
Height = 345
Left = 3960
TabIndex = 14
Top = 3120
Width = 1260
End
Begin VB.CheckBox InsertPathCheck
Caption = "Insert Path"
Height = 255
Left = 2640
TabIndex = 13
Top = 1200
Width = 1215
End
Begin VB.CheckBox VolatileCheck
Caption = "Volatile"
Height = 255
Left = 1320
TabIndex = 12
Top = 1200
Width = 1215
End
Begin VB.CheckBox ReferenceCheck
Caption = "Reference"
Height = 255
Left = 3960
TabIndex = 11
Top = 720
Width = 1215
End
Begin VB.CheckBox SecureCheck
Caption = "Secure"
Height = 255
Left = 2640
TabIndex = 10
Top = 720
Width = 1215
End
Begin VB.CheckBox InheritCheck
Caption = "Inherit"
Height = 255
Left = 1320
TabIndex = 9
Top = 720
Width = 1215
End
Begin VB.ComboBox DataTypeCombo
Height = 315
Left = 1320
Style = 2 'Dropdown List
TabIndex = 8
Top = 2160
Width = 2535
End
Begin VB.TextBox UserTypeText
Enabled = 0 'False
Height = 285
Left = 3960
TabIndex = 7
Top = 1680
Width = 1215
End
Begin VB.ComboBox UserTypeCombo
Height = 315
Left = 1320
Sorted = -1 'True
Style = 2 'Dropdown List
TabIndex = 6
Top = 1680
Width = 2535
End
Begin VB.TextBox DataText
Height = 285
Left = 1320
TabIndex = 0
Top = 2640
Width = 3855
End
Begin VB.Label Label5
Caption = "Data:"
Height = 255
Left = 120
TabIndex = 5
Top = 2640
Width = 975
End
Begin VB.Label Label4
Caption = "Data Type:"
Height = 255
Left = 120
TabIndex = 4
Top = 2160
Width = 975
End
Begin VB.Label Label3
Caption = "User Type:"
Height = 255
Left = 120
TabIndex = 3
Top = 1680
Width = 975
End
Begin VB.Label Label2
Caption = "Atributes:"
Height = 255
Left = 120
TabIndex = 2
Top = 720
Width = 975
End
Begin VB.Label Label1
Caption = "Id:"
Height = 255
Left = 120
TabIndex = 1
Top = 240
Width = 975
End
End
Attribute VB_Name = "SimpleEditForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
DefInt A-Z
'Form parameters
Public Machine As String
Public Key As String
Public Id As Long '0 = New
Public NewDataType As String 'New only
'Metabase Constants
Const METADATA_NO_ATTRIBUTES = &H0
Const METADATA_INHERIT = &H1
Const METADATA_PARTIAL_PATH = &H2
Const METADATA_SECURE = &H4
Const METADATA_REFERENCE = &H8
Const METADATA_VOLATILE = &H10
Const METADATA_ISINHERITED = &H20
Const METADATA_INSERT_PATH = &H40
Const IIS_MD_UT_SERVER = 1
Const IIS_MD_UT_FILE = 2
Const IIS_MD_UT_WAM = 100
Const ASP_MD_UT_APP = 101
Const ALL_METADATA = 0
Const DWORD_METADATA = 1
Const STRING_METADATA = 2
Const BINARY_METADATA = 3
Const EXPANDSZ_METADATA = 4
Const MULTISZ_METADATA = 5
Private Sub Form_Load()
'Init UserTypeCombo
UserTypeCombo.Clear
UserTypeCombo.AddItem "Server"
UserTypeCombo.AddItem "File"
UserTypeCombo.AddItem "WAM"
UserTypeCombo.AddItem "ASP App"
UserTypeCombo.AddItem "Other"
UserTypeCombo.Text = "Server"
'Init DataTypeCombo
DataTypeCombo.Clear
DataTypeCombo.AddItem "DWord"
DataTypeCombo.AddItem "String"
DataTypeCombo.AddItem "Binary"
DataTypeCombo.AddItem "Expand String"
DataTypeCombo.Text = "DWord"
End Sub
Private Sub LoadPropertyNames()
On Error GoTo LError
Dim NameProperty As Variant
For Each NameProperty In MainForm.MetaUtilObj.EnumProperties(Machine + "\Schema\Properties\Names")
NameCombo.AddItem NameProperty.Data
Next
LError:
End Sub
Public Sub Init()
Dim Property As Object
Dim Attributes As Long
Dim UserType As Long
Dim DataType As Long
If Id = 0 Then
'New data
'Load the Names
NameCombo.Clear
LoadPropertyNames
NameCombo.AddItem "Other"
NameCombo.Text = "Other"
NameCombo.Enabled = True
'Set Id to 0
IdText.Enabled = True
IdText.Text = "0"
'Clear all flags
InheritCheck.Value = vbUnchecked
SecureCheck.Value = vbUnchecked
ReferenceCheck.Value = vbUnchecked
VolatileCheck.Value = vbUnchecked
InsertPathCheck.Value = vbUnchecked
'Set UserType to Server
UserTypeCombo.Text = "Server"
'Set DataType
If NewDataType = DWORD_METADATA Then
DataTypeCombo.Text = "DWord"
ElseIf NewDataType = STRING_METADATA Then
DataTypeCombo.Text = "String"
ElseIf NewDataType = BINARY_METADATA Then
DataTypeCombo.Text = "Binary"
ElseIf NewDataType = EXPANDSZ_METADATA Then
DataTypeCombo.Text = "Expand String"
End If
'Set Data to empty
DataText.Text = ""
Else
'Edit existing
Set Property = MainForm.MetaUtilObj.GetProperty(Key, Id)
'Set the Name
NameCombo.Clear
If Property.Name <> "" Then
NameCombo.AddItem Property.Name
NameCombo.Text = Property.Name
Else
NameCombo.AddItem "Other"
NameCombo.Text = "Other"
End If
NameCombo.Enabled = False
'Set Id
IdText.Enabled = False
IdText.Text = Str(Property.Id)
'Set attributes
Attributes = Property.Attributes
If (Attributes And METADATA_INHERIT) = METADATA_INHERIT Then
InheritCheck.Value = vbChecked
Else
InheritCheck.Value = vbUnchecked
End If
If (Attributes And METADATA_SECURE) = METADATA_SECURE Then
SecureCheck.Value = vbChecked
Else
SecureCheck.Value = vbUnchecked
End If
If (Attributes And METADATA_REFERENCE) = METADATA_REFERENCE Then
ReferenceCheck.Value = vbChecked
Else
ReferenceCheck.Value = vbUnchecked
End If
If (Attributes And METADATA_VOLATILE) = METADATA_VOLATILE Then
VolatileCheck.Value = vbChecked
Else
VolatileCheck.Value = vbUnchecked
End If
If (Attributes And METADATA_INSERT_PATH) = METADATA_INSERT_PATH Then
InsertPathCheck.Value = vbChecked
Else
InsertPathCheck.Value = vbUnchecked
End If
'Set UserType
UserType = Property.UserType
If UserType = IIS_MD_UT_SERVER Then
UserTypeCombo.Text = "Server"
ElseIf UserType = IIS_MD_UT_FILE Then
UserTypeCombo.Text = "File"
ElseIf UserType = IIS_MD_UT_WAM Then
UserTypeCombo.Text = "WAM"
ElseIf UserType = ASP_MD_UT_APP Then
UserTypeCombo.Text = "ASP App"
Else
UserTypeCombo.Text = "Other"
UserTypeText.Text = Str(UserType)
End If
'Set DataType
DataType = Property.DataType
If DataType = DWORD_METADATA Then
DataTypeCombo.Text = "DWord"
ElseIf DataType = STRING_METADATA Then
DataTypeCombo.Text = "String"
ElseIf DataType = BINARY_METADATA Then
DataTypeCombo.Text = "Binary"
ElseIf DataType = EXPANDSZ_METADATA Then
DataTypeCombo.Text = "Expand String"
End If
'Set Data
If DataType = BINARY_METADATA Then
LoadBinaryData Property
Else
DataText.Text = CStr(Property.Data)
End If
End If
End Sub
Private Sub LoadBinaryData(Property As Object)
Dim DataStr As String
Dim DataBStr As String
Dim i As Long
Dim DataByte As Integer
'Display as a list of bytes
DataStr = ""
DataBStr = Property.Data
For i = 1 To LenB(DataBStr)
DataByte = AscB(MidB(DataBStr, i, 1))
If DataByte < 16 Then
DataStr = DataStr & "0" & Hex(AscB(MidB(DataBStr, i, 1))) & " "
Else
DataStr = DataStr & Hex(AscB(MidB(DataBStr, i, 1))) & " "
End If
Next
DataText.Text = DataStr
End Sub
Private Function HexVal(ByVal HexStr As String) As Integer
Dim Ret As Integer
Ret = 0
Do While HexStr <> ""
Ret = Ret * 16
If Right(HexStr, 1) = "1" Then
Ret = Ret + 1
ElseIf Right(HexStr, 1) = "2" Then
Ret = Ret + 2
ElseIf Right(HexStr, 1) = "3" Then
Ret = Ret + 3
ElseIf Right(HexStr, 1) = "4" Then
Ret = Ret + 4
ElseIf Right(HexStr, 1) = "5" Then
Ret = Ret + 5
ElseIf Right(HexStr, 1) = "6" Then
Ret = Ret + 6
ElseIf Right(HexStr, 1) = "7" Then
Ret = Ret + 7
ElseIf Right(HexStr, 1) = "8" Then
Ret = Ret + 8
ElseIf Right(HexStr, 1) = "9" Then
Ret = Ret + 9
ElseIf Right(HexStr, 1) = "A" Then
Ret = Ret + 10
ElseIf Right(HexStr, 1) = "B" Then
Ret = Ret + 11
ElseIf Right(HexStr, 1) = "C" Then
Ret = Ret + 12
ElseIf Right(HexStr, 1) = "D" Then
Ret = Ret + 13
ElseIf Right(HexStr, 1) = "E" Then
Ret = Ret + 14
ElseIf Right(HexStr, 1) = "F" Then
Ret = Ret + 15
End If
HexStr = Right(HexStr, Len(HexStr) - 1)
Loop
HexVal = Ret
End Function
Private Sub SaveBinaryData(Property As Object)
Dim WorkStr As String
Dim OutBStr As String
Dim i As Long
Dim CurByte As String
WorkStr = DataText.Text
OutBStr = ""
Do While WorkStr <> ""
'Skip leading spaces
Do While Left(WorkStr, 1) = " "
WorkStr = Right(WorkStr, Len(WorkStr) - 1)
Loop
'Get a byte
i = 0
CurByte = Left(WorkStr, 1)
Do While (CurByte <> "") And (CurByte <> " ")
i = i + 1
CurByte = Mid(WorkStr, i + 1, 1)
Loop
If i > 0 Then
OutBStr = OutBStr + ChrB(HexVal(Left(WorkStr, i)))
End If
WorkStr = Right(WorkStr, Len(WorkStr) - i)
Loop
Property.Data = OutBStr
End Sub
Private Sub NameCombo_Click()
If NameCombo.Text <> "Other" Then
IdText.Enabled = False
IdText.Text = Str(MainForm.MetaUtilObj.PropNameToId(Key, NameCombo.Text))
Else
IdText.Enabled = True
End If
End Sub
Private Sub UserTypeCombo_Click()
If UserTypeCombo.Text = "Other" Then
UserTypeText.Enabled = True
UserTypeText.Text = ""
UserTypeText.SetFocus
Else
UserTypeText.Enabled = False
If UserTypeCombo.Text = "Server" Then
UserTypeText.Text = Str(IIS_MD_UT_SERVER)
ElseIf UserTypeCombo.Text = "File" Then
UserTypeText.Text = Str(IIS_MD_UT_FILE)
ElseIf UserTypeCombo.Text = "WAM" Then
UserTypeText.Text = Str(IIS_MD_UT_WAM)
ElseIf UserTypeCombo.Text = "ASP App" Then
UserTypeText.Text = Str(ASP_MD_UT_APP)
Else
UserTypeText = "0"
End If
End If
End Sub
Private Sub OkButton_Click()
'On Error GoTo LError:
Dim Property As Object
Dim Attributes As Long
'Check fields
If CLng(IdText.Text) = 0 Then
MsgBox "Id must be nonzero", _
vbExclamation + vbOKOnly, "Edit Metabase Data"
Exit Sub
End If
'Write data
If Id = 0 Then
Set Property = MainForm.MetaUtilObj.CreateProperty(Key, CLng(IdText.Text))
Else
Set Property = MainForm.MetaUtilObj.GetProperty(Key, CLng(IdText.Text))
End If
Attributes = METADATA_NO_ATTRIBUTES
If InheritCheck.Value = vbChecked Then
Attributes = Attributes + METADATA_INHERIT
ElseIf SecureCheck.Value = vbChecked Then
Attributes = Attributes + METADATA_SECURE
ElseIf ReferenceCheck.Value = vbChecked Then
Attributes = Attributes + METADATA_REFERENCE
ElseIf VolatileCheck.Value = vbChecked Then
Attributes = Attributes + METADATA_VOLATILE
ElseIf InsertPathCheck.Value = vbChecked Then
Attributes = Attributes + METADATA_INSERT_PATH
End If
Property.Attributes = Attributes
Property.UserType = CLng(UserTypeText.Text)
If DataTypeCombo.Text = "DWord" Then
Property.DataType = DWORD_METADATA
Property.Data = CLng(DataText.Text)
ElseIf DataTypeCombo.Text = "String" Then
Property.DataType = STRING_METADATA
Property.Data = DataText.Text
ElseIf DataTypeCombo.Text = "Binary" Then
Property.DataType = BINARY_METADATA
SaveBinaryData Property
ElseIf DataTypeCombo.Text = "Expand String" Then
Property.DataType = EXPANDSZ_METADATA
Property.Data = DataText.Text
End If
Property.Write
'Clean up
Me.Hide
Exit Sub
LError:
MsgBox "Failure to write property: " & Err.Description, _
vbExclamation + vbOKOnly, "Edit Metabase Data"
End Sub
Private Sub CancelButton_Click()
Me.Hide
End Sub
|
<reponame>mullikine/RosettaCodeData
Public Sub Doors100()
' the state of a door is represented by the data type boolean (false = door closed, true = door opened)
Dim doorstate(1 To 100) As Boolean ' the doorstate()-array is initialized by VB with value 'false'
Dim i As Long, j As Long
For i = 1 To 100
For j = i To 100 Step i
doorstate(j) = Not doorstate(j)
Next j
Next i
Debug.Print "The following doors are open:"
For i = 1 To 100
' print number if door is openend
If doorstate(i) Then Debug.Print CStr(i)
Next i
End Sub
|
<gh_stars>10-100
Set Args = wscript.Arguments
RpNum = Args.item(0)
Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")
if obj.Restore(RpNum) <> 0 Then
wscript.Echo "Restore failed"
End If
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.Reboot()
next
|
<filename>admin/wmi/wbem/scripting/test/vbscript/methodex1.vbs
on error resume next
set process = GetObject("winmgmts:{impersonationLevel=impersonate}!Win32_Process")
set startupinfo = GetObject("winmgmts:{impersonationLevel=impersonate}!Win32_ProcessStartup")
set instance = startupinfo.SpawnInstance_
instance.Title = "Hairy woobit"
result = process.Create ("notepad.exe",,instance,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
|
Public Sub TestSplit(Optional align As String = "left", Optional spacing As Integer = 1)
Dim word() As String
Dim colwidth() As Integer
Dim ncols As Integer
Dim lines(6) As String
Dim nlines As Integer
'check arguments
If Not (align = "left" Or align = "right" Or align = "center") Then
MsgBox "TestSplit: wrong argument 'align': " & align
Exit Sub
End If
If spacing < 0 Then
MsgBox "TestSplit: wrong argument: 'spacing' cannot be negative."
Exit Sub
End If
' Sample Input (should be from a file)
nlines = 6
lines(1) = "Given$a$text$file$of$many$lines,$where$fields$within$a$line$"
lines(2) = "are$delineated$by$a$single$'dollar'$character,$write$a$program"
lines(3) = "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$"
lines(4) = "column$are$separated$by$at$least$one$space."
lines(5) = "Further,$allow$for$each$word$in$a$column$to$be$either$left$"
lines(6) = "justified,$right$justified,$or$center$justified$within$its$column."
'first pass: count columns and column widths
'the words are not kept in memory
ncols = -1
For l = 1 To nlines
word = Split(RTrim(lines(l)), "$")
If UBound(word) > ncols Then
ncols = UBound(word)
ReDim Preserve colwidth(ncols)
End If
For i = 0 To UBound(word)
If Len(word(i)) > colwidth(i) Then colwidth(i) = Len(word(i))
Next i
Next l
'discard possibly empty columns at the right
'(this assumes there is at least one non-empty column)
While colwidth(ncols) = 0
ncols = ncols - 1
Wend
'second pass: print in columns
For l = 1 To nlines
word = Split(RTrim(lines(l)), "$")
For i = 0 To UBound(word)
a = word(i)
w = colwidth(i)
If align = "left" Then
Debug.Print a + String$(w - Len(a), " ");
ElseIf align = "right" Then
Debug.Print String$(w - Len(a), " ") + a;
ElseIf align = "center" Then
d = Int((w - Len(a)) / 2)
Debug.Print String$(d, " ") + a + String$(w - (d + Len(a)), " ");
End If
If i < ncols Then Debug.Print Spc(spacing);
Next i
Debug.Print
Next l
End Sub
|
Public Sub sum_of_squares()
Debug.Print WorksheetFunction.SumSq([{1,2,3,4,5,6,7,8,9,10}])
End Sub
|
Function Multiple_Divide(Dividend As Integer, Divisor As Integer, ParamArray numbers() As Variant) As Long
Dim i As Integer
On Error GoTo ErrorHandler
numbers(LBound(numbers)) = Dividend / Divisor
For i = LBound(numbers) + 1 To UBound(numbers)
numbers(i) = numbers(i - 1) / Divisor
Next i
Multiple_Divide = 1: Exit Function
ErrorHandler:
Multiple_Divide = 0
End Function
'For use :
Sub test_Multiple_Divide()
Dim Arr(3) As Variant, Ddd As Integer, Dvs As Integer, L As Long, i As Integer
Ddd = 10: Dvs = 3
L = Multiple_Divide(Ddd, Dvs, Arr(0), Arr(1), Arr(2), Arr(3))
Debug.Print "The function return : " & L
Debug.Print "The values in return are : "
For i = LBound(Arr) To UBound(Arr)
Debug.Print Arr(i)
Next i
Erase Arr
Debug.Print "--------------------------------------"
Ddd = 10: Dvs = 0
L = Multiple_Divide(Ddd, Dvs, Arr(0), Arr(1), Arr(2), Arr(3))
Debug.Print "The function return : " & L
Debug.Print "The values in return are : "
For i = LBound(Arr) To UBound(Arr)
Debug.Print IIf(Arr(i) = "", "vbNullString", "Null")
Next i
End Sub
|
aardvark, ampicillin, gogodala, wolverhampton, zanzibar, zulu
23, 89, 234, 345, 456, 456, 547, 567, 567, 568, 649, 2345, 5769
True, True, True, True, False, False, False, False
-45.99, -3, 1, 2, 2, 4, 67789
2/02/2010 10:19:51 AM, 3/02/2010 10:19:51 AM, 5/02/2010 10:19:51 AM
|
'********************************************************************
'*
'* File: EVENTLOGFILE.VBS
'* Created: July 1998
'* Version: 1.0
'*
'* Main Function: Backup a eventlog file.
'* Usage: EVENTLOGFILE.VBS eventlogfile outputfile [/B | /C]
'* [/S:server] [/U:username] [/W:password] [/Q]
'*
'* Copyright (C) 1998 Microsoft Corporation
'*
'********************************************************************
OPTION EXPLICIT
ON ERROR RESUME NEXT
'Define constants
CONST CONST_ERROR = 0
CONST CONST_WSCRIPT = 1
CONST CONST_CSCRIPT = 2
CONST CONST_SHOW_USAGE = 3
CONST CONST_PROCEED = 4
CONST CONST_BACKUP = "BackUp"
CONST CONST_CLEAR = "Clear"
'Declare variables
Dim strOutputFile, intOpMode, blnQuiet, i
Dim strCommand, strEventLog, strServer, strUserName, strPassword
ReDim strArgumentArray(0)
'Initialize variables
strArgumentArray(0) = ""
blnQuiet = False
strCommand = CONST_BACKUP
strEventLog =""
strServer = ""
strUserName = ""
strPassword = ""
strOutputFile = ""
'Get the command line arguments
For i = 0 to Wscript.arguments.count - 1
ReDim Preserve strArgumentArray(i)
strArgumentArray(i) = Wscript.arguments.Item(i)
Next
'Check whether the script is run using CScript
Select Case intChkProgram()
Case CONST_CSCRIPT
'Do Nothing
Case CONST_WSCRIPT
WScript.Echo "Please run this script using CScript." & vbCRLF & _
"This can be achieved by" & vbCRLF & _
"1. Using ""CScript EVENTLOGFILE.VBS arguments"" for Windows 95/98 or" & vbCRLF & _
"2. Changing the default Windows Scripting Host setting to CScript" & vbCRLF & _
" using ""CScript //H:CScript //S"" and running the script using" & vbCRLF & _
" ""EVENTLOGFILE.VBS arguments"" for Windows NT."
WScript.Quit
Case Else
WScript.Quit
End Select
'Parse the command line
intOpMode = intParseCmdLine(strArgumentArray, strCommand, strEventLog, strServer, _
strUserName, strPassword, strOutputFile, blnQuiet)
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in parsing the command line."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
WScript.Quit
End If
Select Case intOpMode
Case CONST_SHOW_USAGE
Call ShowUsage()
Case CONST_PROCEED
Call BackupLog(strCommand, strEventLog, strServer, _
strUserName, strPassword, strOutputFile)
Case CONST_ERROR
'Do nothing.
Case Else 'Default -- should never happen
Print "Error occurred in passing parameters."
End Select
'********************************************************************
'*
'* Function intChkProgram()
'* Purpose: Determines which program is used to run this script.
'* Input: None
'* Output: intChkProgram is set to one of CONST_ERROR, CONST_WSCRIPT,
'* and CONST_CSCRIPT.
'*
'********************************************************************
Private Function intChkProgram()
ON ERROR RESUME NEXT
Dim strFullName, strCommand, i, j
'strFullName should be something like C:\WINDOWS\COMMAND\CSCRIPT.EXE
strFullName = WScript.FullName
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred."
If Err.Description <> "" Then
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
End If
intChkProgram = CONST_ERROR
Exit Function
End If
i = InStr(1, strFullName, ".exe", 1)
If i = 0 Then
intChkProgram = CONST_ERROR
Exit Function
Else
j = InStrRev(strFullName, "\", i, 1)
If j = 0 Then
intChkProgram = CONST_ERROR
Exit Function
Else
strCommand = Mid(strFullName, j+1, i-j-1)
Select Case LCase(strCommand)
Case "cscript"
intChkProgram = CONST_CSCRIPT
Case "wscript"
intChkProgram = CONST_WSCRIPT
Case Else 'should never happen
Print "An unexpected program is used to run this script."
Print "Only CScript.Exe or WScript.Exe can be used to run this script."
intChkProgram = CONST_ERROR
End Select
End If
End If
End Function
'********************************************************************
'*
'* Function intParseCmdLine()
'* Purpose: Parses the command line.
'* Input: strArgumentArray an array containing input from the command line
'* Output: strCommand a command: backup or clear
'* strEventLog an event log name
'* strServer a machine name
'* strOutputFile an output file name
'* strUserName the current user's name
'* strPassword the current <PASSWORD>'s password
'* blnQuiet specifies whether to suppress messages
'* intParseCmdLine is set to one of CONST_ERROR, CONST_SHOW_USAGE, CONST_PROCEED.
'*
'********************************************************************
Private Function intParseCmdLine(strArgumentArray, strCommand, strEventLog, strServer, _
strUserName, strPassword, strOutputFile, blnQuiet)
ON ERROR RESUME NEXT
Dim strFlag, i
strFlag = strArgumentArray(0)
If strFlag = "" then 'No arguments have been received
Print "Arguments are required."
Print "Please check the input and try again."
intParseCmdLine = CONST_ERROR
Exit Function
End If
If (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _
OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "?") OR (strFlag="h") Then
intParseCmdLine = CONST_SHOW_USAGE
Exit Function
End If
strEventLog = strFlag 'The first parameter is the eventlog file path.
strOutputFile = strArgumentArray(1) 'The second parameter is the backup file path.
For i = 2 to UBound(strArgumentArray)
strFlag = LCase(Left(strArgumentArray(i), InStr(1, strArgumentArray(i), ":")-1))
If Err.Number Then 'An error occurs if there is no : in the string
Err.Clear
Select Case LCase(strArgumentArray(i))
Case "/q"
blnQuiet = True
Case "/b"
strCommand = CONST_BACKUP
Case "/c"
strCommand = CONST_CLEAR
Case Else
Print strArgumentArray(i) & " is not a valid input."
Print "Please check the input and try again."
intParseCmdLine = CONST_ERROR
Exit Function
End Select
Else
Select Case strFlag
Case "/s"
strServer = Right(strArgumentArray(i), Len(strArgumentArray(i))-3)
Case "/u"
strUserName = Right(strArgumentArray(i), Len(strArgumentArray(i))-3)
Case "/w"
strPassword = Right(strArgumentArray(i), Len(strArgumentArray(i))-3)
Case else
Print "Invalid flag " & """" & strFlag & ":""" & "."
Print "Please check the input and try again."
intParseCmdLine = CONST_ERROR
Exit Function
End Select
End If
Next
intParseCmdLine = CONST_PROCEED
If strOutputFile = "" Then
Print "Please enter a backup file path/name."
intParseCmdLine = CONST_ERROR
Exit Function
End If
End Function
'********************************************************************
'*
'* Sub ShowUsage()
'* Purpose: Shows the correct usage to the user.
'* Input: None
'* Output: Help messages are displayed on screen.
'*
'********************************************************************
Private Sub ShowUsage()
Wscript.echo ""
Wscript.echo "Makes a backup copy of an eventlog file." & vbCRLF
Wscript.echo "EVENTLOGFILE.VBS eventlogfile outputfile [/B | /C]"
Wscript.echo "[/S:server] [/U:username] [/W:password] [/Q]"
Wscript.echo " /S, /U, /W Parameter specifiers."
Wscript.Echo " /B Backup the eventlog file."
Wscript.Echo " /C Backup the eventlog file and clears the eventlog."
Wscript.Echo " eventlogfile An eventlog file."
Wscript.Echo " outputfile The output file name."
Wscript.Echo " server Name of the server to be checked."
Wscript.Echo " username The current user's name."
Wscript.Echo " password Password of the <PASSWORD>."
Wscript.Echo " /Q Suppresses all output messages." & vbCRLF
Wscript.Echo "EXAMPLE:"
Wscript.echo "EVENTLOGFILE.VBS D:\WINNT\system32\config\SysEvent.Evt"
Wscript.echo "C:\Backup\system.bak /b"
Wscript.echo " makes a backup copy of the system eventlog file." & vbCRLF
Wscript.Echo "NOTE:"
Wscript.echo " The backup file is located on the same machine as the"
Wscript.echo " eventlog file."
End Sub
'********************************************************************
'*
'* Sub BackupLog()
'* Purpose: Enumberates WBEM classes on a server.
'* Input: strCommand a command: backup or clear
'* strEventLog an event log name
'* strServer a machine name
'* strOutputFile an output file name
'* strUserName the current user's name
'* strPassword <PASSWORD>
'* Output: Results of the search are either printed on screen or saved in strOutputFile.
'*
'********************************************************************
Private Sub BackupLog(strCommand, strEventLog, strServer, _
strUserName, strPassword, strOutputFile)
ON ERROR RESUME NEXT
Dim objService
'Establish a connection with the server.
If blnConnect(objService, strServer, "root/cimv2", strUserName, strPassword) Then
Exit Sub
End If
Call ExecuteMethod(objService, strCommand, strEventLog, strOutputFile)
End Sub
'********************************************************************
'*
'* Function blnConnect()
'* Purpose: Connects to machine strServer.
'* Input: strServer a machine name
'* strNameSpace a namespace
'* strUserName name of the current user
'* strPassword password of the current user
'* Output: objService is returned as a service object.
'*
'********************************************************************
Private Function blnConnect(objService, strServer, strNameSpace, strUserName, strPassword)
ON ERROR RESUME NEXT
Dim objLocator
blnConnect = False 'There is no error.
' Create Locator object to connect to remote CIM object manager
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in creating a locator object."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
blnConnect = True 'An error occurred
Exit Function
End If
' Connect to the namespace which is either local or remote
Set objService = objLocator.ConnectServer (strServer, strNameSpace, _
strUserName, strPassword)
ObjService.Security_.impersonationlevel = 3
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in connecting to server " _
& strServer & "."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
blnConnect = True 'An error occurred
End If
End Function
'********************************************************************
'*
'* Sub ExecuteMethod()
'* Purpose: Executes a method.
'* Input: objService a service object
'* strCommand a command: backup or clear
'* strEventLog an event log name
'* strQuery the query string
'* strOutputFile an output file name
'* Output: Results of the query are either printed on screen or saved in objOutputFile.
'*
'********************************************************************
Private Sub ExecuteMethod(objService, strCommand, strEventLog, strOutputFile)
ON ERROR RESUME NEXT
Dim objEnumerator, objInstance, strQuery, strMessage, intStatus
strQuery = "Win32_NTEventlogFile.Name=""" & _
Replace(strEventLog , "\" , "\\") & """"
Print strQuery
Set objInstance = objService.Get(strQuery)
If Err.Number Then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred in getting eventlog file " & _
strEventLog & "."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
Exit Sub
End If
If objInstance is nothing Then
Exit Sub
Else
Select Case strCommand
Case CONST_BACKUP
intStatus = objInstance.BackupEventLog(strOutputFile)
Case CONST_CLEAR
intStatus = objInstance.ClearEventLog(strOutputFile)
Case Else
Print "Invalid command: " & strCommand & "."
End Select
If intStatus = 0 Then
WScript.Echo "Execution Succeeded"
Else
WScript.Echo "Execution Failed"
End If
End If
End Sub
'********************************************************************
'*
'* Sub Print()
'* Purpose: Prints a message on screen if blnQuiet = False.
'* Input: strMessage the string to print
'* Output: strMessage is printed on screen if blnQuiet = False.
'*
'********************************************************************
Sub Print(ByRef strMessage)
If Not blnQuiet then
Wscript.Echo strMessage
End If
End Sub
'********************************************************************
'* *
'* End of File *
'* *
'********************************************************************
'********************************************************************
'*
'* Procedures calling sequence: EVENTLOGFILE.VBS
'*
'* intParseCmdLine
'* ShowUsage
'* BackupLog
'* blnConnect
'* ExecuteMethod
'*
'********************************************************************
'********************************************************************
'*
'* Sub Debug()
'* Purpose: Prints a debug message and the error condition.
'* Input: i an integer
'* strMessage a message string
'* Output: A message is printed on screen.
'*
'********************************************************************
Sub Debug(i, strMessage)
If Err.Number then
Wscript.echo "Error 0X" & Hex(Err.Number) & " occurred."
Wscript.echo "Error description " & i & " " & Err.Description
Wscript.echo strMessage
' Err.Clear
Else
Wscript.echo "No problem " & i
Wscript.echo strMessage
End If
End Sub
'********************************************************************
'*
'* Sub PrintArray()
'* Purpose: Prints all elements of an array on screen.
'* Input: strArray an array name
'* Output: All elements of the array are printed on screen.
'*
'********************************************************************
Sub PrintArray(strArray)
Dim i
For i = 0 To UBound(strArray)
Wscript.echo strArray(i)
Next
End Sub
|
dim a
a = array( 1,2,3,4,5,6,7,8,9)
wscript.echo "before: ", join( a, ", " )
shuffle a
wscript.echo "after: ", join( a, ", " )
shuffle a
wscript.echo "after: ", join( a, ", " )
wscript.echo "--"
a = array( now(), "cow", 123, true, sin(1), 16.4 )
wscript.echo "before: ", join( a, ", " )
shuffle a
wscript.echo "after: ", join( a, ", " )
shuffle a
wscript.echo "after: ", join( a, ", " )
|
I bought a bag of apples from my brother.
I bought a bag of apples from T shop.
I bought a bag of apples with my money from T shop.
11111111111111111111
00011H1111000
|
Dim s As Variant
Private Function quick_select(ByRef s As Variant, k As Integer) As Integer
Dim left As Integer, right As Integer, pos As Integer
Dim pivotValue As Integer, tmp As Integer
left = 1: right = UBound(s)
Do While left < right
pivotValue = s(k)
tmp = s(k)
s(k) = s(right)
s(right) = tmp
pos = left
For i = left To right
If s(i) < pivotValue Then
tmp = s(i)
s(i) = s(pos)
s(pos) = tmp
pos = pos + 1
End If
Next i
tmp = s(right)
s(right) = s(pos)
s(pos) = tmp
If pos = k Then
Exit Do
End If
If pos < k Then
left = pos + 1
Else
right = pos - 1
End If
Loop
quick_select = s(k)
End Function
Public Sub main()
Dim r As Integer, i As Integer
s = [{9, 8, 7, 6, 5, 0, 1, 2, 3, 4}]
For i = 1 To 10
r = quick_select(s, i) 's is ByRef parameter
Debug.Print IIf(i < 10, r & ", ", "" & r);
Next i
End Sub
|
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmMain
Caption = "HSC Production Tool"
ClientHeight = 8670
ClientLeft = 165
ClientTop = 855
ClientWidth = 11895
Icon = "frmMain.frx":0000
LinkTopic = "Form1"
ScaleHeight = 8670
ScaleWidth = 11895
StartUpPosition = 3 'Windows Default
Begin VB.ComboBox cboNavModel
Height = 315
Left = 8280
Style = 2 'Dropdown List
TabIndex = 5
Top = 0
Width = 1575
End
Begin VB.CommandButton cmdEditEntry
Caption = "Edit"
Height = 255
Left = 11160
TabIndex = 23
Top = 2520
Width = 615
End
Begin VB.TextBox txtEntry
Height = 285
Left = 6960
TabIndex = 22
Tag = "1"
Top = 2520
Width = 4095
End
Begin VB.CommandButton cmdURI
Caption = "..."
Height = 255
Left = 11400
TabIndex = 16
Top = 1440
Width = 375
End
Begin VB.CheckBox chkSubSite
Caption = "Su&bSite"
Height = 255
Left = 6480
TabIndex = 3
Top = 0
Width = 855
End
Begin VB.TextBox txtIconURI
Height = 285
Left = 6960
TabIndex = 18
Tag = "1"
Top = 1800
Width = 4815
End
Begin VB.Timer tmrRefresh
Interval = 18000
Left = 4320
Top = 0
End
Begin VB.CheckBox chkVisible
Caption = "&Visible"
Height = 255
Left = 5640
TabIndex = 2
Top = 0
Width = 855
End
Begin VB.ComboBox cboLocInclude
Height = 315
Left = 10800
TabIndex = 7
Text = "cboLocInclude"
Top = 0
Width = 975
End
Begin VB.ComboBox cboNavigateLink
Height = 315
Left = 9360
Style = 2 'Dropdown List
TabIndex = 25
Top = 3000
Width = 1935
End
Begin VB.ComboBox cboKeywords
Height = 1935
ItemData = "frmMain.frx":212A
Left = 5640
List = "frmMain.frx":212C
Sorted = -1 'True
Style = 1 'Simple Combo
TabIndex = 39
Tag = "1"
Top = 5520
Width = 6135
End
Begin VB.CommandButton cmdNavigateLink
Caption = "Go"
Height = 375
Left = 11400
TabIndex = 26
Top = 3000
Width = 375
End
Begin VB.Timer tmrScrollDuringDrag
Left = 3960
Top = 0
End
Begin MSComctlLib.StatusBar staInfo
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 47
Tag = "1"
Top = 8295
Width = 11895
_ExtentX = 20981
_ExtentY = 661
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 3
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 8440
MinWidth = 1270
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 8440
MinWidth = 1270
EndProperty
BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Object.Width = 3528
MinWidth = 3528
EndProperty
EndProperty
End
Begin VB.CommandButton cmdRefresh
Caption = "Refresh"
Height = 375
Left = 4080
TabIndex = 43
Top = 7800
Width = 1215
End
Begin VB.CommandButton cmdAddRemove
Caption = "&Add/Remove Keywords ..."
Height = 375
Left = 8880
TabIndex = 37
Top = 5040
Width = 2895
End
Begin VB.CommandButton cmdCreateLeaf
Caption = "Create Topic"
Height = 375
Left = 1440
TabIndex = 41
Top = 7800
Width = 1215
End
Begin MSComctlLib.ImageList ilsIcons
Left = 3360
Top = 0
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 16776960
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 6
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmMain.frx":212E
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmMain.frx":2240
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmMain.frx":2352
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmMain.frx":2464
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmMain.frx":2576
Key = ""
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmMain.frx":2688
Key = ""
EndProperty
EndProperty
End
Begin VB.CommandButton cmdDelete
Caption = "Delete"
Height = 375
Left = 2760
TabIndex = 42
Top = 7800
Width = 1215
End
Begin VB.CommandButton cmdCreateGroup
Caption = "Create Node"
Height = 375
Left = 120
TabIndex = 40
Top = 7800
Width = 1215
End
Begin MSComDlg.CommonDialog dlgCommon
Left = 2880
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 375
Left = 10560
TabIndex = 46
Top = 7800
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "Save"
Height = 375
Left = 9240
TabIndex = 45
Top = 7800
Width = 1215
End
Begin VB.ComboBox cboType
Height = 315
Left = 6960
Style = 2 'Dropdown List
TabIndex = 13
Top = 1080
Width = 4815
End
Begin VB.TextBox txtURI
Height = 285
Left = 6960
TabIndex = 15
Tag = "1"
Top = 1440
Width = 4335
End
Begin VB.TextBox txtDescription
Height = 285
Left = 6960
TabIndex = 11
Tag = "1"
Top = 720
Width = 4815
End
Begin VB.TextBox txtTitle
Height = 285
Left = 6960
TabIndex = 9
Tag = "1"
Top = 360
Width = 4815
End
Begin MSComctlLib.TreeView treTaxonomy
Height = 7335
Left = 120
TabIndex = 1
Tag = "1"
Top = 360
Width = 5415
_ExtentX = 9551
_ExtentY = 12938
_Version = 393217
Indentation = 529
Style = 7
Appearance = 1
End
Begin VB.Frame fraSKU
Caption = "&SKU"
Height = 1575
Left = 5640
TabIndex = 27
Top = 3360
Width = 6135
Begin VB.CheckBox chkWindowsMillennium
Caption = "Windows Me"
Height = 255
Left = 240
TabIndex = 28
Top = 240
Width = 1695
End
Begin VB.CheckBox chkDataCenterServer64
Caption = "64-bit Datacenter Server"
Height = 255
Left = 3120
TabIndex = 36
Top = 1200
Width = 2055
End
Begin VB.CheckBox chkAdvancedServer64
Caption = "64-bit Advanced Server"
Height = 255
Left = 3120
TabIndex = 34
Top = 720
Width = 2055
End
Begin VB.CheckBox chkProfessional64
Caption = "64-bit Professional"
Height = 255
Left = 240
TabIndex = 31
Top = 960
Width = 1695
End
Begin VB.CheckBox chkDataCenterServer
Caption = "32-bit Datacenter Server"
Height = 255
Left = 3120
TabIndex = 35
Top = 960
Width = 2055
End
Begin VB.CheckBox chkAdvancedServer
Caption = "32-bit Advanced Server"
Height = 255
Left = 3120
TabIndex = 33
Top = 480
Width = 2055
End
Begin VB.CheckBox chkServer
Caption = "32-bit Server"
Height = 255
Left = 3120
TabIndex = 32
Top = 240
Width = 2055
End
Begin VB.CheckBox chkProfessional
Caption = "32-bit Professional"
Height = 255
Left = 240
TabIndex = 30
Top = 720
Width = 1695
End
Begin VB.CheckBox chkStandard
Caption = "32-bit Personal"
Height = 255
Left = 240
TabIndex = 29
Top = 480
Width = 1695
End
End
Begin VB.TextBox txtComments
Height = 285
Left = 6960
TabIndex = 20
Tag = "1"
Top = 2160
Width = 4815
End
Begin VB.Label lblNavModel
Caption = "Nav Model:"
Height = 255
Left = 7440
TabIndex = 4
Top = 0
Width = 855
End
Begin VB.Label lblEntry
Caption = "Entry:"
Height = 255
Left = 5640
TabIndex = 21
Top = 2520
Width = 1215
End
Begin VB.Label lblLastModified
BorderStyle = 1 'Fixed Single
Height = 375
Left = 5400
TabIndex = 44
Top = 7800
Width = 3735
End
Begin VB.Label lblIconURI
Caption = "Ico&n URI:"
Height = 255
Left = 5640
TabIndex = 17
Top = 1800
Width = 1215
End
Begin VB.Label lblLocInclude
Caption = "&Loc. Incl:"
Height = 255
Left = 9960
TabIndex = 6
Top = 0
Width = 735
End
Begin VB.Label lblNavigateLink
Caption = "Vie&w Topic:"
Height = 255
Left = 8400
TabIndex = 24
Top = 3000
Width = 855
End
Begin VB.Label lblComments
Caption = "&Comments:"
Height = 255
Left = 5640
TabIndex = 19
Top = 2160
Width = 1215
End
Begin VB.Label lblKeywords
Caption = "&Keywords associated with selected Node:"
Height = 255
Left = 5640
TabIndex = 38
Top = 5160
Width = 3135
End
Begin VB.Label lblURI
Caption = "&URI of the topic:"
Height = 255
Left = 5640
TabIndex = 14
Top = 1440
Width = 1215
End
Begin VB.Label lblType
Caption = "Ty&pe:"
Height = 255
Left = 5640
TabIndex = 12
Top = 1080
Width = 1215
End
Begin VB.Label lblDescription
Caption = "&Description:"
Height = 255
Left = 5640
TabIndex = 10
Top = 720
Width = 1215
End
Begin VB.Label lblTitle
Caption = "* T&itle:"
Height = 255
Left = 5640
TabIndex = 8
Top = 360
Width = 1215
End
Begin VB.Label lblTaxonomy
Caption = "&Taxonomy tree (including topics):"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 2775
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileOpenDatabase
Caption = "Open Database..."
End
Begin VB.Menu mnuFileExportHHT
Caption = "Archive authoring group changes..."
End
Begin VB.Menu mnuFileImportHHT
Caption = "Restore authoring group changes..."
End
Begin VB.Menu mnuSeparator0
Caption = "-"
End
Begin VB.Menu mnuFileExit
Caption = "Exit"
End
End
Begin VB.Menu mnuEdit
Caption = "&Edit"
Begin VB.Menu mnuEditStopSigns
Caption = "Stop Signs..."
End
Begin VB.Menu mnuEditStopWords
Caption = "Stop Words..."
End
Begin VB.Menu mnuEditKeywords
Caption = "Keywords..."
End
Begin VB.Menu mnuEditSynonymSets
Caption = "Synonym Sets..."
End
Begin VB.Menu mnuSeparator1
Caption = "-"
End
Begin VB.Menu mnuEditFind
Caption = "Find..."
Shortcut = ^F
End
Begin VB.Menu mnuEditCopy
Caption = "Copy"
Shortcut = ^Y
End
Begin VB.Menu mnuEditCut
Caption = "Cut"
Shortcut = ^T
End
Begin VB.Menu mnuEditPaste
Caption = "Paste"
Shortcut = ^P
End
Begin VB.Menu mnuSeparator2
Caption = "-"
End
Begin VB.Menu mnuEditCopyKeywords
Caption = "Copy Keywords"
Shortcut = ^K
End
Begin VB.Menu mnuEditPasteKeywords
Caption = "Paste Keywords"
Shortcut = ^L
End
End
Begin VB.Menu mnuTools
Caption = "T&ools"
Begin VB.Menu mnuToolsCreateHHTandCAB
Caption = "Create HHT and CAB..."
End
Begin VB.Menu mnuToolsFilterBySKU
Caption = "Filter by SKU..."
End
Begin VB.Menu mnuToolsImporter
Caption = "Importer..."
End
Begin VB.Menu mnuToolsParameters
Caption = "Parameters..."
End
Begin VB.Menu mnuToolsPropagateKeywords
Caption = "Propagate Keywords"
End
Begin VB.Menu mnuToolsSetFont
Caption = "Set Font..."
End
End
Begin VB.Menu mnuHelp
Caption = "&Help"
Begin VB.Menu mnuHelpContents
Caption = "Contents..."
End
Begin VB.Menu mnuSeparator3
Caption = "-"
End
Begin VB.Menu mnuHelpAbout
Caption = "About..."
End
End
Begin VB.Menu mnuRightClick
Caption = "RightClick"
Visible = 0 'False
Begin VB.Menu mnuRightClickCopy
Caption = "Copy"
End
Begin VB.Menu mnuRightClickCut
Caption = "Cut"
End
Begin VB.Menu mnuRightClickPaste
Caption = "Paste"
End
Begin VB.Menu mnuSeparator4
Caption = "-"
End
Begin VB.Menu mnuRightClickCopyKeywords
Caption = "Copy Keywords"
End
Begin VB.Menu mnuRightClickPasteKeywords
Caption = "Paste Keywords"
End
Begin VB.Menu mnuSeparator5
Caption = "-"
End
Begin VB.Menu mnuRightClickCreateNode
Caption = "Create Node"
End
Begin VB.Menu mnuRightClickCreateTopic
Caption = "Create Topic"
End
Begin VB.Menu mnuRightClickDelete
Caption = "Delete"
End
Begin VB.Menu mnuSeparator6
Caption = "-"
End
Begin VB.Menu mnuRightClickKeywordify
Caption = "Create Keywords from Titles"
End
Begin VB.Menu mnuRightClickExport
Caption = "Archive authoring group changes..."
End
End
Begin VB.Menu mnuMove
Caption = "Move"
Visible = 0 'False
Begin VB.Menu mnuMoveAbove
Caption = "Move Above"
End
Begin VB.Menu mnuMoveBelow
Caption = "Move Below"
End
Begin VB.Menu mnuMoveInside
Caption = "Move Inside"
End
End
Begin VB.Menu mnuTest
Caption = "Test"
Visible = 0 'False
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private WithEvents p_clsTaxonomy As AuthDatabase.Taxonomy
Attribute p_clsTaxonomy.VB_VarHelpID = -1
Private WithEvents p_clsHHT As AuthDatabase.HHT
Attribute p_clsHHT.VB_VarHelpID = -1
Private p_clsKeywords As AuthDatabase.Keywords
Private p_clsParameters As AuthDatabase.Parameters
Private p_clsSizer As Sizer
Private p_colKeywords As Collection
Private p_dictKeywordsWithTitle As Scripting.Dictionary
Private p_intAuthoringGroup As Long
Private p_blnDatabaseOpen As Boolean
Private p_nodeMouseDown As Node
Private p_blnCtrlMouseDown As Boolean
Private p_nodeCopied As Node
Private p_nodeCut As Node
Private p_blnScrollUp As Boolean
Private p_DOMNode As MSXML2.IXMLDOMNode
Private p_blnAddRemoveKeywordsOpen As Boolean
Private p_strKeywords As String
Private p_blnNoHHTStatus As Boolean
Private p_enumFilterSKUs As SKU_E
Private p_blnCreating As Boolean
Private p_blnUpdating As Boolean
Private p_blnDragging As Boolean
Private p_blnSettingControls As Boolean
Private Const KEY_PREFIX_C As String = "TID"
Private Const CREATE_KEY_C As String = "Node being created"
Private Const MODIFY_KEY_C As String = "Node being modified"
Private Const MDB_FILE_FILTER_C As String = "Microsoft Access Files (*.mdb)|*.mdb"
Private Const XML_FILE_FILTER_C As String = "XML Files (*.xml)|*.xml"
Private Const HELP_FILE_NAME_C As String = "Hsc.chm"
Private Const HELP_EXE_C As String = "hh.exe"
Private Enum STATUS_BAR_PANEL_E
SBPANEL_DATABASE = 1
SBPANEL_OTHER = 2
SBPANEL_MODE = 3
End Enum
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) As Long
Private Enum IMAGE_E
IMAGE_LEAF_E = 1
IMAGE_GROUP_E = 2
IMAGE_BAD_LEAF_E = 3
IMAGE_BAD_GROUP_E = 4
IMAGE_FOREIGN_LEAF_E = 5
IMAGE_FOREIGN_GROUP_E = 6
End Enum
' Usage of a Node's Key and Tag:
' If a Taxonomy Node's TID is 8, then Key is TID8. Tag is its DOM Node.
' For a node being modified, Key is MODIFY_KEY_C.
' For a node under construction, Key is CREATE_KEY_C. Tag is the parent's DOM Node.
' A gotcha: You need to use CStr in p_colKeywords(CStr(intKID)).
' Otherwise, you will simply get the intKID'th keyword, not one with intKID as key.
Private Sub Form_Load()
SetLogFile
Set g_AuthDatabase = New AuthDatabase.Main
Set g_ErrorInfo = New CErrorInfo
Set p_clsTaxonomy = g_AuthDatabase.Taxonomy
Set p_clsHHT = g_AuthDatabase.HHT
Set p_clsKeywords = g_AuthDatabase.Keywords
Set p_clsParameters = g_AuthDatabase.Parameters
Set p_clsSizer = New Sizer
Set p_colKeywords = New Collection
Set p_dictKeywordsWithTitle = New Scripting.Dictionary
Set p_nodeMouseDown = Nothing
Set p_nodeCopied = Nothing
Set p_nodeCut = Nothing
Set p_DOMNode = Nothing
p_blnCtrlMouseDown = False
p_blnAddRemoveKeywordsOpen = False
tmrScrollDuringDrag.Enabled = False
tmrScrollDuringDrag.Interval = 20
PopulateCboWithSKUs cboNavigateLink
p_InitializeLocIncludeCombo
p_InitializeNavModelCombo
p_enumFilterSKUs = ALL_SKUS_C
p_StrikeoutUnselectedSKUs
p_blnCreating = False
p_blnUpdating = False
p_blnDragging = False
p_blnSettingControls = False
' The user needs to open a database first
p_DisableEverything
p_InitializeTaxonomyTree
p_SetToolTips
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set g_AuthDatabase = Nothing
Set g_ErrorInfo = Nothing
Set g_Font = Nothing
Set p_clsTaxonomy = Nothing
Set p_clsHHT = Nothing
Set p_clsKeywords = Nothing
Set p_clsParameters = Nothing
Set p_clsSizer = Nothing
Set p_colKeywords = Nothing
Set p_dictKeywordsWithTitle = Nothing
Set p_nodeMouseDown = Nothing
Set p_nodeCopied = Nothing
Set p_nodeCut = Nothing
Set p_DOMNode = Nothing
AddRemoveKeywordsFormGoingAway
Unload frmAddRemoveKeywords
Unload frmFind
Unload frmImporter
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If (p_blnCreating Or p_blnUpdating) Then
MsgBox "You are in the middle of creating or updating an entry. " & _
"Please finish or cancel first.", vbOKOnly
Cancel = True
End If
End Sub
Private Sub Form_Activate()
On Error GoTo LErrorHandler
p_SetSizingInfo
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "Form_Activate"
End Sub
Private Sub Form_Resize()
On Error GoTo LErrorHandler
p_clsSizer.Resize
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "Form_Resize"
End Sub
Private Sub mnuFileOpenDatabase_Click()
Dim strDatabase As String
On Error GoTo LErrorHandler
dlgCommon.CancelError = True
dlgCommon.Flags = cdlOFNHideReadOnly
dlgCommon.Filter = MDB_FILE_FILTER_C
dlgCommon.ShowOpen
strDatabase = dlgCommon.FileName
g_AuthDatabase.SetDatabase strDatabase
p_SetTitle strDatabase
cmdRefresh_Click
' Clear the cached list of all keywords from the old database
AddRemoveKeywordsFormGoingAway
Unload frmAddRemoveKeywords
' frmImporter may have an HHK with KIDs from the old database
' associated with Taxonomy entries.
Unload frmImporter
p_blnDatabaseOpen = True
LEnd:
Exit Sub
LErrorHandler:
Select Case Err.Number
Case cdlCancel
' Nothing. The user cancelled.
Case errDatabaseVersionIncompatible
p_blnDatabaseOpen = False
DisplayDatabaseVersionError
Case errAuthoringGroupNotPresent
p_blnDatabaseOpen = False
DisplayAuthoringGroupError
Case Else
p_blnDatabaseOpen = False
g_ErrorInfo.SetInfoAndDump "mnuFileOpenDatabase_Click"
End Select
GoTo LEnd
End Sub
Private Sub mnuTest_Click()
Dim clsImporter As AuthDatabase.Importer
Set clsImporter = g_AuthDatabase.Importer
clsImporter.ImportHHK "\\srvua\Latest\HelpDirs\SRV\Help\HHK\suptools.hhk", _
"\\srvua\Latest\HelpDirs\SRV\Help", SKU_SERVER_E, HELPDIR_HELP_MSITS_E, "", 2
End Sub
Private Sub mnuToolsSetFont_Click()
On Error GoTo LErrorHandler
dlgCommon.CancelError = True
dlgCommon.Flags = cdlCFBoth Or cdlCFEffects
dlgCommon.ShowFont
Set g_Font = New StdFont
g_Font.Name = dlgCommon.FontName
g_Font.Size = dlgCommon.FontSize
g_Font.Bold = dlgCommon.FontBold
g_Font.Italic = dlgCommon.FontItalic
g_Font.Underline = dlgCommon.FontUnderline
g_Font.Strikethrough = dlgCommon.FontStrikethru
g_intFontColor = dlgCommon.Color
SetFontInternal Me
Exit Sub
LErrorHandler:
' User pressed Cancel button.
Exit Sub
End Sub
Private Sub mnuFileExportHHT_Click()
Dim DOMNode As MSXML2.IXMLDOMNode
Set DOMNode = treTaxonomy.Nodes(KEY_PREFIX_C & ROOT_TID_C).Tag
p_ExportHHT DOMNode
End Sub
Private Sub mnuFileImportHHT_Click()
On Error GoTo LErrorHandler
Dim strFileName As String
Dim Response As VbMsgBoxResult
Response = MsgBox("Are you sure that you want to do this? " & _
"This operation could create a lot of new Nodes and Topics " & _
"throughout the Taxonomy tree.", _
vbOKCancel + vbDefaultButton2 + vbExclamation)
If (Response <> vbOK) Then
Exit Sub
End If
dlgCommon.CancelError = True
dlgCommon.Flags = cdlOFNHideReadOnly
dlgCommon.Filter = XML_FILE_FILTER_C
dlgCommon.ShowOpen
strFileName = dlgCommon.FileName
Me.Enabled = False
p_clsHHT.ImportHHT strFileName
cmdRefresh_Click
LEnd:
Me.Enabled = True
Exit Sub
LErrorHandler:
Select Case Err.Number
Case cdlCancel
' Nothing. The user cancelled.
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Case errAuthoringGroupNotPresent
DisplayAuthoringGroupError
Case Else
g_ErrorInfo.SetInfoAndDump "mnuFileImportHHT_Click"
End Select
GoTo LEnd
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub
Private Sub mnuEditFind_Click()
On Error GoTo LErrorHandler
frmFind.Show vbModeless
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "mnuEditFind_Click"
End Sub
Private Sub mnuEditCopy_Click()
On Error GoTo LErrorHandler
Set p_nodeCopied = treTaxonomy.SelectedItem
Set p_nodeCut = Nothing
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "mnuEditCopy_Click"
End Sub
Private Sub mnuEditCut_Click()
On Error GoTo LErrorHandler
Set p_nodeCut = treTaxonomy.SelectedItem
Set p_nodeCopied = Nothing
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "mnuEditCut_Click"
End Sub
Private Sub mnuEditPaste_Click()
On Error GoTo LErrorHandler
If (Not p_nodeCopied Is Nothing) Then
p_CreateTaxonomyEntries p_nodeCopied.Tag, treTaxonomy.SelectedItem, True
ElseIf (Not p_nodeCut Is Nothing) Then
p_ChangeParent p_nodeCut, treTaxonomy.SelectedItem
Set p_nodeCut = Nothing
p_DisableEditPaste
End If
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "mnuEditPaste_Click"
End Sub
Private Sub mnuEditCopyKeywords_Click()
On Error GoTo LErrorHandler
p_strKeywords = XMLGetAttribute(treTaxonomy.SelectedItem.Tag, HHT_keywords_C)
p_EnableEditPasteKeywords
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "mnuEditCopyKeywords_Click"
End Sub
Private Sub mnuEditPasteKeywords_Click()
On Error Resume Next
Dim Node As Node
Dim blnDisableEditPasteKeywords As Boolean
Dim intTID As Long
If (p_blnCreating Or p_blnUpdating) Then
MsgBox "You are in the middle of creating or updating an entry. " & _
"Please finish or cancel first.", vbOKOnly
Exit Sub
End If
blnDisableEditPasteKeywords = True
For Each Node In treTaxonomy.Nodes
If Node.Checked Then
Err.Clear
p_SetKeywords Node.Tag
If (Err.Number <> 0) Then
blnDisableEditPasteKeywords = False
Err.Clear
Else
Node.Checked = False
End If
End If
Next
If (blnDisableEditPasteKeywords) Then
p_DisableEditPasteKeywords
p_strKeywords = ""
Else
MsgBox "Not all Nodes/Topics could be updated.", vbOKOnly
End If
intTID = XMLGetAttribute(treTaxonomy.SelectedItem.Tag, HHT_tid_C)
' The UI must show the new keywords that were associated.
Highlight intTID
End Sub
Private Sub mnuEditStopSigns_Click()
frmStopSigns.Show vbModal
End Sub
Private Sub mnuEditStopWords_Click()
frmStopWords.Show vbModal
End Sub
Private Sub mnuEditKeywords_Click()
frmKeywords.Show vbModal
End Sub
Private Sub mnuEditSynonymSets_Click()
frmSynonymSets.Show vbModal
End Sub
Private Sub mnuToolsCreateHHTandCAB_Click()
p_blnNoHHTStatus = True
frmHHT.Show vbModal
p_blnNoHHTStatus = False
End Sub
Private Sub mnuToolsFilterBySKU_Click()
frmFilterSKU.SetSKUs p_enumFilterSKUs
frmFilterSKU.Show vbModal
End Sub
Private Sub mnuToolsImporter_Click()
frmImporter.Show vbModeless
End Sub
Private Sub mnuToolsParameters_Click()
frmParameters.Show vbModal
End Sub
Private Sub mnuToolsPropagateKeywords_Click()
On Error GoTo LErrorHandler
Dim T0 As Date
Dim T1 As Date
Dim strStatusText As String
strStatusText = p_GetStatusText(SBPANEL_DATABASE)
Me.MousePointer = vbHourglass
Me.Enabled = False
T0 = Now
p_SetStatusText SBPANEL_DATABASE, "Propagating keywords..."
p_clsTaxonomy.PropagateKeywords
p_SetStatusText SBPANEL_DATABASE, strStatusText
T1 = Now
Debug.Print "mnuToolsPropagateKeywords_Click: " & FormatTime(T0, T1)
cmdRefresh_Click
LEnd:
Me.Enabled = True
Me.MousePointer = vbDefault
Exit Sub
LErrorHandler:
p_SetStatusText SBPANEL_DATABASE, strStatusText
Select Case Err.Number
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Case Else:
g_ErrorInfo.SetInfoAndDump "mnuToolsPropagateKeywords_Click"
End Select
GoTo LEnd
End Sub
Private Sub mnuRightClickCopy_Click()
mnuEditCopy_Click
End Sub
Private Sub mnuRightClickCut_Click()
mnuEditCut_Click
End Sub
Private Sub mnuRightClickPaste_Click()
mnuEditPaste_Click
End Sub
Private Sub mnuRightClickCopyKeywords_Click()
mnuEditCopyKeywords_Click
End Sub
Private Sub mnuRightClickPasteKeywords_Click()
mnuEditPasteKeywords_Click
End Sub
Private Sub mnuRightClickCreateNode_Click()
cmdCreateGroup_Click
End Sub
Private Sub mnuRightClickCreateTopic_Click()
cmdCreateLeaf_Click
End Sub
Private Sub mnuRightClickDelete_Click()
cmdDelete_Click
End Sub
Private Sub mnuRightClickKeywordify_Click()
On Error GoTo LErrorHandler
Dim DOMNode As MSXML2.IXMLDOMNode
Dim intTID As Long
Dim T0 As Date
Dim T1 As Date
Dim strStatusText As String
Dim Response As VbMsgBoxResult
strStatusText = p_GetStatusText(SBPANEL_DATABASE)
Response = MsgBox("Are you sure that you want to create Keywords from Titles of the " & _
"Node/Topic and its descendents?", _
vbOKCancel + vbDefaultButton2)
If (Response <> vbOK) Then
Exit Sub
End If
Me.MousePointer = vbHourglass
Me.Enabled = False
Set DOMNode = treTaxonomy.SelectedItem.Tag
intTID = XMLGetAttribute(DOMNode, HHT_tid_C)
T0 = Now
p_clsTaxonomy.KeywordifyTitles intTID
T1 = Now
Debug.Print "mnuRightClickKeywordify_Click: " & FormatTime(T0, T1)
p_SetStatusText SBPANEL_DATABASE, strStatusText
mnuToolsPropagateKeywords_Click
LEnd:
Me.Enabled = True
Me.MousePointer = vbDefault
Exit Sub
LErrorHandler:
p_SetStatusText SBPANEL_DATABASE, strStatusText
Select Case Err.Number
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Case Else:
g_ErrorInfo.SetInfoAndDump "mnuRightClickKeywordify_Click"
End Select
GoTo LEnd
End Sub
Private Sub mnuRightClickExport_Click()
p_ExportHHT p_nodeMouseDown.Tag
End Sub
Private Sub mnuHelpContents_Click()
Dim strCmd As String
strCmd = HELP_EXE_C & " " & App.Path & "\" & HELP_FILE_NAME_C
Shell strCmd, vbNormalFocus
End Sub
Private Sub mnuHelpAbout_Click()
frmAbout.Show vbModal
End Sub
Private Sub chkVisible_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkSubSite_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub cboLocInclude_Change()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub p_clsTaxonomy_ReportStatus(ByVal strStatus As String, blnCancel As Boolean)
p_SetStatusText SBPANEL_DATABASE, strStatus
DoEvents
End Sub
Private Sub p_clsHHT_ReportStatus(ByVal strStatus As String, blnCancel As Boolean)
If (Not p_blnNoHHTStatus) Then
p_SetStatusText SBPANEL_DATABASE, strStatus
End If
DoEvents
End Sub
Private Sub txtTitle_Change()
On Error GoTo LErrorHandler
Dim Node As Node
If (p_blnSettingControls) Then
Exit Sub
End If
p_UserChangedSomethingForCurrentNode
If (p_blnCreating) Then
Set Node = treTaxonomy.Nodes(CREATE_KEY_C)
Node.Text = txtTitle
ElseIf (p_blnUpdating) Then
Set Node = treTaxonomy.Nodes(MODIFY_KEY_C)
Node.Text = txtTitle
End If
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "txtTitle_Change"
End Sub
Private Sub txtDescription_Change()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub cboNavModel_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub cboNavModel_Change()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub cboType_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub cboType_Change()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub txtURI_Change()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub txtIconURI_Change()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub txtComments_Change()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub txtEntry_Change()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkStandard_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkProfessional_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkProfessional64_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkWindowsMillennium_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkServer_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkAdvancedServer_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkDataCenterServer_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkAdvancedServer64_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub chkDataCenterServer64_Click()
If (Not p_blnSettingControls) Then
p_UserChangedSomethingForCurrentNode
End If
End Sub
Private Sub treTaxonomy_Collapse(ByVal Node As MSComctlLib.Node)
If (Node = treTaxonomy.SelectedItem) Then
treTaxonomy_NodeClick Node
End If
End Sub
Private Sub treTaxonomy_NodeClick(ByVal Node As MSComctlLib.Node)
On Error GoTo LErrorHandler
Dim blnUpdateControls As Boolean
Dim DOMNode As MSXML2.IXMLDOMNode
Dim intAG As Long
If (p_blnCreating Or p_blnUpdating) Then
' The user wants to go to a different Group/Leaf.
' Assume that he wants to save his changes.
p_SaveClicked blnUpdateControls
If (Not blnUpdateControls) Then
Exit Sub
End If
End If
If (p_NodeDeleted(Node)) Then
' If we start creating a node X, and then Create it by right clicking
' on it, then we will come here. The info on the RHS is up to date.
' So it is OK to simply exit.
Exit Sub
End If
Set DOMNode = Node.Tag
p_UpdateRHSControls DOMNode
Set treTaxonomy.SelectedItem = Node
If (p_IsLeaf(Node)) Then
p_DisableCreate
p_DisableEditPaste
p_DisableSubSite
p_DisableEditEntry
p_DisableNavModel
Else
p_EnableCreate
p_EnableSubSite
p_EnableNavModel
p_EnableEditEntry
If (Not p_nodeCut Is Nothing) Then
p_EnableEditPaste
ElseIf (Not p_nodeCopied Is Nothing) Then
p_EnableEditPaste
End If
End If
intAG = XMLGetAttribute(DOMNode, HHT_authoringgroup_C)
If (intAG = p_intAuthoringGroup) Then
p_EnableNodeDetailsExceptIndividualSKUs
Else
p_DisableNodeDetails
p_DisableDelete
p_DisableEditCut
End If
If (p_IsRoot(Node)) Then
p_DisableDelete
p_DisableEditCopy
p_DisableEditCut
p_DisableAddRemoveAndKeywordsCombo
Else
p_EnableEditCopy
If (intAG = p_intAuthoringGroup) Then
p_EnableDelete
p_EnableEditCut
p_EnableAddRemoveAndKeywordsCombo
End If
End If
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "treTaxonomy_NodeClick"
End Sub
Private Sub mnuMoveAbove_Click()
p_Move p_nodeMouseDown, treTaxonomy.DropHighlight, True
End Sub
Private Sub mnuMoveBelow_Click()
p_Move p_nodeMouseDown, treTaxonomy.DropHighlight, False
End Sub
Private Sub mnuMoveInside_Click()
p_ChangeParent p_nodeMouseDown, treTaxonomy.DropHighlight
End Sub
Private Sub p_PopupMoveMenu(i_Node As Node)
mnuMoveInside.Visible = True
mnuMoveAbove.Visible = True
mnuMoveBelow.Visible = True
If (p_IsLeaf(i_Node)) Then
mnuMoveInside.Visible = False
ElseIf (p_IsRoot(i_Node)) Then
mnuMoveAbove.Visible = False
mnuMoveBelow.Visible = False
End If
PopupMenu mnuMove
End Sub
Private Sub treTaxonomy_DragDrop(Source As Control, x As Single, y As Single)
On Error GoTo LErrorHandler
Dim nodeCurrent As Node
Dim Response As VbMsgBoxResult
Dim enumSKUs As SKU_E
Dim intParentTID As Long
Set nodeCurrent = treTaxonomy.DropHighlight
If (Not (nodeCurrent Is Nothing)) Then
If (Not p_nodeMouseDown Is Nothing) Then
If (p_nodeMouseDown.Key <> nodeCurrent.Key) Then
If (p_blnCtrlMouseDown) Then
If (Not p_IsLeaf(nodeCurrent)) Then
Response = MsgBox("Are you sure that you want to create " & _
"a copy of this Node or Topic?", _
vbOKCancel + vbDefaultButton1)
If (Response = vbOK) Then
p_CreateTaxonomyEntries p_nodeMouseDown.Tag, nodeCurrent, _
True
End If
End If
Else
p_PopupMoveMenu nodeCurrent
End If
End If
ElseIf (Not (p_DOMNode Is Nothing)) Then
If (p_blnCreating Or p_blnUpdating) Then
MsgBox "You are in the middle of creating or updating an entry. " & _
"Please finish or cancel first.", vbOKOnly
ElseIf (p_IsLeaf(nodeCurrent)) Then
MsgBox "Please drop over a Node, not a Topic.", vbOKOnly
Else
enumSKUs = frmImporter.GetSelectedSKUs
intParentTID = XMLGetAttribute(nodeCurrent.Tag, HHT_tid_C)
p_ReplaceTaxonomySubtree p_DOMNode, intParentTID, enumSKUs, True
Set p_DOMNode = Nothing
End If
End If
End If
Set treTaxonomy.DropHighlight = Nothing
Set p_nodeMouseDown = Nothing
Set p_DOMNode = Nothing
p_blnCtrlMouseDown = False
p_blnDragging = False
tmrScrollDuringDrag.Enabled = False
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "treTaxonomy_DragDrop"
End Sub
Private Sub treTaxonomy_DragOver(Source As Control, x As Single, y As Single, State As Integer)
On Error GoTo LErrorHandler
Dim nodeCurrent As Node
If (p_blnDragging) Then
If (y > 0 And y < 800) Then
'scroll up
p_blnScrollUp = True
tmrScrollDuringDrag.Enabled = True
ElseIf (y > (treTaxonomy.Height - 800) And y < treTaxonomy.Height) Then
'scroll down
p_blnScrollUp = False
tmrScrollDuringDrag.Enabled = True
Else
tmrScrollDuringDrag.Enabled = False
End If
Set nodeCurrent = treTaxonomy.HitTest(x, y)
If (nodeCurrent Is Nothing) Then
Exit Sub
End If
If (p_blnCtrlMouseDown And p_IsLeaf(nodeCurrent)) Then
Exit Sub
End If
Set treTaxonomy.DropHighlight = nodeCurrent
'nodeCurrent.Expanded = True Users hated this.
End If
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "treTaxonomy_DragOver"
End Sub
Private Sub treTaxonomy_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If (Not p_blnCreating And Not p_blnUpdating) Then
If (treTaxonomy.Checkboxes) Then
Exit Sub
End If
Set p_nodeMouseDown = treTaxonomy.HitTest(x, y)
If (p_nodeMouseDown Is Nothing) Then
Exit Sub
End If
treTaxonomy_NodeClick p_nodeMouseDown
If (p_IsRoot(p_nodeMouseDown)) Then
Set p_nodeMouseDown = Nothing
End If
If (Not (p_nodeMouseDown Is Nothing)) Then
If (Shift = vbCtrlMask) Then
p_blnCtrlMouseDown = True
Else
p_blnCtrlMouseDown = False
End If
End If
End If
End Sub
Private Sub treTaxonomy_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo LErrorHandler
If ((Not p_blnCreating And Not p_blnUpdating) And _
(Button = vbLeftButton) And _
(Not (p_nodeMouseDown Is Nothing))) Then
p_blnDragging = True
treTaxonomy.DragIcon = p_nodeMouseDown.CreateDragImage
treTaxonomy.Drag vbBeginDrag
End If
Exit Sub
LErrorHandler:
' If a node is selected, and then the user clicks on mnuFileOpenDatabase,
' and double clicks a database, this event fires. We get the exception "This item's
' control has been deleted".
End Sub
Public Sub BeginDrag( _
ByVal i_DOMNode As MSXML2.IXMLDOMNode, _
ByVal i_blnHHK As Boolean _
)
' Something is being dragged over from the frmImporter form.
Set p_nodeMouseDown = Nothing
p_blnCtrlMouseDown = False
Set p_DOMNode = i_DOMNode
If (Not i_DOMNode Is Nothing) Then
p_blnDragging = True
Else
p_blnDragging = False
End If
End Sub
Private Sub treTaxonomy_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
tmrScrollDuringDrag.Enabled = False
If (Not p_blnCreating And Not p_blnUpdating) Then
Set p_nodeMouseDown = treTaxonomy.HitTest(x, y)
If (p_nodeMouseDown Is Nothing) Then
Exit Sub
End If
If (Button = vbRightButton) Then
Set treTaxonomy.SelectedItem = p_nodeMouseDown
PopupMenu mnuRightClick
End If
End If
End Sub
Private Sub Form_DragOver(Source As Control, x As Single, y As Single, State As Integer)
If Source.Name = "treTaxonomy" Then
tmrScrollDuringDrag.Enabled = False
End If
End Sub
Private Sub tmrScrollDuringDrag_Timer()
If (p_blnScrollUp) Then
' Send a WM_VSCROLL message 0 is up and 1 is down
SendMessage treTaxonomy.hwnd, 277&, 0&, vbNull
Else
'Scroll Down
SendMessage treTaxonomy.hwnd, 277&, 1&, vbNull
End If
End Sub
Private Sub tmrRefresh_Timer()
' Auto refresh every 30 min because we cache the database.
Static intTicks As Long
intTicks = intTicks + 1
If (intTicks <> 100) Then
Exit Sub
End If
intTicks = 0
If (p_blnUpdating Or p_blnCreating) Then
Exit Sub
End If
If (Not p_blnDatabaseOpen) Then
Exit Sub
End If
' cmdRefresh_Click
End Sub
Private Sub cmdCreateGroup_Click()
On Error GoTo LErrorHandler
p_CreateNode True
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "cmdCreateGroup_Click"
End Sub
Private Sub cmdCreateLeaf_Click()
On Error GoTo LErrorHandler
p_CreateNode False
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "cmdCreateLeaf_Click"
End Sub
Private Sub cmdDelete_Click()
On Error GoTo LErrorHandler
Dim nodeCurrent As Node
Dim strTitle As String
Dim str1 As String
Dim str2 As String
Dim Response As VbMsgBoxResult
Dim dtmModifiedTime As Date
Dim intTID As Long
Dim DOMNodeParent As MSXML2.IXMLDOMNode
Dim strStatusText As String
strStatusText = p_GetStatusText(SBPANEL_DATABASE)
If (p_blnCreating Or p_blnUpdating) Then
GoTo LEnd
End If
Set nodeCurrent = treTaxonomy.SelectedItem
strTitle = txtTitle
If (p_IsLeaf(nodeCurrent)) Then
str1 = "topic """
str2 = """"
Else
str1 = "node """
str2 = """ and all its children"
End If
Response = MsgBox("Are you sure that you want to permanently delete " & _
str1 & strTitle & str2 & "?", vbOKCancel + vbDefaultButton2)
If (Response <> vbOK) Then
GoTo LEnd
End If
Me.Enabled = False
dtmModifiedTime = XMLGetAttribute(nodeCurrent.Tag, HHT_modifiedtime_C)
intTID = XMLGetAttribute(nodeCurrent.Tag, HHT_tid_C)
p_clsTaxonomy.Delete intTID, dtmModifiedTime
Set DOMNodeParent = nodeCurrent.Tag.parentNode
DOMNodeParent.removeChild nodeCurrent.Tag
treTaxonomy.Nodes.Remove treTaxonomy.SelectedItem.Key
treTaxonomy_NodeClick treTaxonomy.SelectedItem
LEnd:
Me.Enabled = True
p_SetStatusText SBPANEL_DATABASE, strStatusText
Exit Sub
LErrorHandler:
Select Case Err.Number
Case errNodeOrTopicAlreadyModified
MsgBox "Someone else already modified this entry. " & _
"You need to Refresh the database and then try again. " & _
"This prevents you from accidentally overwriting something " & _
"the other person entered.", _
vbExclamation + vbOKOnly
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Case errNotPermittedForAuthoringGroup, errAuthoringGroupDiffers, errAuthoringGroupNotPresent
DisplayAuthoringGroupError
Case Else:
g_ErrorInfo.SetInfoAndDump "cmdDelete_Click"
End Select
GoTo LEnd
End Sub
Private Sub cmdRefresh_Click()
On Error GoTo LErrorHandler
Dim DOMNode As MSXML2.IXMLDOMNode
Dim intTID As Long
p_intAuthoringGroup = p_clsParameters.AuthoringGroup
If (treTaxonomy.SelectedItem Is Nothing) Then
intTID = ROOT_TID_C
Else
intTID = XMLGetAttribute(treTaxonomy.SelectedItem.Tag, HHT_tid_C)
End If
Me.MousePointer = vbHourglass
p_InitializeDataStructures DOMNode
p_Refresh DOMNode
p_SetStatusText SBPANEL_DATABASE, "Database last read at: " & Now
If (p_NodeExists(intTID)) Then
treTaxonomy_NodeClick treTaxonomy.Nodes(KEY_PREFIX_C & intTID)
Else
treTaxonomy_NodeClick treTaxonomy.Nodes(KEY_PREFIX_C & ROOT_TID_C)
End If
LEnd:
Me.MousePointer = vbDefault
Exit Sub
LErrorHandler:
Me.Enabled = True
Select Case Err.Number
Case errAuthoringGroupNotPresent
DisplayAuthoringGroupError
Case Else
g_ErrorInfo.SetInfoAndDump "cmdRefresh_Click"
End Select
GoTo LEnd
End Sub
Private Sub cmdURI_Click()
frmURI.SetOldURI txtURI
frmURI.Show vbModal
End Sub
Private Sub cmdEditEntry_Click()
Dim Response As VbMsgBoxResult
If (Not p_blnCreating) Then
Response = MsgBox("Are you sure that you want to change this ENTRY? " & _
"Changing the ENTRY does not change the TITLE, " & _
"but it does change the identifier that others may be using " & _
"to reference this topic. If you really want to change this ENTRY, " & _
"please notify everybody who is linking to this topic so they can " & _
"update their hyperlink.", _
vbOKCancel + vbDefaultButton2 + vbExclamation)
If (Response <> vbOK) Then
p_DisableEntry
Exit Sub
End If
End If
p_EnableEntry
End Sub
Private Sub cmdNavigateLink_Click()
On Error GoTo LErrorHandler
Dim strBrokenLinkDir As String
Dim strVendor As String
Dim strURI As String
Dim Browser As HTMLDocument
strBrokenLinkDir = p_GetBrokenLinkDir(cboNavigateLink.ItemData(cboNavigateLink.ListIndex))
strVendor = p_clsParameters.Value(VENDOR_STRING_C) & ""
LinkValid strBrokenLinkDir, strVendor, txtURI, strURI
Set Browser = New HTMLDocument
Browser.url = strURI
Exit Sub
LErrorHandler:
Select Case Err.Number
Case errNotConfiguredForNavigateLink
MsgBox "Please verify that you've selected the correct SKU. " & _
"If the SKU is correct, the database needs to be configured " & _
"to point to the BrokenLinkWorkingDir.", _
vbExclamation Or vbOKOnly
Case Else
g_ErrorInfo.SetInfoAndDump "cmdNavigateLink_Click"
End Select
End Sub
Public Function GetNavigateLinkURI(i_intListIndex As Long) As String
On Error GoTo LErrorHandler
Dim strBrokenLinkDir As String
Dim strVendor As String
If (txtURI = "") Then
Exit Function
End If
strBrokenLinkDir = p_GetBrokenLinkDir(cboNavigateLink.ItemData(i_intListIndex))
strVendor = p_clsParameters.Value(VENDOR_STRING_C) & ""
LinkValid strBrokenLinkDir, strVendor, txtURI, GetNavigateLinkURI
Exit Function
LErrorHandler:
Select Case Err.Number
Case errNotConfiguredForNavigateLink
MsgBox "Please verify that you've selected the correct SKU. " & _
"If the SKU is correct, the database needs to be configured " & _
"to point to the BrokenLinkWorkingDir.", _
vbExclamation Or vbOKOnly
Case Else
g_ErrorInfo.SetInfoAndDump "GetNavigateLinkURI"
End Select
End Function
Private Sub cmdAddRemove_Click()
On Error GoTo LErrorHandler
Dim Node As Node
Set Node = treTaxonomy.SelectedItem
If (Node Is Nothing) Then
Exit Sub
End If
frmAddRemoveKeywords.SetKeywords p_dictKeywordsWithTitle
frmAddRemoveKeywords.SetTitle txtTitle, p_IsLeaf(Node)
If (txtURI <> "") Then
frmAddRemoveKeywords.LinkNavigable True
Else
frmAddRemoveKeywords.LinkNavigable False
End If
If (Not p_blnAddRemoveKeywordsOpen) Then
frmAddRemoveKeywords.Show vbModeless
p_blnAddRemoveKeywordsOpen = True
End If
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "cmdAddRemove_Click"
End Sub
Private Sub cboKeywords_KeyPress(KeyAscii As Integer)
On Error GoTo LErrorHandler
Dim strKeyword As String
Dim intIndex As Long
Dim intKID As Long
Dim Response As VbMsgBoxResult
If (KeyAscii <> Asc(vbCr)) Then
Exit Sub
End If
strKeyword = RemoveExtraSpaces(cboKeywords.Text)
cboKeywords.Text = ""
For intIndex = 0 To cboKeywords.ListCount
If (LCase$(strKeyword) = LCase$(cboKeywords.List(intIndex))) Then
Exit Sub
End If
Next
intKID = p_clsKeywords.GetKIDOfKeyword(strKeyword)
If (intKID = INVALID_ID_C) Then
Response = MsgBox( _
"The keyword """ & strKeyword & """ doesn't exist. Do you want to create it?", _
vbOKCancel + vbDefaultButton1)
If (Response = vbCancel) Then
Exit Sub
End If
End If
intKID = p_clsKeywords.Create(strKeyword)
p_dictKeywordsWithTitle.Add intKID, strKeyword
If (Not CollectionContainsKey(p_colKeywords, intKID)) Then
p_colKeywords.Add strKeyword, CStr(intKID)
End If
p_SetKeywordsList
p_UserChangedSomethingForCurrentNode
Exit Sub
LErrorHandler:
Select Case Err.Number
Case errContainsGarbageChar
MsgBox "The Keyword " & strKeyword & " contains garbage characters.", _
vbExclamation + vbOKOnly
Case errContainsStopSign
MsgBox "The Keyword " & strKeyword & " contains a Stop Sign.", _
vbExclamation + vbOKOnly
Case errContainsStopWord
MsgBox "The Keyword " & strKeyword & " contains a Stop Word.", _
vbExclamation + vbOKOnly
Case errContainsOperatorShortcut
MsgBox "The Keyword " & strKeyword & " contains an operator shortcut.", _
vbExclamation + vbOKOnly
Case errContainsVerbalOperator
MsgBox "The Keyword " & strKeyword & " contains a verbal operator.", _
vbExclamation + vbOKOnly
Case errContainsQuote
MsgBox "The Keyword " & strKeyword & " contains a quote.", _
vbExclamation + vbOKOnly
Case errTooLong
MsgBox "The Keyword " & strKeyword & " is too long", _
vbExclamation + vbOKOnly
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Case Else
g_ErrorInfo.SetInfoAndDump "cboKeywords_KeyPress"
End Select
End Sub
Private Sub cmdSave_Click()
On Error GoTo LErrorHandler
Dim blnUpdateControls As Boolean
p_SaveClicked blnUpdateControls
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "cmdSave_Click"
End Sub
Private Sub cmdCancel_Click()
On Error GoTo LErrorHandler
Dim Node As Node
If (p_blnCreating) Then
p_DeleteNodeBeingCreated
p_SetModeCreating False
ElseIf (p_blnUpdating) Then
p_SetModeUpdating False
End If
treTaxonomy_NodeClick treTaxonomy.SelectedItem
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "cmdCancel_Click"
End Sub
Private Sub p_SetBrokenLinkAttribute( _
ByVal i_enumSKU As SKU_E, _
ByRef i_strBrokenLinkDir As String, _
ByRef i_strVendor As String, _
ByRef i_strBrokenLinkAttribute As String, _
ByRef u_DOMNode As MSXML2.IXMLDOMNode _
)
Dim enumSKUs As SKU_E
Dim strURI As String
Dim strNewURI As String
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strTitle As String
enumSKUs = XMLGetAttribute(u_DOMNode, HHT_skus_C) And _
XMLGetAttribute(u_DOMNode, HHT_allowedskus_C)
strTitle = XMLGetAttribute(u_DOMNode, HHT_TITLE_C)
strURI = XMLGetAttribute(u_DOMNode, HHT_URI_C)
p_SetStatusText SBPANEL_DATABASE, "Evaluating " & strTitle
If ((i_enumSKU And enumSKUs) = 0) Then
XMLSetAttribute u_DOMNode, i_strBrokenLinkAttribute, "0"
Exit Sub
End If
If (LinkValid(i_strBrokenLinkDir, i_strVendor, strURI, strNewURI)) Then
XMLSetAttribute u_DOMNode, i_strBrokenLinkAttribute, "0"
Else
XMLSetAttribute u_DOMNode, i_strBrokenLinkAttribute, "1"
End If
If (Not (u_DOMNode.firstChild Is Nothing)) Then
For Each DOMNode In u_DOMNode.childNodes
p_SetBrokenLinkAttribute i_enumSKU, i_strBrokenLinkDir, i_strVendor, _
i_strBrokenLinkAttribute, DOMNode
Next
End If
End Sub
Private Sub p_ComputeBrokenLinkAttributes( _
ByVal i_enumSearchTarget As SEARCH_TARGET_E _
)
On Error GoTo LErrorHandler
Dim DOMNodeRoot As MSXML2.IXMLDOMNode
Dim strStatusText As String
Dim enumSKU As SKU_E
Dim strBrokenLinkDir As String
Dim strVendor As String
Dim strBrokenLinkAttribute As String
strStatusText = p_GetStatusText(SBPANEL_DATABASE)
Set DOMNodeRoot = treTaxonomy.Nodes(KEY_PREFIX_C & ROOT_TID_C).Tag
strVendor = p_clsParameters.Value(VENDOR_STRING_C) & ""
If (i_enumSearchTarget And ST_BROKEN_LINK_WINME_E) Then
enumSKU = SKU_WINDOWS_MILLENNIUM_E
strBrokenLinkAttribute = HHT_brokenlinkwinme_C
strBrokenLinkDir = p_GetBrokenLinkDir(enumSKU)
p_SetBrokenLinkAttribute enumSKU, strBrokenLinkDir, strVendor, strBrokenLinkAttribute, _
DOMNodeRoot
ElseIf (i_enumSearchTarget And ST_BROKEN_LINK_STD_E) Then
enumSKU = SKU_STANDARD_E
strBrokenLinkAttribute = HHT_brokenlinkstd_C
strBrokenLinkDir = p_GetBrokenLinkDir(enumSKU)
p_SetBrokenLinkAttribute enumSKU, strBrokenLinkDir, strVendor, strBrokenLinkAttribute, _
DOMNodeRoot
ElseIf (i_enumSearchTarget And ST_BROKEN_LINK_PRO_E) Then
enumSKU = SKU_PROFESSIONAL_E
strBrokenLinkAttribute = HHT_brokenlinkpro_C
strBrokenLinkDir = p_GetBrokenLinkDir(enumSKU)
p_SetBrokenLinkAttribute enumSKU, strBrokenLinkDir, strVendor, strBrokenLinkAttribute, _
DOMNodeRoot
ElseIf (i_enumSearchTarget And ST_BROKEN_LINK_PRO64_E) Then
enumSKU = SKU_PROFESSIONAL_64_E
strBrokenLinkAttribute = HHT_brokenlinkpro64_C
strBrokenLinkDir = p_GetBrokenLinkDir(enumSKU)
p_SetBrokenLinkAttribute enumSKU, strBrokenLinkDir, strVendor, strBrokenLinkAttribute, _
DOMNodeRoot
ElseIf (i_enumSearchTarget And ST_BROKEN_LINK_SRV_E) Then
enumSKU = SKU_SERVER_E
strBrokenLinkAttribute = HHT_brokenlinksrv_C
strBrokenLinkDir = p_GetBrokenLinkDir(enumSKU)
p_SetBrokenLinkAttribute enumSKU, strBrokenLinkDir, strVendor, strBrokenLinkAttribute, _
DOMNodeRoot
ElseIf (i_enumSearchTarget And ST_BROKEN_LINK_ADV_E) Then
enumSKU = SKU_ADVANCED_SERVER_E
strBrokenLinkAttribute = HHT_brokenlinkadv_C
strBrokenLinkDir = p_GetBrokenLinkDir(enumSKU)
p_SetBrokenLinkAttribute enumSKU, strBrokenLinkDir, strVendor, strBrokenLinkAttribute, _
DOMNodeRoot
ElseIf (i_enumSearchTarget And ST_BROKEN_LINK_ADV64_E) Then
enumSKU = SKU_ADVANCED_SERVER_64_E
strBrokenLinkAttribute = HHT_brokenlinkadv64_C
strBrokenLinkDir = p_GetBrokenLinkDir(enumSKU)
p_SetBrokenLinkAttribute enumSKU, strBrokenLinkDir, strVendor, strBrokenLinkAttribute, _
DOMNodeRoot
ElseIf (i_enumSearchTarget And ST_BROKEN_LINK_DAT_E) Then
enumSKU = SKU_DATA_CENTER_SERVER_E
strBrokenLinkAttribute = HHT_brokenlinkdat_C
strBrokenLinkDir = p_GetBrokenLinkDir(enumSKU)
p_SetBrokenLinkAttribute enumSKU, strBrokenLinkDir, strVendor, strBrokenLinkAttribute, _
DOMNodeRoot
ElseIf (i_enumSearchTarget And ST_BROKEN_LINK_DAT64_E) Then
enumSKU = SKU_DATA_CENTER_SERVER_64_E
strBrokenLinkAttribute = HHT_brokenlinkdat64_C
strBrokenLinkDir = p_GetBrokenLinkDir(enumSKU)
p_SetBrokenLinkAttribute enumSKU, strBrokenLinkDir, strVendor, strBrokenLinkAttribute, _
DOMNodeRoot
End If
LDone:
p_SetStatusText SBPANEL_DATABASE, strStatusText
Exit Sub
LErrorHandler:
Select Case Err.Number
Case errNotConfiguredForNavigateLink
MsgBox "Please verify that you've selected the correct SKU. " & _
"If the SKU is correct, the database needs to be configured " & _
"to point to the BrokenLinkWorkingDir.", _
vbExclamation Or vbOKOnly
End Select
GoTo LDone
End Sub
Private Function p_GetBrokenLinkXPathQuery( _
ByVal i_enumSearchTarget As SEARCH_TARGET_E _
) As String
Dim str As String
Dim strQuery As String
strQuery = "attribute::" & HHT_tid_C & "!=""" & INVALID_ID_C & """"
If (i_enumSearchTarget And ST_BROKEN_LINK_WINME_E) Then
str = "attribute::" & HHT_brokenlinkwinme_C & "=""1"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_BROKEN_LINK_STD_E) Then
str = "attribute::" & HHT_brokenlinkstd_C & "=""1"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_BROKEN_LINK_PRO_E) Then
str = "attribute::" & HHT_brokenlinkpro_C & "=""1"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_BROKEN_LINK_PRO64_E) Then
str = "attribute::" & HHT_brokenlinkpro64_C & "=""1"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_BROKEN_LINK_SRV_E) Then
str = "attribute::" & HHT_brokenlinksrv_C & "=""1"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_BROKEN_LINK_ADV_E) Then
str = "attribute::" & HHT_brokenlinkadv_C & "=""1"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_BROKEN_LINK_ADV64_E) Then
str = "attribute::" & HHT_brokenlinkadv64_C & "=""1"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_BROKEN_LINK_DAT_E) Then
str = "attribute::" & HHT_brokenlinkdat_C & "=""1"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_BROKEN_LINK_DAT64_E) Then
str = "attribute::" & HHT_brokenlinkdat64_C & "=""1"""
strQuery = strQuery & " and " & str
End If
p_GetBrokenLinkXPathQuery = strQuery
End Function
Private Function p_GetXPathAttributeString( _
ByVal i_strAttributeName As String, _
ByVal i_strStringToFind As String _
) As String
p_GetXPathAttributeString = "attribute::" & i_strAttributeName & _
"[contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')," & _
"""" & i_strStringToFind & """ )]"
End Function
Private Function p_GetXPathQuery( _
ByVal i_strStringToFind As String, _
ByVal i_enumSearchTarget As SEARCH_TARGET_E _
) As String
Dim strQuery As String
Dim str As String
strQuery = "descendant::TAXONOMY_ENTRY["
str = "attribute::" & HHT_tid_C & "!=""" & INVALID_ID_C & """"
strQuery = strQuery & str
If (i_enumSearchTarget And _
(ST_TITLE_E Or _
ST_DESCRIPTION_E Or _
ST_URI_E Or _
ST_COMMENTS_E Or _
ST_BASE_FILE_E)) Then
strQuery = strQuery & " and ("
strQuery = strQuery & p_GetXPathAttributeString(HHT_basefile_C, "!!!An impossible string!!!")
If (i_enumSearchTarget And ST_TITLE_E) Then
str = p_GetXPathAttributeString(HHT_TITLE_C, i_strStringToFind)
strQuery = strQuery & " or " & str
End If
If (i_enumSearchTarget And ST_DESCRIPTION_E) Then
str = p_GetXPathAttributeString(HHT_DESCRIPTION_C, i_strStringToFind)
strQuery = strQuery & " or " & str
End If
If (i_enumSearchTarget And ST_URI_E) Then
str = p_GetXPathAttributeString(HHT_URI_C, i_strStringToFind)
strQuery = strQuery & " or " & str
End If
If (i_enumSearchTarget And ST_COMMENTS_E) Then
str = p_GetXPathAttributeString(HHT_comments_C, i_strStringToFind)
strQuery = strQuery & " or " & str
End If
If (i_enumSearchTarget And ST_BASE_FILE_E) Then
str = p_GetXPathAttributeString(HHT_basefile_C, i_strStringToFind)
strQuery = strQuery & " or " & str
End If
strQuery = strQuery & ")"
End If
If (i_enumSearchTarget And ST_SELF_AUTHORING_GROUP_E) Then
str = "attribute::" & HHT_authoringgroup_C & "=""" & p_intAuthoringGroup & """"
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_NODES_WITHOUT_KEYWORDS_E) Then
str = "attribute::" & HHT_keywords_C & "="""" and "
str = str & "attribute::" & HHT_leaf_C & "=""False"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And ST_TOPICS_WITHOUT_KEYWORDS_E) Then
str = "attribute::" & HHT_keywords_C & "="""" and "
str = str & "attribute::" & HHT_leaf_C & "=""True"""
strQuery = strQuery & " and " & str
End If
If (i_enumSearchTarget And _
(ST_BROKEN_LINK_WINME_E Or _
ST_BROKEN_LINK_STD_E Or _
ST_BROKEN_LINK_PRO_E Or _
ST_BROKEN_LINK_PRO64_E Or _
ST_BROKEN_LINK_SRV_E Or _
ST_BROKEN_LINK_ADV_E Or _
ST_BROKEN_LINK_ADV64_E Or _
ST_BROKEN_LINK_DAT_E Or _
ST_BROKEN_LINK_DAT64_E)) Then
p_ComputeBrokenLinkAttributes i_enumSearchTarget
str = p_GetBrokenLinkXPathQuery(i_enumSearchTarget)
strQuery = strQuery & " and " & str
End If
strQuery = strQuery & "]"
p_GetXPathQuery = strQuery
End Function
Public Function Find( _
ByVal i_strStringToFind As String, _
ByVal i_enumSearchTarget As SEARCH_TARGET_E _
) As MSXML2.IXMLDOMNodeList
Dim str As String
Dim DOMNodeRoot As MSXML2.IXMLDOMNode
Dim DOMDocument As MSXML2.DOMDocument
Dim strQuery As String
str = LCase$(i_strStringToFind)
strQuery = p_GetXPathQuery(str, i_enumSearchTarget)
Set DOMNodeRoot = treTaxonomy.Nodes(KEY_PREFIX_C & ROOT_TID_C).Tag
Set DOMDocument = DOMNodeRoot.ownerDocument
DOMDocument.setProperty "SelectionLanguage", "XPath"
Set Find = DOMNodeRoot.selectNodes(strQuery)
End Function
Public Sub Highlight( _
ByVal i_intTID As Long _
)
Dim Node As Node
If (Not p_NodeExists(i_intTID)) Then
MsgBox "The Node or Topic no longer exists", vbOKOnly
Exit Sub
End If
Set Node = treTaxonomy.Nodes(KEY_PREFIX_C & i_intTID)
Node.EnsureVisible
treTaxonomy_NodeClick Node
Set treTaxonomy.SelectedItem = Node
End Sub
Public Sub SetURI(ByVal i_strURI As String)
txtURI = i_strURI
End Sub
Public Sub SetKeywords(ByVal i_dictKeywordsWithTitle As Scripting.Dictionary)
On Error GoTo LErrorHandler
Dim intKID As Variant
p_dictKeywordsWithTitle.RemoveAll
For Each intKID In i_dictKeywordsWithTitle.Keys
p_dictKeywordsWithTitle.Add intKID, i_dictKeywordsWithTitle(intKID)
If (Not CollectionContainsKey(p_colKeywords, intKID)) Then
p_colKeywords.Add i_dictKeywordsWithTitle(intKID), CStr(intKID)
End If
Next
p_SetKeywordsList
p_UserChangedSomethingForCurrentNode
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndRaiseError "SetKeywords"
End Sub
Public Sub AddRemoveKeywordsFormGoingAway()
p_blnAddRemoveKeywordsOpen = False
End Sub
Public Sub SetSKUs(i_enumSKUs As SKU_E)
On Error GoTo LErrorHandler
Dim T0 As Date
Dim T1 As Date
If (p_enumFilterSKUs <> i_enumSKUs) Then
p_enumFilterSKUs = i_enumSKUs
p_StrikeoutUnselectedSKUs
T0 = Now
p_UpdateSubTree ROOT_TID_C, ALL_SKUS_C
T1 = Now
Debug.Print "SetSKUs: " & FormatTime(T0, T1)
End If
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndRaiseError "SetSKUs"
End Sub
Private Function p_IsLeaf(i_Node As Node) As Boolean
If ((i_Node.Image = IMAGE_LEAF_E) Or (i_Node.Image = IMAGE_BAD_LEAF_E) Or _
(i_Node.Image = IMAGE_FOREIGN_LEAF_E)) Then
p_IsLeaf = True
Else
p_IsLeaf = False
End If
End Function
Private Function p_IsRoot(i_Node As Node) As Boolean
If (i_Node.Parent Is Nothing) Then
p_IsRoot = True
Else
p_IsRoot = False
End If
End Function
Private Function p_NodeDeleted(i_Node As Node) As Boolean
Dim Node As Node
On Error GoTo LErrorHandler
Set Node = i_Node.Parent
p_NodeDeleted = False
Exit Function
LErrorHandler:
p_NodeDeleted = True
End Function
Private Function p_NodeExists(i_intTID As Long) As Boolean
Dim Node As Node
If (p_blnUpdating) Then
Set Node = treTaxonomy.Nodes(MODIFY_KEY_C)
If (XMLGetAttribute(Node.Tag, HHT_tid_C) = i_intTID) Then
p_NodeExists = True
Exit Function
End If
End If
On Error GoTo LErrorHandler
Set Node = treTaxonomy.Nodes(KEY_PREFIX_C & i_intTID)
p_NodeExists = True
Exit Function
LErrorHandler:
p_NodeExists = False
End Function
Private Sub p_UserChangedSomethingForCurrentNode()
On Error GoTo LErrorHandler
If (p_blnCreating Or p_blnUpdating) Then
Exit Sub
End If
p_SetModeUpdating True
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "p_UserChangedSomethingForCurrentNode"
End Sub
Private Sub p_SetLastModified( _
ByRef i_DOMNode As MSXML2.IXMLDOMNode _
)
Dim strLastModified As String
strLastModified = "Modified by " & XMLGetAttribute(i_DOMNode, HHT_username_C) & _
" on " & XMLGetAttribute(i_DOMNode, HHT_modifiedtime_C)
lblLastModified.Caption = strLastModified
End Sub
Private Sub p_UpdateRHSControls( _
ByRef i_DOMNode As MSXML2.IXMLDOMNode _
)
On Error GoTo LErrorHandler
Dim enumSKUs As SKU_E
Dim intAllowedSKUs As Long
Dim enumAllowedSKUs As SKU_E
Dim intIndex As Long
Dim arrKIDs() As String
Dim intKID As Long
Dim strKeyword As String
Dim intType As Long
Dim blnSettingControls As Boolean
blnSettingControls = p_blnSettingControls
p_blnSettingControls = True
txtTitle = XMLGetAttribute(i_DOMNode, HHT_TITLE_C)
txtDescription = XMLGetAttribute(i_DOMNode, HHT_DESCRIPTION_C)
txtURI = XMLGetAttribute(i_DOMNode, HHT_URI_C)
txtIconURI = XMLGetAttribute(i_DOMNode, HHT_ICONURI_C)
txtComments = XMLGetAttribute(i_DOMNode, HHT_comments_C)
txtEntry = XMLGetAttribute(i_DOMNode, HHT_ENTRY_C)
p_DisableEntry
p_SetLastModified i_DOMNode
chkVisible.Value = IIf(XMLGetAttribute(i_DOMNode, HHT_VISIBLE_C), 1, 0)
If (XMLGetAttribute(i_DOMNode, HHT_leaf_C)) Then
p_DisableSubSite
p_DisableNavModel
p_DisableEditEntry
Else
p_EnableSubSite
p_EnableNavModel
p_EnableEditEntry
End If
chkSubSite.Value = IIf(XMLGetAttribute(i_DOMNode, HHT_SUBSITE_C), 1, 0)
p_SetTypeComboIndex -1
intType = XMLGetAttribute(i_DOMNode, HHT_TYPE_C)
For intIndex = 0 To cboType.ListCount - 1
If (cboType.ItemData(intIndex) = intType) Then
p_SetTypeComboIndex intIndex
Exit For
End If
Next
p_SetNavModelCombo XMLGetAttribute(i_DOMNode, HHT_NAVIGATIONMODEL_C)
p_SetLocIncludeCombo XMLGetAttribute(i_DOMNode, HHT_locinclude_C)
p_SetSKUs XMLGetAttribute(i_DOMNode, HHT_skus_C), _
XMLGetAttribute(i_DOMNode, HHT_allowedskus_C)
If (txtURI <> "") Then
p_EnableNavigateLink
Else
p_DisableNavigateLink
End If
arrKIDs = Split(XMLGetAttribute(i_DOMNode, HHT_keywords_C), " ")
p_dictKeywordsWithTitle.RemoveAll
' This loop is time consuming and sometimes causes a couple of seconds delay.
' This mostly happens when there are a lot of KIDs of deleted keywords.
For intIndex = LBound(arrKIDs) To UBound(arrKIDs)
If (arrKIDs(intIndex) <> "") Then
intKID = arrKIDs(intIndex)
If (CollectionContainsKey(p_colKeywords, intKID)) Then
p_dictKeywordsWithTitle.Add intKID, p_colKeywords(CStr(intKID))
Else
' It is possible that Keyword propagation (for same URI) has gotten
' us new KIDs for which we don't have any Keyword.
p_clsKeywords.GetKeyword intKID, strKeyword
If (strKeyword <> "") Then
p_colKeywords.Add strKeyword, CStr(intKID)
p_dictKeywordsWithTitle.Add intKID, strKeyword
End If
End If
End If
Next
p_SetKeywordsList
' Reset it to the state it was in when this function was called.
p_blnSettingControls = blnSettingControls
If (p_blnAddRemoveKeywordsOpen) Then
cmdAddRemove_Click
End If
Exit Sub
LErrorHandler:
p_blnSettingControls = blnSettingControls
g_ErrorInfo.SetInfoAndRaiseError "p_UpdateRHSControls"
End Sub
Private Sub p_SetSKUs(i_enumSelectedSKUs As SKU_E, i_enumAllowedSKUs As SKU_E)
p_ClearSKUs
p_DisableSKUs
If (i_enumAllowedSKUs And SKU_STANDARD_E) Then
chkStandard.Enabled = True
If (i_enumSelectedSKUs And SKU_STANDARD_E) Then
chkStandard.Value = 1
End If
End If
If (i_enumAllowedSKUs And SKU_PROFESSIONAL_E) Then
chkProfessional.Enabled = True
If (i_enumSelectedSKUs And SKU_PROFESSIONAL_E) Then
chkProfessional.Value = 1
End If
End If
If (i_enumAllowedSKUs And SKU_PROFESSIONAL_64_E) Then
chkProfessional64.Enabled = True
If (i_enumSelectedSKUs And SKU_PROFESSIONAL_64_E) Then
chkProfessional64.Value = 1
End If
End If
If (i_enumAllowedSKUs And SKU_WINDOWS_MILLENNIUM_E) Then
chkWindowsMillennium.Enabled = True
If (i_enumSelectedSKUs And SKU_WINDOWS_MILLENNIUM_E) Then
chkWindowsMillennium.Value = 1
End If
End If
If (i_enumAllowedSKUs And SKU_SERVER_E) Then
chkServer.Enabled = True
If (i_enumSelectedSKUs And SKU_SERVER_E) Then
chkServer.Value = 1
End If
End If
If (i_enumAllowedSKUs And SKU_ADVANCED_SERVER_E) Then
chkAdvancedServer.Enabled = True
If (i_enumSelectedSKUs And SKU_ADVANCED_SERVER_E) Then
chkAdvancedServer.Value = 1
End If
End If
If (i_enumAllowedSKUs And SKU_DATA_CENTER_SERVER_E) Then
chkDataCenterServer.Enabled = True
If (i_enumSelectedSKUs And SKU_DATA_CENTER_SERVER_E) Then
chkDataCenterServer.Value = 1
End If
End If
If (i_enumAllowedSKUs And SKU_ADVANCED_SERVER_64_E) Then
chkAdvancedServer64.Enabled = True
If (i_enumSelectedSKUs And SKU_ADVANCED_SERVER_64_E) Then
chkAdvancedServer64.Value = 1
End If
End If
If (i_enumAllowedSKUs And SKU_DATA_CENTER_SERVER_64_E) Then
chkDataCenterServer64.Enabled = True
If (i_enumSelectedSKUs And SKU_DATA_CENTER_SERVER_64_E) Then
chkDataCenterServer64.Value = 1
End If
End If
End Sub
Private Function p_GetSelectedSKUs() As SKU_E
Dim enumSelectedSKUs As SKU_E
If (chkStandard.Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_STANDARD_E
End If
If (chkProfessional.Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_PROFESSIONAL_E
End If
If (chkProfessional64.Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_PROFESSIONAL_64_E
End If
If (chkWindowsMillennium.Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_WINDOWS_MILLENNIUM_E
End If
If (chkServer.Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_SERVER_E
End If
If (chkAdvancedServer.Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_ADVANCED_SERVER_E
End If
If (chkDataCenterServer.Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_DATA_CENTER_SERVER_E
End If
If (chkAdvancedServer64.Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_ADVANCED_SERVER_64_E
End If
If (chkDataCenterServer64.Value = 1) Then
enumSelectedSKUs = enumSelectedSKUs Or SKU_DATA_CENTER_SERVER_64_E
End If
p_GetSelectedSKUs = enumSelectedSKUs
End Function
Private Function p_GetSelectedNavModel() As Long
If (cboNavModel.ListIndex = -1) Then
p_GetSelectedNavModel = NAVMODEL_DEFAULT_NUM_C
Else
p_GetSelectedNavModel = cboNavModel.ItemData(cboNavModel.ListIndex)
End If
End Function
Private Function p_GetSelectedType() As Long
If (cboType.ListIndex = -1) Then
p_GetSelectedType = 0
Else
p_GetSelectedType = cboType.ItemData(cboType.ListIndex)
End If
End Function
Private Function p_GetSelectedLocInclude() As String
p_GetSelectedLocInclude = cboLocInclude.Text
End Function
Private Sub p_SetNodeColor( _
ByRef i_Node As Node, _
ByRef i_DOMNode As MSXML2.IXMLDOMNode _
)
Dim enumSKUs As SKU_E
Dim blnVisible As Boolean
Dim blnSubSite As Boolean
enumSKUs = XMLGetAttribute(i_DOMNode, HHT_skus_C) And _
XMLGetAttribute(i_DOMNode, HHT_allowedskus_C)
blnVisible = XMLGetAttribute(i_DOMNode, HHT_VISIBLE_C)
blnSubSite = XMLGetAttribute(i_DOMNode, HHT_SUBSITE_C)
If ((p_enumFilterSKUs And enumSKUs) = 0) Then
i_Node.ForeColor = vbWhite
i_Node.BackColor = vbWhite
Else
If (blnVisible) Then
i_Node.ForeColor = vbBlack
Else
i_Node.ForeColor = &HB0B0B0
End If
End If
If (blnSubSite) Then
i_Node.Bold = True
Else
i_Node.Bold = False
End If
End Sub
Private Sub p_SetNodeImage( _
ByRef i_Node As Node, _
ByRef i_DOMNode As MSXML2.IXMLDOMNode _
)
Dim blnLeaf As Boolean
Dim intAG As Long
blnLeaf = XMLGetAttribute(i_DOMNode, HHT_leaf_C)
intAG = XMLGetAttribute(i_DOMNode, HHT_authoringgroup_C)
If (intAG <> p_intAuthoringGroup) Then
If (blnLeaf) Then
i_Node.Image = IMAGE_FOREIGN_LEAF_E
Else
i_Node.Image = IMAGE_FOREIGN_GROUP_E
End If
Exit Sub
End If
If (blnLeaf) Then
i_Node.Image = IMAGE_LEAF_E
Else
i_Node.Image = IMAGE_GROUP_E
End If
End Sub
Private Sub p_DeleteNodeBeingCreated()
On Error GoTo LErrorHandler
treTaxonomy.Nodes.Remove CREATE_KEY_C
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndRaiseError "p_DeleteNodeBeingCreated"
End Sub
Private Sub p_SetModeCreating(i_bln As Boolean)
On Error GoTo LErrorHandler
If (i_bln And Not p_blnCreating) Then
p_blnCreating = True
p_DisableCreate
p_DisableDelete
p_DisableRefresh
p_EnableSaveCancel
p_SetStatusText SBPANEL_MODE, "Creating Node/Topic"
ElseIf (Not i_bln And p_blnCreating) Then
p_blnCreating = False
p_EnableRefresh
p_DisableSaveCancel
p_SetStatusText SBPANEL_MODE, ""
End If
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndRaiseError "p_SetModeCreating"
End Sub
Private Sub p_SetModeUpdating(i_bln As Boolean)
On Error GoTo LErrorHandler
Dim Node As Node
If (i_bln And Not p_blnUpdating) Then
p_blnUpdating = True
treTaxonomy.SelectedItem.Key = MODIFY_KEY_C
p_DisableCreate
p_DisableDelete
p_DisableRefresh
p_EnableSaveCancel
p_SetStatusText SBPANEL_MODE, "Modifying Node/Topic"
ElseIf (Not i_bln And p_blnUpdating) Then
p_blnUpdating = False
p_EnableRefresh
Set Node = treTaxonomy.Nodes(MODIFY_KEY_C)
Node.Key = KEY_PREFIX_C & XMLGetAttribute(Node.Tag, HHT_tid_C)
Node.Text = XMLGetAttribute(Node.Tag, HHT_TITLE_C)
p_DisableSaveCancel
p_SetStatusText SBPANEL_MODE, ""
End If
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndRaiseError "p_SetModeUpdating"
End Sub
Private Sub p_ExportHHT( _
ByRef i_DOMNode As MSXML2.IXMLDOMNode _
)
On Error GoTo LErrorHandler
Dim strFileName As String
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strStatusText As String
strStatusText = p_GetStatusText(SBPANEL_DATABASE)
dlgCommon.CancelError = True
dlgCommon.Flags = cdlOFNHideReadOnly
dlgCommon.Filter = XML_FILE_FILTER_C
dlgCommon.ShowSave
strFileName = Trim$(dlgCommon.FileName)
If (strFileName = "") Then
Exit Sub
End If
Me.Enabled = False
p_clsHHT.ExportHHT strFileName
LEnd:
Me.Enabled = True
p_SetStatusText SBPANEL_DATABASE, strStatusText
Exit Sub
LErrorHandler:
Select Case Err.Number
Case cdlCancel
' Nothing. The user cancelled.
Case Else
g_ErrorInfo.SetInfoAndDump "p_ExportHHT"
End Select
GoTo LEnd
End Sub
Private Sub p_CreateNode(i_blnGroupNode As Boolean)
On Error GoTo LErrorHandler
Dim DOMNode As MSXML2.IXMLDOMNode
Dim nodeNew As Node
Dim strParentKey As String
Dim intParentTID As Long
Dim enumSelectedSKUs As SKU_E
If (p_blnCreating Or p_blnUpdating) Then
Exit Sub
End If
p_SetModeCreating True
Set DOMNode = treTaxonomy.SelectedItem.Tag
intParentTID = XMLGetAttribute(DOMNode, HHT_tid_C)
strParentKey = KEY_PREFIX_C & intParentTID
Set nodeNew = treTaxonomy.Nodes.Add(strParentKey, tvwChild, CREATE_KEY_C)
Set nodeNew.Tag = DOMNode
If (i_blnGroupNode) Then
nodeNew.Image = IMAGE_GROUP_E
p_EnableSubSite
p_EnableNavModel
p_EnableEditEntry
Else
nodeNew.Image = IMAGE_LEAF_E
p_DisableSubSite
p_DisableNavModel
p_DisableEditEntry
End If
Set treTaxonomy.SelectedItem = nodeNew
nodeNew.EnsureVisible
p_DisableUnselectedSKUs
p_EnableNodeDetailsExceptIndividualSKUs
p_EnableNavigateLink
p_EnableAddRemoveAndKeywordsCombo
chkSubSite.Value = 0
p_SetNavModelCombo NAVMODEL_DEFAULT_STR_C
enumSelectedSKUs = p_GetSelectedSKUs
p_SetSKUs enumSelectedSKUs, enumSelectedSKUs
txtTitle = ""
txtDescription = ""
txtURI = ""
txtIconURI = ""
txtComments = ""
txtEntry = ""
lblLastModified = ""
txtTitle.SetFocus
p_dictKeywordsWithTitle.RemoveAll
p_SetKeywordsList
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndRaiseError "p_CreateNode"
End Sub
Private Sub p_ReplaceTaxonomySubtree( _
ByVal u_DOMNode As MSXML2.IXMLDOMNode, _
ByVal i_intParentTID As Long, _
ByVal i_enumSKUs As SKU_E, _
ByVal i_blnFastImport As Boolean _
)
Dim DOMNode As MSXML2.IXMLDOMNode
Dim T0 As Date
Dim T1 As Date
T0 = Now
If (u_DOMNode.nodeName = HHT_TAXONOMY_ENTRIES_C) Then
If (Not (u_DOMNode.firstChild Is Nothing)) Then
For Each DOMNode In u_DOMNode.childNodes
p_ReplaceTaxonomySubtree2 DOMNode, i_intParentTID, i_enumSKUs, i_blnFastImport
Next
End If
ElseIf (u_DOMNode.nodeName = HHT_TAXONOMY_ENTRY_C) Then
p_ReplaceTaxonomySubtree2 u_DOMNode, i_intParentTID, i_enumSKUs, i_blnFastImport
End If
T1 = Now
Debug.Print "p_ReplaceTaxonomySubtree: " & FormatTime(T0, T1)
End Sub
Private Sub p_SetTypeSKUsLeafLocIncludeVisibleSubSite( _
ByVal u_DOMNode As MSXML2.IXMLDOMNode, _
ByVal i_enumSKUs As SKU_E, _
ByRef i_strLocInclude As String _
)
Dim DOMNode As MSXML2.IXMLDOMNode
Dim blnHasChildren As Boolean
If (XMLGetAttribute(u_DOMNode, HHT_TYPE_C) = "") Then
XMLSetAttribute u_DOMNode, HHT_TYPE_C, 0
End If
XMLSetAttribute u_DOMNode, HHT_skus_C, i_enumSKUs
If (Not u_DOMNode.firstChild Is Nothing) Then
blnHasChildren = True
End If
If (XMLGetAttribute(u_DOMNode, HHT_leaf_C) = "") Then
XMLSetAttribute u_DOMNode, HHT_leaf_C, IIf(blnHasChildren, False, True)
End If
XMLSetAttribute u_DOMNode, HHT_locinclude_C, i_strLocInclude
If (XMLGetAttribute(u_DOMNode, HHT_VISIBLE_C) = "") Then
XMLSetAttribute u_DOMNode, HHT_VISIBLE_C, CStr(True)
End If
If (XMLGetAttribute(u_DOMNode, HHT_SUBSITE_C) = "") Then
XMLSetAttribute u_DOMNode, HHT_SUBSITE_C, CStr(False)
End If
If (blnHasChildren) Then
For Each DOMNode In u_DOMNode.childNodes
p_SetTypeSKUsLeafLocIncludeVisibleSubSite DOMNode, i_enumSKUs, i_strLocInclude
Next
End If
End Sub
Private Sub p_ReplaceTaxonomySubtree2( _
ByVal u_DOMNode As MSXML2.IXMLDOMNode, _
ByVal i_intParentTID As Long, _
ByVal i_enumSKUs As SKU_E, _
ByVal i_blnFastImport As Boolean _
)
On Error GoTo LErrorHandler
Dim strStatusText As String
Dim NodeParent As Node
Dim strLocInclude As String
Me.MousePointer = vbHourglass
Me.Enabled = False
strStatusText = p_GetStatusText(SBPANEL_DATABASE)
' For some reason, if nodeParent is passed in to p_ReplaceTaxonomySubtree2
' from treTaxonomy_DragDrop, we get the error "The items's control has been
' deleted" after about 20 min of processing. So we pass in the TID instead.
Set NodeParent = treTaxonomy.Nodes(KEY_PREFIX_C & i_intParentTID)
p_SetStatusText SBPANEL_DATABASE, "Creating new Nodes/Topics..."
strLocInclude = XMLGetAttribute(NodeParent.Tag, HHT_locinclude_C)
p_SetTypeSKUsLeafLocIncludeVisibleSubSite u_DOMNode, i_enumSKUs, strLocInclude
p_CreateTaxonomyEntries u_DOMNode, NodeParent, i_blnFastImport
LEnd:
Me.Enabled = True
Me.MousePointer = vbDefault
p_SetStatusText SBPANEL_DATABASE, strStatusText
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndDump "p_ReplaceTaxonomySubtree2"
GoTo LEnd
End Sub
Private Sub p_SaveClicked( _
ByRef o_blnUpdateControls As Boolean _
)
Dim str As String
Dim intError As Long
Dim bln As Boolean
Dim intTID As Long
If (p_blnUpdating) Then
intTID = XMLGetAttribute(treTaxonomy.Nodes(MODIFY_KEY_C).Tag, HHT_tid_C)
If (intTID = ROOT_TID_C) Then
p_SetModeUpdating False
o_blnUpdateControls = True
Exit Sub
End If
End If
o_blnUpdateControls = False
str = RemoveExtraSpaces(txtTitle)
If (str = "") Then
MsgBox "Title cannot be blank", vbExclamation Or vbOKOnly
txtTitle.SetFocus
Exit Sub
End If
If (p_blnCreating) Then
bln = p_CreateTaxonomy
ElseIf (p_blnUpdating) Then
bln = p_UpdateTaxonomy
End If
o_blnUpdateControls = bln
End Sub
Private Function p_GetAllowedSKUs( _
ByRef i_DOMNodeParent As MSXML2.IXMLDOMNode _
) As SKU_E
p_GetAllowedSKUs = XMLGetAttribute(i_DOMNodeParent, HHT_allowedskus_C) And _
XMLGetAttribute(i_DOMNodeParent, HHT_skus_C)
End Function
Private Function p_CreateTaxonomy() As Boolean
On Error GoTo LErrorHandler
Dim intSelectedSKUs As Long
Dim intParentTID As Long
Dim Node As Node
Dim blnLeaf As Boolean
Dim blnVisible As Boolean
Dim blnSubSite As Boolean
Dim strTitle As String
Dim strDescription As String
Dim strURI As String
Dim strIconURI As String
Dim intTID As Long
Dim intType As Long
Dim intNavModel As Long
Dim strLocInclude As String
Dim strKeywords As String
Dim DOMNodeParent As MSXML2.IXMLDOMNode
Dim DOMNode As MSXML2.IXMLDOMNode
Dim ModifiedDOMNodes As MSXML2.IXMLDOMNode
Dim NodeParent As Node
Dim enumAllowedSKUs As SKU_E
p_CreateTaxonomy = False
Set Node = treTaxonomy.Nodes(CREATE_KEY_C)
Set DOMNodeParent = Node.Tag
intParentTID = XMLGetAttribute(DOMNodeParent, HHT_tid_C)
intSelectedSKUs = p_GetSelectedSKUs
If (p_IsLeaf(Node)) Then
blnLeaf = True
Else
blnLeaf = False
End If
strTitle = RemoveExtraSpaces(txtTitle)
strDescription = RemoveExtraSpaces(txtDescription)
strURI = RemoveExtraSpaces(txtURI)
strIconURI = RemoveExtraSpaces(txtIconURI)
blnVisible = IIf((chkVisible.Value = 0), False, True)
blnSubSite = IIf((chkSubSite.Value = 0), False, True)
intType = p_GetSelectedType
strLocInclude = p_GetSelectedLocInclude
intNavModel = p_GetSelectedNavModel
strKeywords = p_GetKeywords
p_clsTaxonomy.Create strTitle, strDescription, intType, intNavModel, strURI, strIconURI, _
intSelectedSKUs, blnLeaf, intParentTID, strLocInclude, blnVisible, blnSubSite, _
strKeywords, "", txtComments, txtEntry, DOMNodeParent.ownerDocument, DOMNode, _
ModifiedDOMNodes
p_SetModeCreating False
intTID = XMLGetAttribute(DOMNode, HHT_tid_C)
DOMNodeParent.appendChild DOMNode
treTaxonomy.Nodes.Remove CREATE_KEY_C
enumAllowedSKUs = p_GetAllowedSKUs(DOMNodeParent)
Set NodeParent = treTaxonomy.Nodes(KEY_PREFIX_C & intParentTID)
p_CreateTree DOMNode, NodeParent, enumAllowedSKUs
p_CreateTaxonomy = True
p_UpdateTIDs ModifiedDOMNodes
' The UI must show the new keywords that were associated by p_clsTaxonomy.Create
Highlight intTID
LEnd:
Exit Function
LErrorHandler:
Select Case Err.Number
Case errContainsGarbageChar
MsgBox "The Title " & strTitle & _
" or the Description " & strDescription & _
" contains garbage characters", _
vbExclamation + vbOKOnly
Case errTooLong
MsgBox "The Title " & strTitle & " is too long", _
vbExclamation + vbOKOnly
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Err.Raise Err.Number
Case errAuthoringGroupNotPresent
DisplayAuthoringGroupError
Case Else
g_ErrorInfo.SetInfoAndRaiseError "p_CreateTaxonomy"
End Select
GoTo LEnd
End Function
Private Sub p_SetKeywords( _
ByRef i_DOMNode As MSXML2.IXMLDOMNode _
)
Dim intTID As Long
Dim strURI As String
Dim DOMNodeNew As MSXML2.IXMLDOMNode
Dim ModifiedDOMNodes As MSXML2.IXMLDOMNode
Dim dtmModifiedTime As Date
intTID = XMLGetAttribute(i_DOMNode, HHT_tid_C)
strURI = XMLGetAttribute(i_DOMNode, HHT_URI_C)
dtmModifiedTime = XMLGetAttribute(i_DOMNode, HHT_modifiedtime_C)
p_clsTaxonomy.SetKeywords intTID, strURI, p_strKeywords, dtmModifiedTime, _
i_DOMNode.ownerDocument, DOMNodeNew, ModifiedDOMNodes
If (Not DOMNodeNew Is Nothing) Then
' If nothing changed, then DOMNodeNew will be Nothing.
XMLCopyAttributes DOMNodeNew, i_DOMNode
End If
If (Not ModifiedDOMNodes Is Nothing) Then
p_UpdateTIDs ModifiedDOMNodes
End If
End Sub
Private Function p_UpdateTaxonomy() As Boolean
On Error GoTo LErrorHandler
Dim intSelectedSKUs As Long
Dim intTID As Long
Dim Node As Node
Dim blnVisible As Boolean
Dim blnSubSite As Boolean
Dim strTitle As String
Dim strDescription As String
Dim strURI As String
Dim strIconURI As String
Dim intType As Long
Dim intNavModel As Long
Dim strLocInclude As String
Dim strKeywords As String
Dim strOriginalKeywords As String
Dim strDeletedKeywords As String
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMNodeNew As MSXML2.IXMLDOMNode
Dim ModifiedDOMNodes As MSXML2.IXMLDOMNode
Dim dtmModifiedTime As Date
Dim enumSKUsOld As SKU_E
p_UpdateTaxonomy = False
Set Node = treTaxonomy.Nodes(MODIFY_KEY_C)
Set DOMNode = Node.Tag
intTID = XMLGetAttribute(DOMNode, HHT_tid_C)
intSelectedSKUs = p_GetSelectedSKUs
blnVisible = IIf((chkVisible.Value = 0), False, True)
blnSubSite = IIf((chkSubSite.Value = 0), False, True)
strTitle = RemoveExtraSpaces(txtTitle)
strDescription = RemoveExtraSpaces(txtDescription)
strURI = RemoveExtraSpaces(txtURI)
strIconURI = RemoveExtraSpaces(txtIconURI)
intType = p_GetSelectedType
intNavModel = p_GetSelectedNavModel
strLocInclude = p_GetSelectedLocInclude
strKeywords = p_GetKeywords
strOriginalKeywords = XMLGetAttribute(DOMNode, HHT_keywords_C)
strDeletedKeywords = p_GetDeletedKeywords(strOriginalKeywords, strKeywords)
dtmModifiedTime = XMLGetAttribute(DOMNode, HHT_modifiedtime_C)
p_clsTaxonomy.Update intTID, strTitle, strDescription, intType, intNavModel, strURI, _
strIconURI, intSelectedSKUs, strLocInclude, blnVisible, blnSubSite, strKeywords, _
strDeletedKeywords, txtComments, txtEntry, dtmModifiedTime, _
DOMNode.ownerDocument, DOMNodeNew, ModifiedDOMNodes
enumSKUsOld = XMLGetAttribute(DOMNode, HHT_skus_C)
If (Not DOMNodeNew Is Nothing) Then
' If nothing changed, then DOMNodeNew will be Nothing.
' p_SetModeUpdating will set the title. Make sure that it is correct.
XMLCopyAttributes DOMNodeNew, DOMNode
End If
p_SetModeUpdating False
p_UpdateTaxonomy = True
If (intSelectedSKUs <> enumSKUsOld) Then
p_UpdateSubTree intTID, XMLGetAttribute(DOMNode, HHT_allowedskus_C)
End If
If (Not ModifiedDOMNodes Is Nothing) Then
p_UpdateTIDs ModifiedDOMNodes
End If
p_SetNodeColor Node, DOMNode
' The UI must show the new keywords that were associated by p_clsTaxonomy.Update
Highlight intTID
LEnd:
Exit Function
LErrorHandler:
Select Case Err.Number
Case errContainsGarbageChar
MsgBox "The Title " & strTitle & _
" or the Description " & strDescription & _
" contains garbage characters", _
vbExclamation + vbOKOnly
Case errTooLong
MsgBox "The Title " & strTitle & " is too long", _
vbExclamation + vbOKOnly
Case errNodeOrTopicAlreadyModified
MsgBox "Someone else already modified this entry. " & _
"You need to Cancel your entry, Refresh the database and then " & _
"re-enter your changes. " & _
"This prevents you from accidentally overwriting something " & _
"the other person entered. " & _
"Tip: Before cancelling your changes, copy them to Notepad.", _
vbExclamation + vbOKOnly
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Err.Raise Err.Number
Case errNotPermittedForAuthoringGroup, errAuthoringGroupDiffers, errAuthoringGroupNotPresent
DisplayAuthoringGroupError
Case Else
g_ErrorInfo.SetInfoAndRaiseError "p_UpdateTaxonomy"
End Select
GoTo LEnd
End Function
Private Sub p_UpdateTIDs( _
ByRef i_ModifiedDOMNodes As MSXML2.IXMLDOMNode _
)
Dim DOMNodes As MSXML2.IXMLDOMNode
Dim DOMNode As MSXML2.IXMLDOMNode
Dim intTID As Long
Dim intParentTID As Long
Dim intOrderUnderParent As Long
Dim enumSKUs As SKU_E
Dim Node As Node
Dim DOMNodeOld As MSXML2.IXMLDOMNode
Dim intParentTIDOld As Long
Dim intOrderUnderParentOld As Long
Dim enumSKUsOld As SKU_E
Dim blnRefresh As Boolean
Dim strTitle As String
Set DOMNodes = XMLFindFirstNode(i_ModifiedDOMNodes, HHT_TAXONOMY_ENTRIES_C)
If (Not DOMNodes.firstChild Is Nothing) Then
For Each DOMNode In DOMNodes.childNodes
intTID = XMLGetAttribute(DOMNode, HHT_tid_C)
If (Not p_NodeExists(intTID)) Then
GoTo LForEnd
End If
intParentTID = XMLGetAttribute(DOMNode, HHT_parenttid_C)
intOrderUnderParent = XMLGetAttribute(DOMNode, HHT_orderunderparent_C)
enumSKUs = XMLGetAttribute(DOMNode, HHT_skus_C)
Set Node = treTaxonomy.Nodes(KEY_PREFIX_C & intTID)
Set DOMNodeOld = Node.Tag
intParentTIDOld = XMLGetAttribute(DOMNodeOld, HHT_parenttid_C)
intOrderUnderParentOld = XMLGetAttribute(DOMNodeOld, HHT_orderunderparent_C)
enumSKUsOld = XMLGetAttribute(DOMNodeOld, HHT_skus_C)
If ((intParentTID <> intParentTIDOld) Or _
(intOrderUnderParent <> intOrderUnderParentOld)) Then
blnRefresh = True
Exit For
End If
XMLCopyAttributes DOMNode, DOMNodeOld
strTitle = XMLGetAttribute(DOMNode, HHT_TITLE_C)
Node.Text = strTitle
If (enumSKUs <> enumSKUsOld) Then
p_UpdateSubTree intTID, XMLGetAttribute(DOMNode, HHT_allowedskus_C)
End If
LForEnd:
Next
End If
If (blnRefresh) Then
cmdRefresh_Click
End If
End Sub
Private Sub p_CreateTaxonomyEntries( _
ByRef i_DOMNode As MSXML2.IXMLDOMNode, _
ByRef i_nodeParent As Node, _
ByVal i_blnFast As Boolean _
)
On Error GoTo LErrorHandler
Dim intParentTID As Long
Dim DOMNodeParent As MSXML2.IXMLDOMNode
Dim enumAllowedSKUs As SKU_E
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
If (p_blnCreating Or p_blnUpdating) Then
Exit Sub
End If
Set DOMNodeParent = i_nodeParent.Tag
intParentTID = XMLGetAttribute(DOMNodeParent, HHT_tid_C)
Set DOMDoc = New MSXML2.DOMDocument
Set DOMNode = HhtPreamble(DOMDoc, True)
XMLCopyDOMTree i_DOMNode, DOMNode
Set DOMNode = XMLFindFirstNode(DOMNode, HHT_TAXONOMY_ENTRY_C)
p_clsTaxonomy.CreateTaxonomyEntries DOMNode, intParentTID, i_blnFast
enumAllowedSKUs = p_GetAllowedSKUs(DOMNodeParent)
DOMNodeParent.appendChild DOMNode
p_CreateTree DOMNode, i_nodeParent, enumAllowedSKUs
LEnd:
Exit Sub
LErrorHandler:
Select Case Err.Number
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Err.Raise Err.Number
Case errAuthoringGroupNotPresent
DisplayAuthoringGroupError
Case Else
g_ErrorInfo.SetInfoAndRaiseError "p_CreateTaxonomyEntries"
End Select
GoTo LEnd
End Sub
Private Sub p_Move(i_Node As Node, i_nodeRef As Node, i_blnAbove As Boolean)
On Error GoTo LErrorHandler
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMNodeRef As MSXML2.IXMLDOMNode
Dim DOMNodeNewParent As MSXML2.IXMLDOMNode
Dim intTID As Long
Dim intRefTID As Long
Dim dtmModifiedTime As Date
Dim intNewParentTID As Long
Dim NodeNewParent As Node
Dim enumAllowedSKUs As SKU_E
Dim intOrderUnderParent As Long
If (p_blnCreating Or p_blnUpdating) Then
Exit Sub
End If
Set DOMNode = i_Node.Tag
Set DOMNodeRef = i_nodeRef.Tag
intTID = XMLGetAttribute(DOMNode, HHT_tid_C)
intRefTID = XMLGetAttribute(DOMNodeRef, HHT_tid_C)
dtmModifiedTime = XMLGetAttribute(DOMNode, HHT_modifiedtime_C)
p_clsTaxonomy.Move intTID, intRefTID, i_blnAbove, dtmModifiedTime, intOrderUnderParent
intNewParentTID = XMLGetAttribute(DOMNodeRef, HHT_parenttid_C)
XMLSetAttribute DOMNode, HHT_modifiedtime_C, Now
XMLSetAttribute DOMNode, HHT_parenttid_C, intNewParentTID
XMLSetAttribute DOMNode, HHT_orderunderparent_C, intOrderUnderParent
Set DOMNodeNewParent = treTaxonomy.Nodes(KEY_PREFIX_C & intNewParentTID).Tag
DOMNode.parentNode.removeChild DOMNode
DOMNodeNewParent.insertBefore DOMNode, DOMNodeRef
treTaxonomy.Nodes.Remove i_Node.Key
enumAllowedSKUs = p_GetAllowedSKUs(DOMNodeNewParent)
p_CreateTree DOMNode, i_nodeRef.Parent, enumAllowedSKUs, _
i_nodeRef, i_blnAbove
treTaxonomy_NodeClick treTaxonomy.SelectedItem
LEnd:
Exit Sub
LErrorHandler:
Select Case Err.Number
Case errRefNodeCannotBeDescendent
MsgBox "A Node cannot move above or below a descendent Node", _
vbExclamation + vbOKOnly
Case errNodeOrTopicAlreadyModified
MsgBox "Someone else already modified this entry. " & _
"You need to Refresh the database and then try again. " & _
"This prevents you from accidentally overwriting something " & _
"the other person entered.", _
vbExclamation + vbOKOnly
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Err.Raise Err.Number
Case errNotPermittedForAuthoringGroup, errAuthoringGroupDiffers, errAuthoringGroupNotPresent
DisplayAuthoringGroupError
Case Else
g_ErrorInfo.SetInfoAndRaiseError "p_Move"
End Select
GoTo LEnd
End Sub
Private Sub p_ChangeParent(i_Node As Node, i_nodeParent As Node)
On Error GoTo LErrorHandler
Dim DOMNode As MSXML2.IXMLDOMNode
Dim intTID As Long
Dim intOldParentTID As Long
Dim intNewParentTID As Long
Dim dtmModifiedTime As Date
Dim DOMNodeNewParent As MSXML2.IXMLDOMNode
Dim NodeNewParent As Node
Dim enumAllowedSKUs As SKU_E
Dim intOrderUnderParent As Long
If (p_blnCreating Or p_blnUpdating) Then
Exit Sub
End If
Set DOMNode = i_Node.Tag
Set DOMNodeNewParent = i_nodeParent.Tag
intTID = XMLGetAttribute(DOMNode, HHT_tid_C)
intOldParentTID = XMLGetAttribute(i_Node.Parent.Tag, HHT_tid_C)
intNewParentTID = XMLGetAttribute(DOMNodeNewParent, HHT_tid_C)
dtmModifiedTime = XMLGetAttribute(DOMNode, HHT_modifiedtime_C)
Set NodeNewParent = treTaxonomy.Nodes(KEY_PREFIX_C & intNewParentTID)
If (intOldParentTID = intNewParentTID) Then
Exit Sub
End If
p_clsTaxonomy.MoveInto intTID, intNewParentTID, dtmModifiedTime, intOrderUnderParent
XMLSetAttribute DOMNode, HHT_modifiedtime_C, Now
XMLSetAttribute DOMNode, HHT_parenttid_C, intNewParentTID
XMLSetAttribute DOMNode, HHT_orderunderparent_C, intOrderUnderParent
DOMNode.parentNode.removeChild DOMNode
DOMNodeNewParent.appendChild DOMNode
treTaxonomy.Nodes.Remove i_Node.Key
enumAllowedSKUs = p_GetAllowedSKUs(DOMNodeNewParent)
p_CreateTree DOMNode, NodeNewParent, enumAllowedSKUs
treTaxonomy_NodeClick treTaxonomy.SelectedItem
LEnd:
Exit Sub
LErrorHandler:
Select Case Err.Number
Case errRefNodeCannotBeDescendent
MsgBox "A Node cannot be a child of a descendent Node", _
vbExclamation + vbOKOnly
Case errParentCannotBeLeaf
MsgBox "A Node cannot be a child of a Topic", _
vbExclamation + vbOKOnly
Case errNodeOrTopicAlreadyModified
MsgBox "Someone else already modified this entry. " & _
"You need to Refresh the database and then try again. " & _
"This prevents you from accidentally overwriting something " & _
"the other person entered.", _
vbExclamation + vbOKOnly
Case E_FAIL
DisplayDatabaseLockedError
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Err.Raise Err.Number
Case errNotPermittedForAuthoringGroup, errAuthoringGroupDiffers, errAuthoringGroupNotPresent
DisplayAuthoringGroupError
Case Else
g_ErrorInfo.SetInfoAndRaiseError "p_ChangeParent"
End Select
GoTo LEnd
End Sub
Private Function p_GetKeywords() As String
Dim intKID As Variant
p_GetKeywords = " "
For Each intKID In p_dictKeywordsWithTitle.Keys
p_GetKeywords = p_GetKeywords & intKID & " "
Next
If (p_GetKeywords = " ") Then
p_GetKeywords = ""
End If
End Function
Private Function p_GetDeletedKeywords( _
ByVal strOldKeywords As String, _
ByVal strNewKeywords As String _
) As String
Dim arrOldKIDs() As String
Dim arrNewKIDs() As String
Dim intIndex1 As Long
Dim intIndex2 As Long
Dim blnFound As Boolean
p_GetDeletedKeywords = " "
arrOldKIDs = Split(strOldKeywords, " ")
arrNewKIDs = Split(strNewKeywords, " ")
For intIndex1 = LBound(arrOldKIDs) To UBound(arrOldKIDs)
blnFound = False
intIndex2 = LBound(arrNewKIDs)
Do While (intIndex2 <= UBound(arrNewKIDs))
If (arrOldKIDs(intIndex1) = arrNewKIDs(intIndex2)) Then
blnFound = True
Exit Do
End If
intIndex2 = intIndex2 + 1
Loop
If (Not blnFound) Then
p_GetDeletedKeywords = p_GetDeletedKeywords & arrOldKIDs(intIndex1) & " "
End If
Next
End Function
Private Sub p_UpdateSubTree( _
ByVal i_intTID As Long, _
ByVal i_enumAllowedSKUs As SKU_E _
)
Dim Node As Node
Dim DOMNode As MSXML2.IXMLDOMNode
Dim ChildDOMNode As MSXML2.IXMLDOMNode
Dim enumAllowedSKUs As SKU_E
Dim intTID As Long
Set Node = treTaxonomy.Nodes(KEY_PREFIX_C & i_intTID)
Set DOMNode = Node.Tag
If (i_intTID <> ROOT_TID_C) Then
XMLSetAttribute DOMNode, HHT_allowedskus_C, i_enumAllowedSKUs
p_SetNodeImage Node, DOMNode
p_SetNodeColor Node, DOMNode
enumAllowedSKUs = i_enumAllowedSKUs And XMLGetAttribute(DOMNode, HHT_skus_C)
Else
enumAllowedSKUs = i_enumAllowedSKUs
End If
' Now update the descendents
If (Not DOMNode.firstChild Is Nothing) Then
For Each ChildDOMNode In DOMNode.childNodes
intTID = XMLGetAttribute(ChildDOMNode, HHT_tid_C)
p_UpdateSubTree intTID, enumAllowedSKUs
Next
End If
End Sub
Private Sub p_CreateTree( _
ByRef u_DOMNode As MSXML2.IXMLDOMNode, _
ByRef i_Node As Node, _
ByVal i_enumAllowedSKUs As SKU_E, _
Optional ByRef i_nodeRef As Node = Nothing, _
Optional ByRef i_blnAbove As Boolean _
)
On Error GoTo LErrorHandler
Dim DOMNode As MSXML2.IXMLDOMNode
Dim Node As Node
Dim strTitle As String
Dim strKey As String
Dim enumAllowedSKUs As SKU_E
Dim intRelationship As Long
If (u_DOMNode.nodeName = HHT_TAXONOMY_ENTRY_C) Then
strTitle = XMLGetAttribute(u_DOMNode, HHT_TITLE_C)
strKey = KEY_PREFIX_C & XMLGetAttribute(u_DOMNode, HHT_tid_C)
XMLSetAttribute u_DOMNode, HHT_allowedskus_C, i_enumAllowedSKUs
If (i_Node Is Nothing) Then
Set Node = treTaxonomy.Nodes.Add(Key:=strKey, Text:=strTitle)
Node.Expanded = True
Else
If (i_nodeRef Is Nothing) Then
Set Node = treTaxonomy.Nodes.Add(i_Node, tvwChild, strKey, strTitle)
Else
If (i_blnAbove) Then
intRelationship = tvwPrevious
Else
intRelationship = tvwNext
End If
Set Node = treTaxonomy.Nodes.Add(i_nodeRef.Key, intRelationship, strKey, _
strTitle)
End If
End If
Set Node.Tag = u_DOMNode
p_SetNodeColor Node, u_DOMNode
p_SetNodeImage Node, u_DOMNode
enumAllowedSKUs = i_enumAllowedSKUs And XMLGetAttribute(u_DOMNode, HHT_skus_C)
Else
Set Node = i_Node
enumAllowedSKUs = i_enumAllowedSKUs
End If
If (Not (u_DOMNode.firstChild Is Nothing)) Then
For Each DOMNode In u_DOMNode.childNodes
p_CreateTree DOMNode, Node, enumAllowedSKUs
Next
End If
LEnd:
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndRaiseError "p_CreateTree"
GoTo LEnd
End Sub
Private Sub p_InitializeDataStructures( _
ByRef o_DOMNode As MSXML2.IXMLDOMNode _
)
' Put a Me.Enabled = True in the error handler that will handle errors
' that happen here.
Dim T0 As Date
Dim T1 As Date
Dim DOMDoc As MSXML2.DOMDocument
Me.Enabled = False
T0 = Now
Set p_colKeywords = New Collection
p_SetStatusText SBPANEL_DATABASE, "Reading Keywords from Database..."
p_clsKeywords.GetAllKeywordsColl p_colKeywords
p_SetStatusText SBPANEL_DATABASE, "Reading Taxonomy from Database..."
Set DOMDoc = p_clsTaxonomy.GetTaxonomyInXml
p_SetStatusText SBPANEL_DATABASE, ""
Set o_DOMNode = XMLFindFirstNode(DOMDoc, HHT_TAXONOMY_ENTRY_C)
T1 = Now
Debug.Print "p_InitializeDataStructures: " & FormatTime(T0, T1)
Me.Enabled = True
End Sub
Private Sub p_Refresh( _
ByRef i_DOMNode As MSXML2.IXMLDOMNode _
)
' Put a Me.Enabled = True in the error handler that will handle errors
' that happen here.
Dim T0 As Date
Dim T1 As Date
Me.Enabled = False
T0 = Now
If (p_blnCreating Or p_blnUpdating) Then
Exit Sub
End If
p_ClearTreeView
p_ClearNodeDetails
p_DisableEditPaste
p_DisableEditPasteKeywords
p_InitializeTypeCombo
p_EnableTaxonomyAndSomeMenus
p_EnableRefresh
p_EnableNodeDetailsExceptIndividualSKUs
p_SetStatusText SBPANEL_DATABASE, "Creating Taxonomy tree..."
p_CreateTree i_DOMNode, Nothing, ALL_SKUS_C
p_SetStatusText SBPANEL_DATABASE, ""
T1 = Now
Debug.Print "p_Refresh: " & FormatTime(T0, T1)
Me.Enabled = True
End Sub
Private Sub p_SetKeywordsList()
On Error GoTo LErrorHandler
Dim intKID As Variant
cboKeywords.Clear
For Each intKID In p_dictKeywordsWithTitle
cboKeywords.AddItem p_colKeywords(CStr(intKID))
Next
Exit Sub
LErrorHandler:
g_ErrorInfo.SetInfoAndRaiseError "p_SetKeywordsList"
End Sub
Private Function p_GetStatusText(i_enumPanel As STATUS_BAR_PANEL_E) As String
p_GetStatusText = staInfo.Panels(i_enumPanel).Text
End Function
Private Sub p_SetStatusText(i_enumPanel As STATUS_BAR_PANEL_E, i_strText As String)
staInfo.Panels(i_enumPanel).Text = i_strText
End Sub
Private Sub p_SetNavModelCombo(i_strNavModel As String)
Dim strNavModel As String
Dim intIndex As Long
If (i_strNavModel = "") Then
strNavModel = NAVMODEL_DEFAULT_STR_C
Else
strNavModel = i_strNavModel
End If
For intIndex = 0 To cboNavModel.ListCount - 1
If (cboNavModel.List(intIndex) = strNavModel) Then
cboNavModel.ListIndex = intIndex
Exit For
End If
Next
End Sub
Private Sub p_InitializeNavModelCombo()
cboNavModel.Clear
cboNavModel.AddItem NAVMODEL_DEFAULT_STR_C
cboNavModel.ItemData(cboNavModel.NewIndex) = NAVMODEL_DEFAULT_NUM_C
cboNavModel.AddItem NAVMODEL_SERVER_STR_C
cboNavModel.ItemData(cboNavModel.NewIndex) = NAVMODEL_SERVER_NUM_C
cboNavModel.AddItem NAVMODEL_DESKTOP_STR_C
cboNavModel.ItemData(cboNavModel.NewIndex) = NAVMODEL_DESKTOP_NUM_C
End Sub
Private Sub p_SetLocIncludeCombo(i_strLocInclude As String)
Dim intIndex As Long
Dim blnExistingLocInclude As Boolean
p_InitializeLocIncludeCombo
For intIndex = LBound(LocIncludes) To UBound(LocIncludes)
If (i_strLocInclude = LocIncludes(intIndex)) Then
blnExistingLocInclude = True
End If
Next
If (Not blnExistingLocInclude) Then
cboLocInclude.AddItem i_strLocInclude, UBound(LocIncludes) + 1
End If
cboLocInclude.Text = i_strLocInclude
End Sub
Private Sub p_InitializeLocIncludeCombo()
Dim intIndex As Long
InitializeLocIncludes
cboLocInclude.Clear
For intIndex = LBound(LocIncludes) To UBound(LocIncludes)
cboLocInclude.AddItem LocIncludes(intIndex), intIndex
Next
End Sub
Private Sub p_SetTypeComboIndex(i_intIndex As Long)
cboType.ListIndex = i_intIndex
End Sub
Private Sub p_InitializeTypeCombo()
On Error GoTo LErrorHandler
Dim arrTypes() As Variant
Dim intIndex As Long
' Initialize the Types Combo Box
arrTypes = p_clsTaxonomy.GetTypes
cboType.Clear
For intIndex = 0 To UBound(arrTypes)
cboType.AddItem arrTypes(intIndex)(1), intIndex
cboType.ItemData(cboType.NewIndex) = arrTypes(intIndex)(0)
Next
Exit Sub
LErrorHandler:
Select Case Err.Number
Case errDatabaseVersionIncompatible
DisplayDatabaseVersionError
Err.Raise Err.Number
Case Else
g_ErrorInfo.SetInfoAndRaiseError "p_InitializeTypeCombo"
End Select
End Sub
Private Function p_GetBrokenLinkDir( _
ByVal i_enumSKU As SKU_E _
) As String
p_GetBrokenLinkDir = p_clsParameters.Value(BROKEN_LINK_WORKING_DIR_C & Hex(i_enumSKU)) & ""
If (p_GetBrokenLinkDir = "") Then
Err.Raise errNotConfiguredForNavigateLink
End If
End Function
Private Sub p_InitializeTaxonomyTree()
Dim nodeNew As Node
Set treTaxonomy.ImageList = ilsIcons
treTaxonomy.HideSelection = False
treTaxonomy.LabelEdit = tvwManual
' The problem with FullRowSelect is that if you click on the far right side of
' a row, it will be highlighted, but NodeClick will not be called.
' treTaxonomy.FullRowSelect = True
End Sub
Private Sub p_ClearTreeView()
' Remove the root. Does garbage collection caused the other nodes to be removed?
If (treTaxonomy.Nodes.Count > 0) Then
treTaxonomy.Nodes.Remove 1
End If
End Sub
Private Sub p_EnableTaxonomyAndSomeMenus()
mnuEdit.Enabled = True
mnuTools.Enabled = True
mnuFileExportHHT.Enabled = True
mnuFileImportHHT.Enabled = True
lblTaxonomy.Enabled = True
treTaxonomy.Enabled = True
End Sub
Private Sub p_DisableTaxonomyAndSomeMenus()
mnuEdit.Enabled = False
mnuTools.Enabled = False
mnuFileExportHHT.Enabled = False
mnuFileImportHHT.Enabled = False
lblTaxonomy.Enabled = False
treTaxonomy.Enabled = False
End Sub
Private Sub p_EnableCreate()
cmdCreateGroup.Enabled = True
cmdCreateLeaf.Enabled = True
mnuRightClickCreateNode.Enabled = True
mnuRightClickCreateTopic.Enabled = True
End Sub
Private Sub p_DisableCreate()
cmdCreateGroup.Enabled = False
cmdCreateLeaf.Enabled = False
mnuRightClickCreateNode.Enabled = False
mnuRightClickCreateTopic.Enabled = False
End Sub
Private Sub p_EnableDelete()
cmdDelete.Enabled = True
mnuRightClickDelete.Enabled = True
End Sub
Private Sub p_DisableDelete()
cmdDelete.Enabled = False
mnuRightClickDelete.Enabled = False
End Sub
Private Sub p_EnableRefresh()
cmdRefresh.Enabled = True
End Sub
Private Sub p_DisableRefresh()
cmdRefresh.Enabled = False
End Sub
Private Sub p_EnableNavModel()
lblNavModel.Enabled = True
cboNavModel.Enabled = True
End Sub
Private Sub p_DisableNavModel()
lblNavModel.Enabled = False
cboNavModel.Enabled = False
End Sub
Private Sub p_EnableSubSite()
chkSubSite.Enabled = True
End Sub
Private Sub p_DisableSubSite()
chkSubSite.Enabled = False
End Sub
Private Sub p_EnableEditEntry()
cmdEditEntry.Enabled = True
End Sub
Private Sub p_DisableEditEntry()
cmdEditEntry.Enabled = False
End Sub
Private Sub p_EnableEntry()
txtEntry.Locked = False
End Sub
Private Sub p_DisableEntry()
txtEntry.Locked = True
End Sub
Private Sub p_EnableNodeDetailsExceptIndividualSKUs()
chkVisible.Enabled = True
lblLocInclude.Enabled = True
cboLocInclude.Enabled = True
lblTitle.Enabled = True
lblDescription.Enabled = True
lblURI.Enabled = True
cmdURI.Enabled = True
lblIconURI.Enabled = True
lblType.Enabled = True
lblComments.Enabled = True
lblEntry.Enabled = True
txtTitle.Locked = False
txtDescription.Locked = False
txtURI.Locked = False
txtIconURI.Locked = False
cboType.Enabled = True
txtComments.Locked = False
fraSKU.Enabled = True
lblKeywords.Enabled = True
cboKeywords.Enabled = True
lblLastModified.Enabled = True
End Sub
Private Sub p_DisableNodeDetails()
chkVisible.Enabled = False
lblLocInclude.Enabled = False
cboLocInclude.Enabled = False
chkSubSite.Enabled = False
p_DisableNavModel
lblTitle.Enabled = False
lblDescription.Enabled = False
lblURI.Enabled = False
cmdURI.Enabled = False
lblIconURI.Enabled = False
lblType.Enabled = False
lblComments.Enabled = False
lblEntry.Enabled = False
p_DisableEditEntry
txtTitle.Locked = True
txtDescription.Locked = True
txtURI.Locked = True
txtIconURI.Locked = True
cboType.Enabled = False
txtComments.Locked = True
p_DisableEntry
chkVisible.Enabled = False
fraSKU.Enabled = False
p_DisableSKUs
lblKeywords.Enabled = False
cboKeywords.Enabled = False
lblLastModified.Enabled = False
p_DisableAddRemoveAndKeywordsCombo
p_DisableNavigateLink
End Sub
Private Sub p_EnableNavigateLink()
lblNavigateLink.Enabled = True
cboNavigateLink.Enabled = True
cmdNavigateLink.Enabled = True
End Sub
Private Sub p_DisableNavigateLink()
lblNavigateLink.Enabled = False
cboNavigateLink.Enabled = False
cmdNavigateLink.Enabled = False
End Sub
Private Sub p_EnableAddRemoveAndKeywordsCombo()
cmdAddRemove.Enabled = True
cboKeywords.Enabled = True
End Sub
Private Sub p_DisableAddRemoveAndKeywordsCombo()
cmdAddRemove.Enabled = False
cboKeywords.Enabled = False
End Sub
Private Sub p_ClearNodeDetails()
Dim blnSettingControls As Boolean
blnSettingControls = p_blnSettingControls
p_blnSettingControls = True
txtTitle = ""
txtDescription = ""
txtURI = ""
txtIconURI = ""
txtComments = ""
txtEntry = ""
lblLastModified = ""
p_SetTypeComboIndex -1
chkVisible.Value = 0
chkSubSite.Value = 0
p_SetNavModelCombo NAVMODEL_DEFAULT_NUM_C
p_ClearSKUs
cboKeywords.Clear
' Reset it to the state it was in when this function was called.
p_blnSettingControls = blnSettingControls
End Sub
Private Sub p_EnableSKUs()
chkStandard.Enabled = True
chkProfessional.Enabled = True
chkProfessional64.Enabled = True
chkWindowsMillennium.Enabled = True
chkServer.Enabled = True
chkAdvancedServer.Enabled = True
chkDataCenterServer.Enabled = True
chkAdvancedServer64.Enabled = True
chkDataCenterServer64.Enabled = True
End Sub
Private Sub p_DisableSKUs()
chkStandard.Enabled = False
chkProfessional.Enabled = False
chkProfessional64.Enabled = False
chkWindowsMillennium.Enabled = False
chkServer.Enabled = False
chkAdvancedServer.Enabled = False
chkDataCenterServer.Enabled = False
chkAdvancedServer64.Enabled = False
chkDataCenterServer64.Enabled = False
End Sub
Private Sub p_ClearSKUs()
chkStandard.Value = 0
chkProfessional.Value = 0
chkProfessional64.Value = 0
chkWindowsMillennium.Value = 0
chkServer.Value = 0
chkAdvancedServer.Value = 0
chkDataCenterServer.Value = 0
chkAdvancedServer64.Value = 0
chkDataCenterServer64.Value = 0
End Sub
Private Sub p_StrikeoutUnselectedSKUs()
chkStandard.Font.Strikethrough = _
IIf((p_enumFilterSKUs And SKU_STANDARD_E), False, True)
chkProfessional.Font.Strikethrough = _
IIf((p_enumFilterSKUs And SKU_PROFESSIONAL_E), False, True)
chkProfessional64.Font.Strikethrough = _
IIf((p_enumFilterSKUs And SKU_PROFESSIONAL_64_E), False, True)
chkWindowsMillennium.Font.Strikethrough = _
IIf((p_enumFilterSKUs And SKU_WINDOWS_MILLENNIUM_E), False, True)
chkServer.Font.Strikethrough = _
IIf((p_enumFilterSKUs And SKU_SERVER_E), False, True)
chkAdvancedServer.Font.Strikethrough = _
IIf((p_enumFilterSKUs And SKU_ADVANCED_SERVER_E), False, True)
chkDataCenterServer.Font.Strikethrough = _
IIf((p_enumFilterSKUs And SKU_DATA_CENTER_SERVER_E), False, True)
chkAdvancedServer64.Font.Strikethrough = _
IIf((p_enumFilterSKUs And SKU_ADVANCED_SERVER_64_E), False, True)
chkDataCenterServer64.Font.Strikethrough = _
IIf((p_enumFilterSKUs And SKU_DATA_CENTER_SERVER_64_E), False, True)
End Sub
Private Sub p_DisableUnselectedSKUs()
If (chkStandard.Value = 0) Then
chkStandard.Enabled = False
End If
If (chkProfessional.Value = 0) Then
chkProfessional.Enabled = False
End If
If (chkProfessional64.Value = 0) Then
chkProfessional64.Enabled = False
End If
If (chkWindowsMillennium.Value = 0) Then
chkWindowsMillennium.Enabled = False
End If
If (chkServer.Value = 0) Then
chkServer.Enabled = False
End If
If (chkAdvancedServer.Value = 0) Then
chkAdvancedServer.Enabled = False
End If
If (chkDataCenterServer.Value = 0) Then
chkDataCenterServer.Enabled = False
End If
If (chkAdvancedServer64.Value = 0) Then
chkAdvancedServer64.Enabled = False
End If
If (chkDataCenterServer64.Value = 0) Then
chkDataCenterServer64.Enabled = False
End If
End Sub
Private Sub p_EnableSaveCancel()
cmdSave.Enabled = True
cmdCancel.Enabled = True
cmdCancel.Cancel = True
End Sub
Private Sub p_DisableSaveCancel()
cmdSave.Enabled = False
cmdCancel.Enabled = False
cmdCancel.Cancel = False
End Sub
Private Sub p_EnableEditCopy()
mnuEditCopy.Enabled = True
mnuRightClickCopy.Enabled = True
End Sub
Private Sub p_DisableEditCopy()
mnuEditCopy.Enabled = False
mnuRightClickCopy.Enabled = False
End Sub
Private Sub p_EnableEditCut()
mnuEditCut.Enabled = True
mnuRightClickCut.Enabled = True
End Sub
Private Sub p_DisableEditCut()
mnuEditCut.Enabled = False
mnuRightClickCut.Enabled = False
End Sub
Private Sub p_EnableEditPaste()
mnuEditPaste.Enabled = True
mnuRightClickPaste.Enabled = True
End Sub
Private Sub p_DisableEditPaste()
mnuEditPaste.Enabled = False
mnuRightClickPaste.Enabled = False
End Sub
Private Sub p_EnableEditPasteKeywords()
mnuEditPasteKeywords.Enabled = True
mnuRightClickPasteKeywords.Enabled = True
p_AddCheckboxesToTree
End Sub
Private Sub p_DisableEditPasteKeywords()
mnuEditPasteKeywords.Enabled = False
mnuRightClickPasteKeywords.Enabled = False
p_RemoveCheckboxesFromTree
End Sub
Private Sub p_DisableEverything()
p_DisableTaxonomyAndSomeMenus
p_DisableCreate
p_DisableDelete
p_DisableRefresh
p_DisableNodeDetails
p_DisableAddRemoveAndKeywordsCombo
p_DisableNavigateLink
p_DisableSaveCancel
End Sub
Private Sub p_AddCheckboxesToTree()
treTaxonomy.Checkboxes = True
End Sub
Private Sub p_RemoveCheckboxesFromTree()
treTaxonomy.Checkboxes = False
End Sub
Private Sub p_SetTitle( _
ByVal i_strDatabase As String _
)
frmMain.Caption = "Production Tool (" & i_strDatabase & ")"
End Sub
Private Sub p_SetSizingInfo()
Static blnInfoSet As Boolean
If (blnInfoSet) Then
Exit Sub
End If
p_clsSizer.AddControl treTaxonomy
Set p_clsSizer.ReferenceControl(DIM_HEIGHT_E) = frmMain
Set p_clsSizer.ReferenceControl(DIM_WIDTH_E) = frmMain
p_clsSizer.Operation(DIM_WIDTH_E) = OP_MULTIPLY_E
p_clsSizer.AddControl cmdCreateGroup
Set p_clsSizer.ReferenceControl(DIM_TOP_E) = treTaxonomy
p_clsSizer.ReferenceDimension(DIM_TOP_E) = DIM_BOTTOM_E
p_clsSizer.AddControl cmdCreateLeaf
Set p_clsSizer.ReferenceControl(DIM_TOP_E) = cmdCreateGroup
p_clsSizer.AddControl cmdDelete
Set p_clsSizer.ReferenceControl(DIM_TOP_E) = cmdCreateGroup
p_clsSizer.AddControl cmdRefresh
Set p_clsSizer.ReferenceControl(DIM_TOP_E) = cmdCreateGroup
p_clsSizer.AddControl lblLocInclude
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = frmMain
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
p_clsSizer.AddControl cboLocInclude
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = lblLocInclude
p_clsSizer.AddControl lblTitle
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = treTaxonomy
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_RIGHT_E
p_clsSizer.AddControl txtTitle
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = lblTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = frmMain
p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
p_clsSizer.AddControl chkVisible
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl chkSubSite
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl lblNavModel
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl cboNavModel
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl lblDescription
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl txtDescription
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = txtTitle
p_clsSizer.AddControl lblType
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl cboType
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = txtTitle
p_clsSizer.AddControl lblURI
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl txtURI
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = txtTitle
p_clsSizer.AddControl cmdURI
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_RIGHT_E
p_clsSizer.AddControl lblIconURI
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl txtIconURI
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = txtTitle
p_clsSizer.AddControl lblComments
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl txtComments
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = txtTitle
p_clsSizer.AddControl lblEntry
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl txtEntry
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = txtTitle
p_clsSizer.AddControl cmdEditEntry
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_RIGHT_E
p_clsSizer.AddControl lblNavigateLink
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl cboNavigateLink
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = frmMain
p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
p_clsSizer.AddControl cmdNavigateLink
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_RIGHT_E
p_clsSizer.AddControl fraSKU
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = txtTitle
p_clsSizer.AddControl chkServer
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = fraSKU
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
p_clsSizer.Operation(DIM_LEFT_E) = OP_MULTIPLY_E
p_clsSizer.AddControl chkAdvancedServer
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = chkServer
p_clsSizer.AddControl chkDataCenterServer
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = chkServer
p_clsSizer.AddControl chkAdvancedServer64
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = chkServer
p_clsSizer.AddControl chkDataCenterServer64
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = chkServer
p_clsSizer.AddControl lblKeywords
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.AddControl cmdAddRemove
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_RIGHT_E
p_clsSizer.AddControl cboKeywords
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = txtTitle
Set p_clsSizer.ReferenceControl(DIM_HEIGHT_E) = frmMain
p_clsSizer.AddControl cmdSave
Set p_clsSizer.ReferenceControl(DIM_TOP_E) = cmdCreateGroup
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = frmMain
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
p_clsSizer.AddControl cmdCancel
Set p_clsSizer.ReferenceControl(DIM_TOP_E) = cmdCreateGroup
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = cmdSave
p_clsSizer.AddControl lblLastModified
Set p_clsSizer.ReferenceControl(DIM_TOP_E) = cmdCreateGroup
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = cmdCreateGroup
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = cmdSave
blnInfoSet = True
End Sub
Private Sub p_SetToolTips()
chkVisible.ToolTipText = "Controls whether the user can navigate to the Node/Topic using the Taxonomy."
chkSubSite.ToolTipText = "Indicates whether this node is a subsite, or appears on the flyout menu."
lblNavModel.ToolTipText = "Determines which navigation model will be used for the node."
cboNavModel.ToolTipText = lblNavModel.ToolTipText
lblLocInclude.ToolTipText = "Indicates localization preferences for the topic."
cboLocInclude.ToolTipText = lblLocInclude.ToolTipText
lblTitle.ToolTipText = "The title as it will appear in the taxonomy tree."
txtTitle.ToolTipText = lblTitle.ToolTipText
lblDescription.ToolTipText = "A description of the node or topic."
txtDescription.ToolTipText = lblDescription.ToolTipText
lblType.ToolTipText = "The category of the title, to be used for search categories."
cboType.ToolTipText = lblType.ToolTipText
lblURI.ToolTipText = "Uniform Resource Indicator. This is the address of the file."
txtURI.ToolTipText = lblURI.ToolTipText
lblIconURI.ToolTipText = "The path to the icon that is displayed in the Desktop navigation model."
txtIconURI.ToolTipText = lblIconURI.ToolTipText
lblComments.ToolTipText = "Additional comment about the node or topic."
txtComments.ToolTipText = lblComments.ToolTipText
lblEntry.ToolTipText = "Used by other files to link to this topic. It is not recommended that this field be changed after it has been set."
txtEntry.ToolTipText = lblEntry.ToolTipText
lblNavigateLink.ToolTipText = "Select a valid SKU to view the content of the selected topic."
cboNavigateLink.ToolTipText = lblNavigateLink.ToolTipText
fraSKU.ToolTipText = "Select which platforms this node or topic applies to. " & _
"Child nodes or topics will inherit only the boxes checked for the parent " & _
"node or topic."
cboKeywords.ToolTipText = "These are the keywords associated with selected node."
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
Function rep_string(s)
max_len = Int(Len(s)/2)
tmp = ""
If max_len = 0 Then
rep_string = "No Repeating String"
Exit Function
End If
For i = 1 To max_len
If InStr(i+1,s,tmp & Mid(s,i,1))Then
tmp = tmp & Mid(s,i,1)
Else
Exit For
End If
Next
Do While Len(tmp) > 0
If Mid(s,Len(tmp)+1,Len(tmp)) = tmp Then
rep_string = tmp
Exit Do
Else
tmp = Mid(tmp,1,Len(tmp)-1)
End If
Loop
If Len(tmp) > 0 Then
rep_string = tmp
Else
rep_string = "No Repeating String"
End If
End Function
'testing the function
arr = Array("1001110011","1110111011","0010010010","1010101010",_
"1111111111","0100101101","0100100","101","11","00","1")
For n = 0 To UBound(arr)
WScript.StdOut.Write arr(n) & ": " & rep_string(arr(n))
WScript.StdOut.WriteLine
Next
|
' ***********************************************************************
' *****
' ***** RS232_Debugger PC - Bridge to - RS232_Debugger.v FPGA Verilog
' *****
' ***** Designed to be compiled with FREEBASIC
' ***** https://www.freebasic.net/
' *****
' ***** Written By <NAME>. November 2019
'
' ***** V1.2 - August 13, 2020
' ***** Patched ascii display bug where character 0xFF sometimes showed
' ***** old characters from a previous page refresh.
'
' ***********************************************************************
const MAX_MEM_ALLOC = 1048576 '16384 '1048576
const COM_CACHE = 2048: REM number of allowed sequential bytes to be sent and received. FOR FTDI FT232 serial cables, use 2048. 1/2 their fifo size.
const COM_PRE_TIMEOUT = 2 : REM time in ms to wait for flush to take effect
const COM_POST_TIMEOUT = 20 : REM time in ms to wait for GPU to respond before considering an error
const COM_FLUSH = 0 : REM 1 = send 272 null characters before every command 0 = high speed
const COM_WAIT = 0 : REM 1 = wait and flush an characters in the PC's RDX before beginning to transmit
const COM_VERBOSE = 0 : REM 1= print all com transaction debug information, 2 = print mouse coordinates and keypresses
const SLEEP_TIME = 1 : REM The amount of time to sleep in ms between screen refresh and COM access. Use at least 1 for good multitasking
const TXT_BOX_x = 20
const TXT_BOX_y = 25
Declare Sub print_setup()
Declare Sub print_hex()
Declare Sub print_dec()
Declare Sub print_mouse()
Declare sub print_select()
Declare Sub gpu_printadr()
Declare Sub color_rg( colm as ubyte, yp as ubyte, xp as ubyte )
Declare Sub ascii_enter()
Declare Sub hex_enter()
Declare Sub inc_cursor(xofs as byte, yofs as byte)
Declare Sub put_undo()
Declare Sub get_undo()
Declare Sub do_commands()
Declare Sub print_ports()
Declare sub click_binary(xp as integer, yp as integer, eb as Ubyte)
Declare Sub open_com()
Declare Sub close_com()
Declare Sub read_gpu(mbase as integer, msize as integer)
Declare Sub write_gpu(mbase as integer, msize as integer)
Declare Sub read_gpu_all(mbase as integer, msize as integer)
Declare Sub write_gpu_all(mbase as integer, msize as integer)
Declare Sub com_setport()
Declare Sub save_file(fname as string, start as integer, size as integer)
Declare Sub load_file(fname as string, start as integer, size as integer)
Declare Sub save_dialog()
Declare Sub load_dialog()
Declare Sub save_mif()
Declare Sub save_mif16()
Declare Sub file_dialog( i as string, fn as string )
Declare Sub edit16( i as integer )
Declare Sub enter16( i as integer )
Declare Sub box( i as integer )
declare sub show_errors(i as integer)
Declare Sub inputhex (i as string)
Declare Sub inputdec (i as string)
function phex24(byval i As Integer) As String
dim as string d
d = hex(i)
if i<16 then d = "0" + d
if i<256 then d = "0" + d
if i<4096 then d = "0" + d
if i<65536 then d = "0" + d
if i<1048576 then d = "0" + d
function = d
end function
function phex16(byval i As Integer) As String
dim as string d
d = hex(i)
if i<16 then d = "0" + d
if i<256 then d = "0" + d
if i<4096 then d = "0" + d
function = d
end function
function p099(byval i As Integer) As String
dim as string d
d = str(i)
if i<10 then d = " " + d
function = d
end function
function px99(byval i As Integer) As String
dim as string d
d = str(i)
if i<10 then d = "0" + d
function = d
end function
function p999(byval i As Integer) As String
dim as string d
d = str(i)
if i<100 then d = "0" + d
if i<10 then d = "0" + d
function = d
end function
function px999(byval i As Integer) As String
dim as string d
d = str(i)
if i<100 then d = " " + d
if i<10 then d = " " + d
function = d
end function
function p9999(byval i As Integer) As String
dim as string d
d = str(i)
if i<1000 then d = "0" + d
if i<100 then d = "0" + d
if i<10 then d = "0" + d
function = d
end function
function px9999(byval i As Integer) As String
dim as string d
d = str(i)
if i<1000 then d = " " + d
if i<100 then d = " " + d
if i<10 then d = " " + d
function = d
end function
function p99999(byval i As Integer) As String
dim as string d
d = str(i)
if i<10000 then d = "0" + d
if i<1000 then d = "0" + d
if i<100 then d = "0" + d
if i<10 then d = "0" + d
function = d
end function
function px99999(byval i As Integer) As String
dim as string d
d = str(i)
if i<10000 then d = " " + d
if i<1000 then d = " " + d
if i<100 then d = " " + d
if i<10 then d = " " + d
function = d
end function
dim Shared as string ink, stemp, cmd_write, cmd_write_page, cmd_saddr, cmd_read, cmd_read_page, cmd_reset, cmd_null16, cmd_prefix, com_num, cmd_setp, com_port
dim Shared as ubyte ser_byte
dim Shared as integer gpu_addr, gpu_addr_now, ser_rxbuf, x, y, z, c, hp, undobase, MAX_MEM
dim shared as integer mx,my,mb,mw,mwl,mbl,mwd,mcx1,mcy1,mcz,mcx2,mcy2,mcx,mcy, edit_mode, edit_pos
dim shared as integer m2cx1,m2cy1,m2cz,m2cx2,m2cy2,m2cx,m2cy,edit_col
Dim Shared read_buffer (0 To MAX_MEM_ALLOC) As Ubyte
Dim Shared undo_buffer (0 To 256) As Ubyte
Dim Shared verify_buffer (0 To COM_CACHE) As Ubyte
Dim Shared phex8 (0 To 255) As string
Dim Shared asc_str (0 To 255) As string
Dim Shared bin_str (0 To 255) As string
Dim Shared in_port (0 to 4) As Ubyte
Dim Shared out_port (0 to 3) As Ubyte
dim Shared as integer mstart,mstop,mpos
Dim Shared com_buffer (0 To 16) As Ubyte
dim shared as integer com_addr, com_bytepos, com_command, com_timer, com_txp, com_rxp, com_sxp, com_rx_error, com_tx_error
dim shared as string d_filename
dim shared as integer d_membase, d_memsize
ScreenRes 720,560,16,0,0
cmd_null16 = chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0)
cmd_prefix = chr(128) + chr(255) + chr(255) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0) + chr(0)
cmd_write = "Writ" :rem The next 3 BYTEs defines the base address and the next byte defines the number of bytes to write
cmd_read = "Read" :rem The next 3 BYTEs defines the base address and the next byte defines the number of bytes to read
cmd_write_page = "WriP" :rem The next 3 BYTEs defines the base address and the next byte defines the number of 256 bytes to write
cmd_read_page = "ReaP" :rem The next 3 BYTEs defines the base address and the next byte defines the number of 256 bytes to read
cmd_setp = "SetP" :rem The next 3 BYTEs defines the base address and the next byte defines the number of bytes to read
cmd_reset = "ResetNow"
cmd_reset = cmd_null16 + cmd_prefix + cmd_reset + cmd_reset: Rem this is the full reset sequence
asc_str(0) = " 0 0 0 0"
asc_str(1) = " 0 0 0 1"
asc_str(2) = " 0 0 1 0"
asc_str(3) = " 0 0 1 1"
asc_str(4) = " 0 1 0 0"
asc_str(5) = " 0 1 0 1"
asc_str(6) = " 0 1 1 0"
asc_str(7) = " 0 1 1 1"
asc_str(8) = " 1 0 0 0"
asc_str(9) = " 1 0 0 1"
asc_str(10) = " 1 0 1 0"
asc_str(11) = " 1 0 1 1"
asc_str(12) = " 1 1 0 0"
asc_str(13) = " 1 1 0 1"
asc_str(14) = " 1 1 1 0"
asc_str(15) = " 1 1 1 1"
MAX_MEM = MAX_MEM_ALLOC
for x=0 to 255
bin_str(x) = asc_str(int(x/16)) + asc_str(x and 15) + " "
next x
for x=0 to 255
phex8(x) = hex(int(x/16)) + hex((x and 15))
read_buffer(x) = x:rem fill dummy data
asc_str(x) = "."
if x<>7 and x<>0 and x<>32 and x<>13 and not (x>=8 and x<=10) then asc_str(x)=chr(x): rem remove screen bell sound
next x
' This dummy fills a 16bit wide counter into memory
'for x=0 to MAX_MEM/2-1
'read_buffer(x*2) = int(x/256) and 255:rem fill dummy data
'read_buffer(x*2+1) = int(x) and 255:rem fill dummy data
'next x
for x=0 to MAX_MEM-1
read_buffer(x) = 0
next x
close_com()
print_setup()
' Wait for keyboard input
getmouse mx,my,mw,mb:mbl=mb:mwl=mw
ink=inkey
ink=inkey
ink=""
while (ink<>chr(27) or edit_mode=1) and asc(mid(ink,2,1))<>107
ink=inkey
do_commands()
wend : ' program quit
close #1
end
sub print_setup()
color rgb(224,224,64),rgb(0,0,0)
cls
locate 52,1:
? "Keys: PGUP & PGDN & Arrows = Scroll Up / Down Home & End = Top and Bottom of memory"
? " +CTRL+ = Scroll faster ESC = Quit"
? " [r] = re-read entire GPU ram [w] = write entire GPU ram"
?
? " Click mouse to select either hex numbers or ASCII text. Use +/-, Wheel mouse,"
? " click on the the binary bits or decimal #, or type to edit the memory."
? " [CTRL-z] To undo changes. Hit ENTER/RMB/ESC to exit editing memory.";
locate 39,60:?"SHIFT-S Save Debug_quick_file1"
locate 40,60:?"SHIFT-L Load Debug_quick_file1"
locate 41,60:?"CTRL -S Save Debug_quick_file2"
locate 42,60:?"CTRL -L Load Debug_quick_file2"
locate 43,60:?"[l] Load Binary"
locate 44,60:?"[s] Save Binary"
locate 46,60:?"[m] Save Quartus .mif file"
locate 47,60:?"[M] Save 16bit Quartus .mif"
locate 48,60:?"CTRL -R RESET GPU"
locate 49,60:?"CTRL -O Open RS232 com port"
locate 50,60:?"CTRL -C Close RS232 com port"
for y=0 to 8
color_rg(1,y+62,1 ):? ,,," ";
color_rg(2,y+62,45):? ,,," ";
next y
color rgb(224,224,224),rgb(0,0,0)
if com_num<>"" then color_rg(0,60,1):? com_port;
if com_num="" then color_rg(2,60,1):? " Com Disabled! File hex editor mode. ";
end sub
sub do_commands()
if ink="" and edit_mode=0 then read_gpu(gpu_addr,256)
if ink="" and edit_mode=1 then write_gpu(gpu_addr,256)
if ink="" then com_setport()
if len(ink)<>0 and COM_VERBOSE=2 then locate 60,32:? len(ink),asc(ink),asc(mid(ink,2,1)),,
if SLEEP_TIME<>0 then sleep SLEEP_TIME,0: REM helps allow allow system multitasking
if edit_mode = 0 then
z= asc(mid(ink,1,1))
if ink="L" then load_file("Debug_quick_file1.bin",0,MAX_MEM)
if ink="S" then save_file("Debug_quick_file1.bin",0,MAX_MEM)
if z = 12 then load_file("Debug_quick_file2.bin",0,MAX_MEM)
if z = 19 then save_file("Debug_quick_file2.bin",0,MAX_MEM)
if ink="l" then put_undo():load_dialog()
if ink="s" then save_dialog()
if ink="m" then save_mif()
if ink="M" then save_mif16()
if ink="r" then read_gpu_all(0,MAX_MEM)
if ink="w" then write_gpu_all(0,MAX_MEM)
if asc(mid(ink,1,1))=3 then close_com()
if asc(mid(ink,1,1))=15 then open_com()
if asc(mid(ink,2,1))=71 then gpu_addr=0
if asc(mid(ink,2,1))=79 then gpu_addr=(MAX_MEM-256)
if asc(mid(ink,2,1))=132 then gpu_addr=gpu_addr-1024
if asc(mid(ink,2,1))=118 then gpu_addr=gpu_addr+1024
if asc(mid(ink,2,1))=73 then gpu_addr=gpu_addr-256
if asc(mid(ink,2,1))=81 then gpu_addr=gpu_addr+256
if asc(mid(ink,2,1))=72 then gpu_addr=gpu_addr-16
if asc(mid(ink,2,1))=80 then gpu_addr=gpu_addr+16
if asc(mid(ink,2,1))=141 then gpu_addr=gpu_addr-64
if asc(mid(ink,2,1))=145 then gpu_addr=gpu_addr+64
z= asc(mid(ink,1,1))
if z=26 then get_undo()
if z=18 then for x=0 to 32:? #1,cmd_null16; :next x: ?#1,cmd_reset; : REM Reset the GPU
end if
if edit_mode = 1 then : REM Editing values
z= asc(mid(ink,1,1))
if z=13 or z=27 or mb=2 then ink="":edit_mode=0: REM Leaving edit mode
if z=26 then get_undo: REM Leaving edit mode
if z>31 and edit_pos=1 and z<128 then ascii_enter()
if (z>=48 and z<=57) or (z>=asc("a") and z<=asc("f")) and edit_pos = 0 then hex_enter()
if ink="+" and edit_pos=0 then edit16(1)
if ink="-" and edit_pos=0 then edit16(-1)
if asc(mid(ink,2,1))=72 then inc_cursor(0,-1)
if asc(mid(ink,2,1))=80 then inc_cursor(0,1)
if asc(mid(ink,2,1))=75 then inc_cursor(-1,0)
if asc(mid(ink,2,1))=77 then inc_cursor(1,0)
end if
mbl=mb
getmouse mx,my,mw,mb
if mb=-1 then mbl=mb
if mb<>-1 and mbl=-1 then mwl=mw:mbl=0
if mb<>-1 then mwd=mwl-mw:mwl=mw
if mb=-1 then mwd=0
if COM_VERBOSE=2 then locate 49,1:? mx,my,mw,mb;
if edit_mode=0 and my<400 then gpu_addr=gpu_addr + (mwd*16) : rem mouse wheel scroll
if gpu_addr<0 then gpu_addr=0
if gpu_addr>(MAX_MEM-256) then gpu_addr=(MAX_MEM-256)
if edit_mode=1 and my<400 then read_buffer(mcz) = read_buffer(mcz) + mwd : REM Mouse wheel edit
print_hex()
print_mouse()
print_ports()
end sub
sub print_ports()
color_rg(1,1,1):? " RS232 Address Size = ";in_port(4);" = ";(2^in_port(4));" bytes.";
for y=0 to 3
dim as string d
d = " In" + str(y) + "[7:0]=8'b" + bin_str(in_port(y)) + "=8'h" + phex8(in_port(y)) + "=8'd" + p999(in_port(y)) + ". "
color_rg(1,y*2+63,1):? d;
d = " Out" + str(y) + "[7:0]=8'b" + bin_str(out_port(y)) + "=8'h" + phex8(out_port(y)) + "=8'd" + p999(out_port(y)) + ". "
color_rg(2,y*2+63,45):? d;
click_binary(60, y*2+63, y)
next y
end sub
Sub edit16( i as integer )
x = read_buffer(int(mcz/2)*2)*256 + read_buffer(int(mcz/2)*2+1)
x=x+i:x=x and 65535
read_buffer(int(mcz/2)*2) = int(x/256)
read_buffer(int(mcz/2)*2+1) = x and 255
end sub
Sub inputhex( i as string )
dim as string i1
box(7):z=-1
color_rg(7,TXT_BOX_y+0,TXT_BOX_x):? i;
input i1
if i1<>"" then
if mid(i1,1,2)="0x" then i1=mid(i1,3,len(i1)-2)
if mid(i1,1,1)="$" then i1=mid(i1,2,len(i1)-1)
i1 = "&H" + i1
z= val(i1)
end if
box(0)
end sub
Sub inputdec( i as string )
dim as string i1
box(7):z=-1
color_rg(7,TXT_BOX_y+0,TXT_BOX_x):? i;
input i1
if i1<>"" then
if mid(i1,1,2)="0x" then i1=mid(i1,3,len(i1)-2):i1 = "&H" + i1
if mid(i1,1,1)="$" then i1=mid(i1,2,len(i1)-1):i1 = "&H" + i1
z= val(i1)
endif
box(0)
end sub
Sub box( i as integer )
for y=0 to 10
color_rg(i,TXT_BOX_y-1+y,TXT_BOX_x-1):?" ";
next y
end sub
'dim shared as string d_filename
'dim shared as integer d_membase, d_memsize
Sub save_dialog()
file_dialog("Save binary:",".bin")
if d_filename<>"" then save_file(d_filename,d_membase,d_memsize)
box(0)
end sub
Sub load_dialog()
file_dialog("Load Binary:",".bin")
if d_filename<>"" then load_file(d_filename,d_membase,d_memsize)
box(0)
end sub
Sub save_mif()
dim as integer mifpos
file_dialog("Save a Quartus .mif (Memory Initialization File):",".mif")
if d_filename<>"" then
OPEN d_filename FOR OUTPUT AS #2
PRINT #2, "-- Generated by BrianHG's RS232_Debugger hex editor."
PRINT #2, ""
PRINT #2, "WIDTH=8;"
PRINT #2, "DEPTH=";d_memsize;";"
PRINT #2, ""
PRINT #2, "ADDRESS_RADIX=UNS;"
PRINT #2, "DATA_RADIX=UNS;"
PRINT #2, ""
PRINT #2, "CONTENT BEGIN"
for x=d_membase to d_membase+d_memsize-1
?#2, mifpos;" : ";read_buffer(x);";"
mifpos=mifpos + 1
next x
PRINT #2, "END;"
close #2
end if
box(0)
end sub
Sub save_mif16()
dim as integer mifpos
file_dialog("Save a Quartus .mif (Memory Initialization File):",".mif")
if d_filename<>"" then
OPEN d_filename FOR OUTPUT AS #2
PRINT #2, "-- Generated by BrianHG's RS232_Debugger hex editor."
PRINT #2, ""
PRINT #2, "WIDTH=16;"
PRINT #2, "DEPTH=";int(d_memsize/2);";"
PRINT #2, ""
PRINT #2, "ADDRESS_RADIX=UNS;"
PRINT #2, "DATA_RADIX=UNS;"
PRINT #2, ""
PRINT #2, "CONTENT BEGIN"
for x=d_membase to d_membase+int(d_memsize/2)-1
?#2, mifpos;" : ";int(read_buffer(x*2+1)*256+read_buffer(x*2+0));";"
mifpos=mifpos + 1
next x
PRINT #2, "END;"
close #2
end if
box(0)
open "HW_regs.txt" for output as 2
?#2,"Hardware regs ="
for y=0 to 7
?#2,"A(";
for x=0 to 30
?#2,read_buffer(y*32+x);",";
next x
?#2,read_buffer(y*32+x);")"
next y
close #2
end sub
Sub file_dialog( i as string, fn as string )
dim as string i1,i2,i3
dim as integer mst,mlen,errd,hexin
box(7):z=0
color_rg(7,TXT_BOX_y+0,TXT_BOX_x):? i;
color_rg(7,TXT_BOX_y+1,TXT_BOX_x):? "Enter [filename],[addr start],[data length]:"
color_rg(7,TXT_BOX_y+2,TXT_BOX_x):input i1,i2,i3
hexin=0
if mid(i2,1,2)="0x" then i2=mid(i2,3,len(i2)-2):i2 = "&H" + i2:hexin=1
if mid(i2,1,1)="$" then i2=mid(i2,2,len(i2)-1):i2 = "&H" + i2:hexin=1
if mid(i3,1,2)="0x" then i3=mid(i3,3,len(i3)-2):i3 = "&H" + i3
if mid(i3,1,1)="$" then i3=mid(i3,2,len(i3)-1):i3 = "&H" + i3
mst=val(i2):mlen=val(i3)
if len(i1)>4 and mid(i1,len(i1)-3,1)<>"." then i1=i1+fn
if len(i1)<>0 and len(i1)<5 then i1=i1+fn
d_filename = ""
d_membase = 0
d_memsize = 0
errd=0
if mst >= MAX_MEM or mlen > MAX_MEM then errd=1
if mlen=0 then mlen = MAX_MEM-mst
if mst+mlen > MAX_MEM or errd=1 then errd=1:color_rg(2,TXT_BOX_y+5,TXT_BOX_x):?"Address out of range error.";:color_rg(2,TXT_BOX_y+6,TXT_BOX_x):?"Press any key to continue.";:sleep
if i1<>"" and errd=0 then
color_rg(7,TXT_BOX_y+4,TXT_BOX_x):? i;" ";i1;"."
color_rg(7,TXT_BOX_y+5,TXT_BOX_x)
if hexin = 1 then ?"from addr $";phex24(mst);" to $";phex24(mst+mlen-1);".";
if hexin = 0 then ?"from addr";mst;" to";mst+mlen-1;".";
color_rg(2,TXT_BOX_y+7,TXT_BOX_x):?"Proceede? [Y/N]"
fn="":While (fn<>"Y" and fn<>"N" and fn<>chr(27) and fn<>chr(255)):fn=ucase(inkey):sleep 10,0:wend
d_filename = ""
if fn="Y" then d_filename=i1:d_membase=mst:d_memsize=mlen
end if
end sub
Sub save_file(fname as string, start as integer, size as integer)
color rgb(255,255,255),rgb(0,0,255)
locate 60,32:? " SAVING > ";fname;" < ";
color_rg(0,0,0)
'read_gpu_all(start,size)
read_gpu_all(0,MAX_MEM)
open fname For Binary Access Write As 2
put #2,,read_buffer(start),size
close #2
end sub
Sub load_file(fname as string, start as integer, size as integer)
if size+start > MAX_MEM then size = MAX_MEM-start
open fname For Binary Access Read As 2
color rgb(255,255,255),rgb(0,0,255)
locate 60,32:? " LOADING > ";fname;" < With";lof(2);" bytes.";
color_rg(0,0,0)
if lof(2)>0 then
if lof(2)<size then size=lof(2)
if size+start>MAX_MEM then size=MAX_MEM-start
if size>0 then get #2,,read_buffer(start),size
end if
if lof(2)<1 then
box(2)
color_rg(7,TXT_BOX_y+1,TXT_BOX_x):?" Cannot load file."
color_rg(7,TXT_BOX_y+3,TXT_BOX_x):?" Press any key to continue."
sleep
box(0)
end if
close #2
'write_gpu_all(start,size)
write_gpu_all(0,MAX_MEM)
end sub
' *****************************************************
' ******************* handle RS232 communications
' *****************************************************
' ******************* Open and close com port
' *****************************************************
Sub open_com()
close #1
box(7)
color_rg(7,TXT_BOX_y+0,TXT_BOX_x):? "Note that opening a valid com will replace the"
color_rg(7,TXT_BOX_y+1,TXT_BOX_x):? "current memory on display with the contents of"
color_rg(7,TXT_BOX_y+2,TXT_BOX_x):? "the RS232_Debugger hardware."
color_rg(7,TXT_BOX_y+3,TXT_BOX_x):? "Press ";:color_rg(2,0,0):?"[ENTER]";:color_rg(7,0,0):?" to abort.";
color_rg(7,TXT_BOX_y+5,TXT_BOX_x):? "Enter Com# ";:input com_num
com_port="COM"+com_num+":921600,N,8,1,CS,DS,BIN,DT"
if com_num<>"" then
box(7)
color_rg(7,TXT_BOX_y+0,TXT_BOX_x):? "Opening com:"
color_rg(7,TXT_BOX_y+2,TXT_BOX_x):? com_port;
OPEN COM com_port For Binary Access AS 1
?#1,chr(0); : rem Must tx at least 1 character
in_port(4)=0:com_setport():in_port(4)=0:com_setport() : rem get ADDR size, 2 attempts
end if
if in_port(4)=0 and com_num<>"" then
color_rg(2,TXT_BOX_y+4,TXT_BOX_x):? "Opening COM";com_num;" has not connected";
color_rg(2,TXT_BOX_y+5,TXT_BOX_x):? "to a RS232 Debugger peripheral.";
color_rg(2,TXT_BOX_y+6,TXT_BOX_x):? "Entering COM debug state.";
color_rg(2,TXT_BOX_y+8,TXT_BOX_x):? "Use CTRL-O / CTRL-C to change COM port.";
rem com_num=""
sleep
rem close #1
end if
if com_num<>"" and in_port(4)>7 then
MAX_MEM = 2^in_port(4)
if MAX_MEM>MAX_MEM_ALLOC then MAX_MEM = MAX_MEM_ALLOC
color_rg(7,TXT_BOX_y+4,TXT_BOX_x):? "Received RS232_Debugger address size of:";
color_rg(7,TXT_BOX_y+6,TXT_BOX_x):? in_port(4);" which =";MAX_MEM;" bytes of ram.";
color_rg(7,TXT_BOX_y+8,TXT_BOX_x):? "Press any key to begin editing memory.";
if MAX_MEM > MAX_MEM_ALLOC then MAX_MEM = MAX_MEM_ALLOC
sleep 5000
gpu_addr=0:read_gpu_all(0,MAX_MEM)
end if
print_setup()
end sub
Sub close_com()
close #1
box(7)
color_rg(7,TXT_BOX_y+0,TXT_BOX_x):? "Closed COM";com_num;".";
color_rg(7,TXT_BOX_y+2,TXT_BOX_x):? "Press any key to enter file hex editor mode."
color_rg(7,TXT_BOX_y+4,TXT_BOX_x):? "Use CTRL-O to open a new com port at any time."
color_rg(7,TXT_BOX_y+6,TXT_BOX_x):? "Use CTRL-C to close the com port and enter"
color_rg(7,TXT_BOX_y+7,TXT_BOX_x):? " file hext editor mode."
com_num=""
MAX_MEM = MAX_MEM_ALLOC
gpu_addr=0
sleep 4000
print_setup()
end sub
' *****************************************************
' ******************* handle RS232 communications
' *****************************************************
' ******************* Read and Write All
' *****************************************************
Sub read_gpu_all(mbase as integer, msize as integer)
if msize > COM_CACHE then
for mpos=mbase to msize-1 step COM_CACHE
read_gpu(mpos,COM_CACHE)
next mpos
end if
if msize <= COM_CACHE then read_gpu(mpos,msize)
end sub
Sub write_gpu_all(mbase as integer, msize as integer)
if msize > COM_CACHE then
for mpos=mbase to msize-1 step COM_CACHE
write_gpu(mpos,COM_CACHE)
next mpos
end if
if msize <= COM_CACHE then write_gpu(mpos,msize)
end sub
' *****************************************************
' ******************* handle RS232 communications
' *****************************************************
' ******************* READ
' *****************************************************
Sub read_gpu(mbase as integer, msize as integer)
if com_num<>"" then
y=45:if COM_VERBOSE=1 then for x=0 to 3:color_rg(0,x+y,1):? " ",,:next x
com_rxp=com_rxp+1:com_rxp=com_rxp and 8191
color_rg(1,y,1):?" Com read #" ;px9999(com_rxp);" Address $";phex24(mbase);" with ";px9999(msize);" bytes. ";
?#1,cmd_null16;
if COM_FLUSH=1 then
if COM_VERBOSE=1 then color_rg(1,y+1,1):?" Flushing GPU. ";
for x=0 to 16
?#1,cmd_null16;
next x
endif
com_timer = timer*100 + COM_PRE_TIMEOUT
if COM_WAIT=1 and COM_PRE_TIMEOUT>0 then
if COM_VERBOSE=1 then color_rg(1,y+1,1):?" Waiting for flush. ";
while (loc(1)>0 or com_timer>timer*100 )
if loc(1)>0 then get #1,,com_buffer(0),1:com_timer = timer*100 + COM_PRE_TIMEOUT
wend
end if
if msize < 256 then
stemp = chr(int(mbase/65536) and 255) + chr(int(mbase/256) and 255) + chr(mbase and 255) + chr(msize-1)
stemp = cmd_read + stemp
end if
if msize >255 then
stemp = chr(int(mbase/65536) and 255) + chr(int(mbase/256) and 255) + chr(mbase and 255) + chr(int(msize/256)-1)
stemp = cmd_read_page + stemp
end if
if COM_VERBOSE=1 then color_rg(1,y+2,1):?" Sending read command. ";
?#1,cmd_prefix;stemp;stemp;
com_timer = timer*100 + COM_POST_TIMEOUT
if COM_VERBOSE=1 then color_rg(1,y+3,1):?" Waiting for response. ";
while (loc(1)<msize and com_timer>timer*100 )
sleep 1,0
wend
z=loc(1)
if z<msize and z<257 then
color_rg(2,y+3,1):?" Error, read #";px9999(com_rxp);" received";px9999(loc(1));" bytes of";px9999(msize);". ";
While ( loc(1)>0 )
get #1,,com_buffer(0),1
wend
end if
if z>msize then
color_rg(2,y+3,1):?" Error, read #";px9999(com_rxp);" received";px9999(loc(1));" bytes of ";px9999(msize);". ";
While ( loc(1)>0 )
get #1,,com_buffer(0),1
wend
end if
if z=msize then
get #1,,read_buffer(mbase),z
if COM_VERBOSE=1 then color_rg(1,y+3,1):?" Read #";px9999(com_rxp);" was successfull. ";
endif
end if
end sub
' *****************************************************
' ******************* handle RS232 communications
' *****************************************************
' ******************* WRITE
' *****************************************************
Sub write_gpu(mbase as integer, msize as integer)
if com_num<>"" then
y=45:if COM_VERBOSE=1 then for x=0 to 3:color_rg(0,x+y,1):? " ",,:next x
com_txp=com_txp+1:com_txp=com_txp and 8191
color_rg(2,y,1):?" Com write #" ;px9999(com_txp);" Address $";phex24(mbase);" with";px9999(msize);" bytes. ";
?#1,cmd_null16;
if COM_FLUSH=1 then
if COM_VERBOSE=1 then color_rg(1,y+1,1):?" Flushing GPU. ";
for x=0 to 16
?#1,cmd_null16;
next x
endif
com_timer = timer*100 + COM_PRE_TIMEOUT
if COM_WAIT=1 and COM_PRE_TIMEOUT>0 then
if COM_VERBOSE=1 then color_rg(1,y+1,1):?" Waiting for flush. ";
while (loc(1)>0 or com_timer>timer*100 )
if loc(1)>0 then get #1,,com_buffer(0),1:com_timer = timer*100 + COM_PRE_TIMEOUT
wend
end if
if msize < 256 then
stemp = chr(int(mbase/65536) and 255) + chr(int(mbase/256) and 255) + chr(mbase and 255) + chr(msize-1)
stemp = cmd_write + stemp
end if
if msize >255 then
stemp = chr(int(mbase/65536) and 255) + chr(int(mbase/256) and 255) + chr(mbase and 255) + chr(int(msize/256)-1)
stemp = cmd_write_page + stemp
end if
if COM_VERBOSE=1 then color_rg(1,y+2,1):?" Sending write command. ";
?#1,cmd_prefix;stemp;stemp;
if COM_VERBOSE=1 then color_rg(1,y+2,1):?" Sending write data. ";
put #1,,read_buffer(mbase),msize
com_timer = timer*100 + COM_POST_TIMEOUT
if COM_VERBOSE=1 then color_rg(1,y+3,1):?" Waiting for write data echo. ";
while (loc(1)<msize and com_timer>timer*100 )
wend
z=loc(1)
if z<msize and z<257 then
color_rg(2,y+3,1):?" Error, write #";px9999(com_txp);" verify received ";px9999(loc(1));" bytes of";px9999(msize);". ";
While ( loc(1)>0 )
get #1,,com_buffer(0),1
wend
end if
if z>msize then
color_rg(2,y+3,1):?" Error, write #";px9999(com_txp);" verify received ";px9999(loc(1));" bytes of ";px9999(msize);". ";
While ( loc(1)>0 )
get #1,,com_buffer(0),1
wend
end if
if z=msize then
get #1,,verify_buffer(0),z
c=1
for x=0 to z-1
if read_buffer(mbase+x)<>verify_buffer(x) then c=0
next x
if COM_VERBOSE=1 then if c=1 then color_rg(1,y+3,1):?" Write #";px9999(com_txp);" was confirmed. ";
if c=0 then color_rg(2,y+3,1):?" Write #";px9999(com_txp);" verify has data errors. ";:if COM_VERBOSE=1 then show_errors(mbase)
end if
end if
end sub
sub show_errors(q as integer)
for y=0 to 15
for x=0 to 15
c=1
if read_buffer(q+x+y*16)<>verify_buffer(x+y*16) then c=2
color_rg(c, y*2+5+1, x*3+7 ):? " ";phex8(verify_buffer(x+y*16));" ";
next x
next y
end sub
' *****************************************************************
' ******************* handle RS232 communications
' *****************************************************************
' ******************* Set Out0,1,2,3, Read In0,1,2,3,ADDR_SIZE
' *****************************************************************
Sub com_setport()
dim as integer msize
msize = 5
if com_num<>"" then
y=47:if COM_VERBOSE=1 then for x=0 to 3:color_rg(0,x+y,1):? " ",:next x
com_sxp=com_sxp+1:com_sxp=com_sxp and 8191
if COM_VERBOSE=1 then color_rg(1,y,1):?" Com Setport #" ;px9999(com_sxp);". ";
?#1,cmd_null16;
if COM_FLUSH=1 then
if COM_VERBOSE=1 then color_rg(1,y+1,1):?" Flushing COM. ";
for x=0 to 16
?#1,cmd_null16;
next x
endif
com_timer = timer*100 + COM_PRE_TIMEOUT
if COM_WAIT=1 and COM_PRE_TIMEOUT>0 then
if COM_VERBOSE=1 then color_rg(1,y+1,1):?" Waiting for flush. ";
while (loc(1)>0 or com_timer>timer*100 )
if loc(1)>0 then get #1,,com_buffer(0),1:com_timer = timer*100 + COM_PRE_TIMEOUT
wend
end if
stemp = chr(out_port(0)) + chr(out_port(1)) + chr(out_port(2)) + chr(out_port(3))
stemp = cmd_setp + stemp
if COM_VERBOSE=1 then color_rg(1,y+1,1):?" Sending Set Port Command. ";
?#1,cmd_prefix;stemp;stemp;
com_timer = timer*100 + COM_POST_TIMEOUT
if COM_VERBOSE=1 then color_rg(1,y+2,1):?" Waiting for response. ";
while (loc(1)<msize and com_timer>timer*100 )
sleep 1,0
wend
z=loc(1)
if z<msize and z<257 then
color_rg(2,y+2,1):?" Error, read #";px9999(com_sxp);". Received ";px9999(loc(1));" bytes of ";px9999(msize);".";
While ( loc(1)>0 )
get #1,,com_buffer(0),1
wend
end if
if z>msize then
color_rg(2,y+2,1):?" Error, read #";px9999(com_sxp);". Received";px9999(loc(1));" bytes of ";px9999(msize);".";
While ( loc(1)>0 )
get #1,,com_buffer(0),1
wend
end if
if z=msize then
get #1,,in_port(0),z
if COM_VERBOSE=1 then color_rg(1,y+2,1):?" Setport #";px9999(com_sxp);" was successfull.";
endif
end if
end sub
' *****************************************************
' ******************* End of handle RS232 communications
' *****************************************************
sub put_undo()
undobase=gpu_addr
for x=0 to 255
undo_buffer(x)=read_buffer(x+gpu_addr)
next x
end sub
sub get_undo()
for x=0 to 255
read_buffer(x+undobase)=undo_buffer(x)
next x
print_dec()
end sub
sub hex_enter()
z=-1
c=asc(ink)
if c>=48 and c<=57 then z=c-48
if c>=asc("a") and c<=asc("f") then z=c-asc("a")+10
if z<>-1 and hp=0 then read_buffer(mcz)=(read_buffer(mcz) and 15) + z*16:hp=1
if z<>-1 and hp=2 then read_buffer(mcz)=(read_buffer(mcz) and 240) + z
print_dec()
if hp=2 then hp=0:inc_cursor(1,0)
if hp=1 then hp=2
end sub
sub ascii_enter()
read_buffer(mcz) = asc(ink)
print_dec()
inc_cursor(1,0)
print_dec()
end sub
sub inc_cursor(xofs as byte, yofs as byte)
mcx1=mcx1+xofs
mcy1=mcy1+yofs
if mcx1>15 then mcx1=0:mcy1=mcy1+1
if mcx1<0 then mcx1=15:mcy1=mcy1-1
if mcy1>15 then mcy1=mcy1-1:if xofs=1 then mcx1=15:REM UNDO BUFFER BUG gpu_addr=gpu_addr+16:if gpu_addr>(MAX_MEM-256) then gpu_addr=(MAX_MEM-256) Rem rend of screen
if mcy1<0 then mcy1=mcy1+1:if xofs=-1 then mcx1=0
mcz=gpu_addr+mcy1*16+mcx1
print_dec()
end sub
sub print_hex()
c=1:if edit_mode=1 and edit_pos=0 then c=2
color_rg(c, 3 , 1 ):? " HEX +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F ":? " ";
for y=0 to 15
z=gpu_addr+y*16:gpu_printadr()
for x=0 to 15
locate y*2+5,x*3+7:? " ";phex8(read_buffer(z+x));" ";
next x
for x=0 to 15
locate y*2+5,x*2+57:? " ";
locate y*2+5,x*2+57:? " ";asc_str(read_buffer(z+x));
next x
next y
c=1:if edit_mode=1 and edit_pos=1 then c=2
color_rg(c, 3 , 57 ):? " ASCII ";
for y=3 to 36:locate y,90:?" ";
next y
color_rg(0,0,0)
end sub
sub gpu_printadr()
color_rg(c, y*2+5 , 1 ):? phex24(z)
? " ";
color_rg(0,0,0)
end sub
sub print_mouse()
const ADDRhy = 38
const ADDRdy = 40
const ADDRx1 = 1
const ADDRx2 = 24
const datbiny = 38
const datdec8y = 40
const datdec16y = 42
const datdecx1 = 27
const datdecx2 = 46
const datbin2 = 58
const datbinx128 = 43
const datbinx64 = 45
const datbinx32 = 47
const datbinx16 = 49
const datbinx8 = 51
const datbinx4 = 53
const datbinx2 = 55
const datbinx1 = 57
edit_col=0
if edit_mode = 0 then
m2cx = (mx+4)/8
m2cy = (my+4)/8
if m2cy = ADDRhy and m2cx >= ADDRx1 and m2cx <= ADDRx2 then edit_col = 1
if m2cy = ADDRdy and m2cx >= ADDRx1 and m2cx <= ADDRx2 then edit_col = 2
if edit_col=1 and mb=1 then inputhex("Enter new hex address:"):if z>0 then gpu_addr=z and 1048560
if edit_col=2 and mb=1 then inputdec("Enter new decimal address:"):if z>0 then gpu_addr=z and 1048560
if mx<450 then
mcx = (mx-64)/24
mcy = (my-34)/16
if mcx>=0 and mcx<16 and mcy>=0 and mcy<16 then
mcx1=mcx:mcy1=mcy
mcz=gpu_addr+mcy1*16+mcx1
if mb = 1 then edit_mode=1:edit_pos=0:put_undo()
end if
end if
if mx>450 then
mcx = (mx-459)/16
mcy = (my-34)/16
if mcx>=0 and mcx<16 and mcy>=0 and mcy<16 then
mcx1=mcx:mcy1=mcy
mcz=gpu_addr+mcy1*16+mcx1
if mb = 1 then edit_mode=1:edit_pos=1:put_undo()
end if
end if
end if :rem EDIT mode 0
if edit_mode = 1 then
m2cx = (mx+4)/8
m2cy = (my+4)/8
'locate m2cy,m2cx:? m2cx;
if m2cy = datbiny and m2cx >= datdecx1 and m2cx <= datbin2 then edit_col = 3
if m2cy = datdec8y and m2cx >= datdecx1 and m2cx <= datdecx2 then edit_col = 4
if m2cy = datdec16y and m2cx >= datdecx1 and m2cx <= datdecx2 then edit_col = 5
if edit_col=4 and mb=1 then inputdec("Enter new data byte:"):if z>0 then read_buffer(mcz)=z and 255
if edit_col=5 and mb=1 then inputdec("Enter new data for 16bit byte:"):if z>0 then z=z and 65535:read_buffer(int(mcz/2)*2)=int(z/256):read_buffer(int(mcz/2)*2+1)=z and 255
if m2cx = datbinx128 and edit_col=3 and mbl=0 and mb=1 then read_buffer(mcz)=read_buffer(mcz) xor 128
if m2cx = datbinx64 and edit_col=3 and mbl=0 and mb=1 then read_buffer(mcz)=read_buffer(mcz) xor 64
if m2cx = datbinx32 and edit_col=3 and mbl=0 and mb=1 then read_buffer(mcz)=read_buffer(mcz) xor 32
if m2cx = datbinx16 and edit_col=3 and mbl=0 and mb=1 then read_buffer(mcz)=read_buffer(mcz) xor 16
if m2cx = datbinx8 and edit_col=3 and mbl=0 and mb=1 then read_buffer(mcz)=read_buffer(mcz) xor 8
if m2cx = datbinx4 and edit_col=3 and mbl=0 and mb=1 then read_buffer(mcz)=read_buffer(mcz) xor 4
if m2cx = datbinx2 and edit_col=3 and mbl=0 and mb=1 then read_buffer(mcz)=read_buffer(mcz) xor 2
if m2cx = datbinx1 and edit_col=3 and mbl=0 and mb=1 then read_buffer(mcz)=read_buffer(mcz) xor 1
end if : rem edit mode 1
if mx<>-1 then print_dec()
end sub
sub click_binary(xp as integer, yp as integer, eb as Ubyte)
m2cx = (mx+4)/8
m2cy = (my+4)/8
'locate m2cy,m2cx:? m2cx;m2cy;
if m2cy=yp and m2cx+2 > xp and m2cx-16 < xp then
color_rg(7,yp,xp-1):? bin_str(out_port(eb));
out_port(eb)=out_port(eb) + mwd
if m2cx = (xp + 0 ) and mbl=0 and mb=1 then out_port(eb)=out_port(eb) xor 128
if m2cx = (xp + 2 ) and mbl=0 and mb=1 then out_port(eb)=out_port(eb) xor 64
if m2cx = (xp + 4 ) and mbl=0 and mb=1 then out_port(eb)=out_port(eb) xor 32
if m2cx = (xp + 6 ) and mbl=0 and mb=1 then out_port(eb)=out_port(eb) xor 16
if m2cx = (xp + 8 ) and mbl=0 and mb=1 then out_port(eb)=out_port(eb) xor 8
if m2cx = (xp + 10) and mbl=0 and mb=1 then out_port(eb)=out_port(eb) xor 4
if m2cx = (xp + 12) and mbl=0 and mb=1 then out_port(eb)=out_port(eb) xor 2
if m2cx = (xp + 14) and mbl=0 and mb=1 then out_port(eb)=out_port(eb) xor 1
end if
end sub
sub print_dec()
color_rg(0, mcy1*2+5, mcx1*2+57):? ">";
color_rg(4, 0 , 0 ):? asc_str(read_buffer(mcz));
color_rg(5, mcy1*2+5, mcx1*3+7 ):? " ";phex8(read_buffer(mcz));" ";
z=3:if edit_col=1 then z=7
color_rg(z, 38 , 1 ):? "Address Hex :";
z=0:if edit_col=1 then z=7
color_rg(z, 0 , 0 ):? " ";phex24(mcz); " ";
z=3:if edit_col=2 then z=7
color_rg(z, 40 , 1 ):? "Address Decimal :";
z=0:if edit_col=2 then z=7
color_rg(z, 0 , 0 ):? mcz,
z=3:if edit_col=3 then z=7
color_rg(z, 38 , 27 ):? "Binary :";
z=0:if edit_col=3 then z=7
color_rg(z, 0 , 0 ):? bin_str(read_buffer(mcz));
z=3:if edit_col=4 then z=7
color_rg(z, 40 , 27 ):? "Decimal :";
z=0:if edit_col=4 then z=7
color_rg(z, 0 , 0 ):? " ";read_buffer(mcz);" ";
z=3:if edit_col=5 then z=7
color_rg(z, 42 , 27 ):? "16bit Decimal :";
y = read_buffer(int(mcz/2)*2)*256 + read_buffer(int(mcz/2)*2+1)
z=0:if edit_col=5 then z=7
color_rg(z, 0 , 0 ):? y;" ";
end sub
sub color_rg( colm as ubyte, yp as ubyte, xp as ubyte )
if xp<>0 and yp<>0 then locate yp,xp
if colm=0 then color rgb(224,224,224),rgb(0,0,0) : REM white text
if colm=1 then color rgb(255,255,255),rgb(32,96,0) : REM Green outline
if colm=2 then color rgb(255,255,255),rgb(128,16,0) : REM Red outline
if colm=3 then color rgb(0,0,0),rgb(224,224,224) : REM Negative white
if colm=4 then color rgb(0,0,0),rgb(255,255,255) : REM Negative white X-bright
if colm=5 then color rgb(192,255,255),rgb(96,48,16) : REM Blue on dark red
if colm=6 then color rgb(192,255,255),rgb(0,224,224) : REM Blue on green
if colm=7 then color rgb(255,255,64),rgb(0,0,128) : REM Blue on red
end sub
|
<reponame>npocmaka/Windows-Server-2003<filename>admin/wmi/wbem/scripting/test/whistler/sysprop/derivation.vbs<gh_stars>10-100
set disk = Getobject ("Winmgmts:win32_logicaldisk")
s = disk.SystemProperties_("__DERIVATION")
For Each c in disk.SystemProperties_("__DERIVATION").Value
WScript.Echo c
Next
|
<gh_stars>10-100
Option Explicit
Main
Sub Main
Dim oCluster
Dim oResource
Dim bPending
Dim sCluster
Set oCluster = CreateObject("MSCluster.Cluster")
sCluster = InputBox( "Cluster to open?" )
oCluster.Open( sCluster )
MsgBox "Cluster Name is " & oCluster.Name
MsgBox "Cluster Version is " & oCluster.Version.BuildNumber
MsgBox "Cluster resource count is " & oCluster.Resources.Count
Set oResource = oCluster.Resources.Item("Dummy")
bpending = oResource.Offline(30)
MsgBox "bPending is " & bPending
End Sub
|
Set SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("Win32_ComputerSystem")
for each System in SystemSet
WScript.Echo System.Caption
WScript.Echo System.PrimaryOwnerName
WScript.Echo System.Domain
WScript.Echo System.SystemType
WScript.Echo System.Description
next
|
Function ICE32()
On Error Resume Next
Set recInfo=Installer.CreateRecord(1)
If Err <> 0 Then
ICE32 = 1
Exit Function
End If
'Give description of test
recInfo.StringData(0)="ICE32" & Chr(9) & "3" & Chr(9) & "ICE32 - Confirms that keys and foreign keys are the same type/size"
Message &h03000000, recInfo
'Give creation data
recInfo.StringData(0)="ICE32" & Chr(9) & "3" & Chr(9) & "Created 07/30/98. Last Modified 10/08/98."
Message &h03000000, recInfo
Set msiDB = Session.Database
Set msiTablesView = msiDB.OpenView("SELECT * FROM `_Validation` WHERE `KeyTable` IS NOT NULL")
msiTablesView.Execute
If Err <> 0 Then
recInfo.StringData(0)="ICE32" & Chr(9) & "0" & Chr(9) & "view.Execute_1 API Error"
Message &h03000000, recInfo
ICE32=1
Exit Function
End If
Set msiTablesRecord = msiTablesView.Fetch
Do Until msiTablesRecord Is Nothing
sThisTable = msiTablesRecord.StringData(1)
sThisColumn = msiTablesRecord.StringData(2)
sKeyTables = msiTablesRecord.StringData(6)
'Is this table in the database?
iStat = Database.TablePersistent(sThisTable)
If 1 = iStat Then
If Len(sKeyTables) > 0 Then
iKeyColumn = msiTablesRecord.IntegerData(7)
Set msiForeignView = msiDB.OpenView("SELECT `" & sThisColumn & "` FROM `" & sThisTable & "`")
msiForeignView.Execute
Set msiForeignInfo = msiForeignView.ColumnInfo(1)
iDelim = InStr(sKeyTables & ";", ";")
sKeyTable = Left(sKeyTables & ";", iDelim - 1)
While Len(sKeyTable) > 0
'Is this table in the database?
iStat = Database.TablePersistent(sKeyTable)
If 1 <> iStat Then
recInfo.StringData(0)="ICE32" & Chr(9) & "3" & Chr(9) & sKeyTable & " table is not in database, but is listed in the _Validation table as a foreign key of " & sThisTable & "." & sThisColumn & Chr(9) & "" & Chr(9) & "_Validation"
Message &h03000000, recInfo
Else
Set msiKeyView = msiDB.OpenView("SELECT * FROM `" & sKeyTable & "`")
msiKeyView.Execute
If Err <> 0 Then
recInfo.StringData(0)="ICE32" & Chr(9) & "0" & Chr(9) & "view.Execute_2 API Error in table " & sKeyTable & " Error: " & Installer.LastErrorRecord.StringData(1)
Message &h03000000, recInfo
ICE32=1
Exit Function
End If
Set msiKeyInfo = msiKeyView.ColumnInfo(1)
If LCase(msiKeyInfo.StringData(iKeyColumn)) <> LCase(msiForeignInfo.StringData(1)) Then
recInfo.StringData(0) = "ICE32" & Chr(9) & "1" & Chr(9) & "Possible Mis-Aligned Foreign Keys" & Chr(10) & _
sKeyTable & "." & iKeyColumn & " = " & _
msiKeyInfo.StringData(iKeyColumn) & Chr(10) & _
sThisTable & "." & sThisColumn & " = " & _
msiForeignInfo.StringData(1) & Chr(9) & "" & Chr(9) & "_Validation"
Message &h03000000, recInfo
bDifference = True
End If
End If
iDelim = InStr(sKeyTables, ";")
If iDelim > 0 Then
sKeyTables = Mid(sKeyTables, iDelim + 1)
iDelim = InStr(sKeyTables & ";", ";")
sKeyTable = Left(sKeyTables & ";", iDelim - 1)
Else
sKeyTable = ""
End If
Wend
End If
End If
Set msiTablesRecord = msiTablesView.Fetch
Loop
recInfo.StringData(0) = "ICE32" & Chr(9) & "3" & Chr(9) & "Differences found = " & UCase(CStr(bDifference))
Message &h03000000, recInfo
'Return iesSuccess
ICE32 = 1
Exit Function
End Function
|
Set Args = wscript.Arguments
If Args.Count() > 0 Then
RpName = Args.item(0)
Else
RpName = "Vbscript"
End If
Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")
If (obj.CreateRestorePoint(RpName, 0, 100)) = 0 Then
wscript.Echo "Success"
Else
wscript.Echo "Failed"
End If
|
'//on error resume next
set objArgs = wscript.Arguments
if objArgs.count < 1 then
wscript.echo "Usage format volume"
wscript.quit(1)
end if
fNotDone = True
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: " & Volume.Name
' illustration of how to handle input parameters - not tested
Set objMethod = Volume.Methods_.Item("Format")
Set objInParams = objMethod.InParameters.SpawnInstance_
objInParams.ClusterSize = 4096
objInParams.EnableCompression = False
objInParams.FileSystem = "NTFS"
objInParams.Label = ""
objInParams.QuickFormat = False
Set objSink = WScript.CreateObject("WbemScripting.SWbemSink","SINK_")
Volume.ExecMethodAsync_ objSink, "Format", objInParams
WScript.Echo "method executing..."
while (fNotDone)
wscript.Sleep(1000)
wend
Sub SINK_OnObjectReady(objObject, objAsyncContext)
'WScript.Echo objObject.Name
Result = objObject.ReturnValue
wscript.echo "ObjectReady: Format returned: " & Result & " : " & MapErrorCode("Win32_Volume", "Format", Result)
End Sub
Sub SINK_OnCompleted(intHresult, objError, objContext)
WScript.Echo "OnCompleted: hresult: 0x" & Hex(intHresult)
fNotDone = False
End Sub
Sub SINK_OnProgress(intTotal, intCurrent, strMessage, objContext)
WScript.Echo "OnProgress: " & intCurrent & "/" & intTotal
End Sub
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
|
Option Explicit
Private Declare Function AllocConsole Lib "kernel32.dll" () As Long
Private Declare Function FreeConsole Lib "kernel32.dll" () As Long
'needs a reference set to "Microsoft Scripting Runtime" (scrrun.dll)
Sub Main()
Call AllocConsole
Dim mFSO As Scripting.FileSystemObject
Dim mStdIn As Scripting.TextStream
Dim mStdOut As Scripting.TextStream
Set mFSO = New Scripting.FileSystemObject
Set mStdIn = mFSO.GetStandardStream(StdIn)
Set mStdOut = mFSO.GetStandardStream(StdOut)
mStdOut.Write "Hello world!" & vbNewLine
mStdOut.Write "press enter to quit program."
mStdIn.Read 1
Call FreeConsole
End Sub
|
#define ESCAPE(s)s:Print"ESCAPE("&#s&")"
ESCAPE(Print"#define ESCAPE(s)s:Print""ESCAPE(""&#s&"")""")
|
<filename>Task/Phrase-reversals/VBA/phrase-reversals.vba
Option Explicit
Sub Main_Phrase_Reversals()
Const PHRASE As String = "rosetta code phrase reversal"
Debug.Print "Original String : " & PHRASE
Debug.Print "Reverse String : " & Reverse_String(PHRASE)
Debug.Print "Reverse each individual word : " & Reverse_each_individual_word(PHRASE)
Debug.Print "Reverse order of each word : " & Reverse_the_order_of_each_word(PHRASE)
End Sub
Function Reverse_String(strPhrase As String) As String
Reverse_String = StrReverse(strPhrase)
End Function
Function Reverse_each_individual_word(strPhrase As String) As String
Dim Words, i&, strTemp$
Words = Split(strPhrase, " ")
For i = 0 To UBound(Words)
Words(i) = Reverse_String(CStr(Words(i)))
Next i
Reverse_each_individual_word = Join(Words, " ")
End Function
Function Reverse_the_order_of_each_word(strPhrase As String) As String
Dim Words, i&, strTemp$
Words = Split(strPhrase, " ")
For i = UBound(Words) To 0 Step -1
strTemp = strTemp & " " & Words(i)
Next i
Reverse_the_order_of_each_word = Trim(strTemp)
End Function
|
<reponame>djgoku/RosettaCodeData<filename>Task/99-Bottles-of-Beer/VBA/99-bottles-of-beer.vba
Public Function countbottles(n As Integer, liquid As String) As String
countbottles = IIf(n > 1, Format$(n), IIf(n = 0, "no more", "one")) & " bottle" & IIf(n = 1, "", "s") & " of " & liquid
End Function
Public Sub drink(fullbottles As Integer, Optional liquid As String = "beer")
Static emptybottles As Integer
Debug.Print countbottles(fullbottles, liquid) & " on the wall"
Debug.Print countbottles(fullbottles, liquid)
If fullbottles > 0 Then
Debug.Print "take " & IIf(fullbottles > 1, "one", "it") & " down, pass it around"
Debug.Print countbottles(fullbottles - 1, liquid) & " on the wall"
Debug.Print
emptybottles = emptybottles + 1
drink fullbottles - 1, liquid
Else
Debug.Print "go to the store and buy some more"
Debug.Print countbottles(emptybottles, liquid) & " on the wall"
End If
End Sub
|
<filename>Task/Associative-array-Creation/VBA/associative-array-creation.vba
Option Explicit
Sub Test()
Dim h As Object
Set h = CreateObject("Scripting.Dictionary")
h.Add "A", 1
h.Add "B", 2
h.Add "C", 3
Debug.Print h.Item("A")
h.Item("C") = 4
h.Key("C") = "D"
Debug.Print h.exists("C")
h.Remove "B"
Debug.Print h.Count
h.RemoveAll
Debug.Print h.Count
End Sub
|
Sub Main()
Const bottlesofbeer As String = " bottles of beer"
Const onthewall As String = " on the wall"
Const takeonedown As String = "Take one down, pass it around"
Const onebeer As String = "1 bottle of beer"
Dim bottles As Long
For bottles = 99 To 3 Step -1
Debug.Print CStr(bottles) & bottlesofbeer & onthewall
Debug.Print CStr(bottles) & bottlesofbeer
Debug.Print takeonedown
Debug.Print CStr(bottles - 1) & bottlesofbeer & onthewall
Debug.Print
Next
Debug.Print "2" & bottlesofbeer & onthewall
Debug.Print "2" & bottlesofbeer
Debug.Print takeonedown
Debug.Print onebeer & onthewall
Debug.Print
Debug.Print onebeer & onthewall
Debug.Print onebeer
Debug.Print takeonedown
Debug.Print "No more" & bottlesofbeer & onthewall
Debug.Print
Debug.Print "No" & bottlesofbeer & onthewall
Debug.Print "No" & bottlesofbeer
Debug.Print "Go to the store, buy some more"
Debug.Print "99" & bottlesofbeer & onthewall
End Sub
|
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.MDIForm MDIForm1
BackColor = &H00FFC0C0&
Caption = "Microsoft Fax Server Test Application"
ClientHeight = 6075
ClientLeft = 4485
ClientTop = 4995
ClientWidth = 9600
Icon = "mdiwin.frx":0000
LinkTopic = "MDIForm1"
Begin ComctlLib.Toolbar Toolbar
Align = 1 'Align Top
Height = 420
Left = 0
TabIndex = 0
Top = 0
Width = 9600
_ExtentX = 16933
_ExtentY = 741
ButtonWidth = 635
ButtonHeight = 582
Appearance = 1
_Version = 327682
End
Begin VB.PictureBox Picture1
Align = 1 'Align Top
Height = 495
Left = 0
Picture = "mdiwin.frx":0442
ScaleHeight = 435
ScaleWidth = 9540
TabIndex = 1
Top = 420
Visible = 0 'False
Width = 9600
End
Begin ComctlLib.ImageList ImageList1
Left = 0
Top = 480
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
MaskColor = 12632256
_Version = 327682
End
Begin VB.Menu File
Caption = "&File"
Begin VB.Menu Exit
Caption = "E&xit"
End
End
Begin VB.Menu FaxServer
Caption = "Fax &Server"
Begin VB.Menu Connect
Caption = "&Connect..."
End
Begin VB.Menu Disconnect
Caption = "&Disconnect"
Enabled = 0 'False
End
Begin VB.Menu server_properties
Caption = "&Properties"
Enabled = 0 'False
End
End
Begin VB.Menu Document
Caption = "Document"
Visible = 0 'False
Begin VB.Menu NewDocument
Caption = "&New Fax Document"
End
Begin VB.Menu Send
Caption = "&Send"
Enabled = 0 'False
End
Begin VB.Menu BroadCast
Caption = "&BroadCast"
Enabled = 0 'False
End
Begin VB.Menu DocProp
Caption = "&Properties"
Enabled = 0 'False
End
End
End
Attribute VB_Name = "MDIForm1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Connect_Click()
Connect_Server
End Sub
Private Sub Disconnect_Click()
DisConnect_Server
End Sub
Private Sub DocProp_Click()
Document_Properties
End Sub
Private Sub Exit_Click()
End
End Sub
Private Sub MDIForm_Load()
Set Fax = CreateObject("FaxServer.FaxServer")
Connected = False
Dim imgX As ListImage
Dim btnX As Button
Set imgX = ImageList1.ListImages.Add(, "Connect", Picture1.Picture)
Toolbar.ImageList = ImageList1
Toolbar.Buttons.Add , , , tbrSeparator
Set btnX = Toolbar.Buttons.Add(, "Connect", , tbrDefault, "Connect")
btnX.ToolTipText = "Connect to a Fax Server"
btnX.Description = btnX.ToolTipText
End Sub
Private Sub NewDocument_Click()
New_FaxDocument
End Sub
Private Sub Send_Click()
Send_Document
End Sub
Private Sub server_properties_Click()
server_property
End Sub
Private Sub Toolbar_ButtonClick(ByVal Button As ComctlLib.Button)
If Button.Key = "Connect" Then
If Connected Then
DisConnect_Server
Else
Connect_Server
End If
End If
End Sub
Private Sub Connect_Server()
ConnectDialog.Show 1
If Connected Then
Connect.Enabled = False
Disconnect.Enabled = True
Document.Visible = True
NewDocument.Enabled = True
server_properties.Enabled = True
DeviceListWindow.Show
End If
End Sub
Private Sub DisConnect_Server()
On Error Resume Next
Err.Clear
Fax.Disconnect
If Err.Number <> 0 Then
msg = "Could not disconnect from the fax server"
MsgBox msg, , "Error"
Exit Sub
End If
Unload DeviceListWindow
Unload DeviceWindow
Unload FaxDocument
Connect.Enabled = True
Disconnect.Enabled = False
Connected = False
NewDocument.Enabled = False
Document.Visible = False
server_properties.Enabled = False
End Sub
Private Sub New_FaxDocument()
On Error Resume Next
NewFaxDialog.Show 1
If Err.Number <> 0 Then
msg = "Could not create a fax document"
MsgBox msg, , "Error"
Unload NewFaxDialog
Exit Sub
Else
Send.Enabled = True
BroadCast.Enabled = True
DocProp.Enabled = True
NewDocument.Enabled = False
End If
End Sub
Private Sub Send_Document()
On Error Resume Next
FaxDocument.Send
If Err.Number <> 0 Then
msg = "Could not send document"
MsgBox msg, , "Error"
Send.Enabled = False
BroadCast.Enabled = False
End If
End Sub
Private Sub Document_Properties()
On Error Resume Next
DocProperty.Show 1
If Err.Number <> 0 Then
msg = "Could not get document properties"
MsgBox msg, , "Error"
Unload DocProperty
Exit Sub
Else
Send.Enabled = True
BroadCast.Enabled = True
DocProp.Enabled = True
NewDocument.Enabled = False
End If
If Doc = True Then
NewDocument.Enabled = False
End If
End Sub
Private Sub server_property()
On Error Resume Next
ServerProperty.Show 1
If Err.Number <> 0 Then
msg = "could not get server properties"
MsgBox msg, , "Error"
Unload ServerProperties
Exit Sub
End If
End Sub
|
<filename>v/vbnet.vb
Module FuckYouGithub
Sub Main()
System.Console.WriteLine("Fuck You Github")
End Sub
End Module
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.