Skip to content

Commit d8dd07a

Browse files
committed
Fix variable scoping
1 parent 545a9b7 commit d8dd07a

File tree

4 files changed

+139
-128
lines changed

4 files changed

+139
-128
lines changed

VBScript/02_Upfront_Encapsulated_Code_With_No_Dependencies/TestObjectIsAnyTypeOfInteger.vbs

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
Function TestObjectIsAnyTypeOfInteger(ByRef objToTest)
2-
'region FunctionMetadata ####################################################
1+
Function TestObjectIsAnyTypeOfInteger(ByVal objToTest)
2+
'region FunctionMetadata #######################################################
33
' Safely determines if the specified object is an integer (of any kind)
44
'
5-
' Function takes one positional argument (objToTest), which is the object to be tested to
6-
' determine if it is an integer number.
5+
' Function takes one positional argument (objToTest), which is the object to be
6+
' tested to determine if it is an integer number.
77
'
8-
' The function returns boolean True if the specified object is an integer number, boolean
9-
' False otherwise
8+
' The function returns boolean True if the specified object is an integer number,
9+
' boolean False otherwise
1010
'
1111
' Example 1:
1212
' objToTest = "12345"
@@ -33,37 +33,38 @@ Function TestObjectIsAnyTypeOfInteger(ByRef objToTest)
3333
' boolResult = TestObjectIsAnyTypeOfInteger(objToTest)
3434
' ' boolResult is equal to False
3535
'
36-
' Version: 1.1.20210709.0
37-
'endregion FunctionMetadata ####################################################
36+
' Version: 1.2.20230422.0
37+
'endregion FunctionMetadata #######################################################
3838

39-
'region License ####################################################
40-
' Copyright 2021 Frank Lesniak
39+
'region License ################################################################
40+
' Copyright 2023 Frank Lesniak
4141
'
42-
' Permission is hereby granted, free of charge, to any person obtaining a copy of this
43-
' software and associated documentation files (the "Software"), to deal in the Software
44-
' without restriction, including without limitation the rights to use, copy, modify, merge,
45-
' publish, distribute, sublicense, and/or sell copies of the Software, and to permit
46-
' persons to whom the Software is furnished to do so, subject to the following conditions:
42+
' Permission is hereby granted, free of charge, to any person obtaining a copy of
43+
' this software and associated documentation files (the "Software"), to deal in the
44+
' Software without restriction, including without limitation the rights to use,
45+
' copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
46+
' Software, and to permit persons to whom the Software is furnished to do so,
47+
' subject to the following conditions:
4748
'
48-
' The above copyright notice and this permission notice shall be included in all copies or
49-
' substantial portions of the Software.
49+
' The above copyright notice and this permission notice shall be included in all
50+
' copies or substantial portions of the Software.
5051
'
51-
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
52-
' INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
53-
' PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
54-
' FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
55-
' OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
56-
' DEALINGS IN THE SOFTWARE.
57-
'endregion License ####################################################
52+
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53+
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
54+
' FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
55+
' COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
56+
' AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
57+
' WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58+
'endregion License ################################################################
5859

59-
'region DownloadLocationNotice ####################################################
60-
' The most up-to-date version of this script can be found on the author's GitHub repository
61-
' at https://github.com/franklesniak/sysadmin-accelerator
62-
'endregion DownloadLocationNotice ####################################################
60+
'region DownloadLocationNotice #################################################
61+
' The most up-to-date version of this script can be found on the author's GitHub
62+
' repository at https://github.com/franklesniak/sysadmin-accelerator
63+
'endregion DownloadLocationNotice #################################################
6364

64-
'region DependsOn ####################################################
65+
'region DependsOn ##############################################################
6566
' TestObjectForData()
66-
'endregion DependsOn ####################################################
67+
'endregion DependsOn ##############################################################
6768

6869
Dim boolFunctionReturn
6970
Dim boolTest
@@ -88,10 +89,12 @@ Function TestObjectIsAnyTypeOfInteger(ByRef objToTest)
8889
Else
8990
On Error Goto 0
9091
If boolTest = True Then
91-
' VarType(objToTest) <> 2 And VarType(objToTest) <> 3 And VarType(objToTest) <> 17 And VarType(objToTest) <> 20
92+
' VarType(objToTest) <> 2 And VarType(objToTest) <> 3 And
93+
' VarType(objToTest) <> 17 And VarType(objToTest) <> 20
9294
boolFunctionReturn = False
9395
Else
94-
' VarType(objToTest) = 2 Or VarType(objToTest) = 3 Or VarType(objToTest) = 17 Or VarType(objToTest) = 20
96+
' VarType(objToTest) = 2 Or VarType(objToTest) = 3 Or
97+
' VarType(objToTest) = 17 Or VarType(objToTest) = 20
9598
boolFunctionReturn = True
9699
End If
97100
End If

VBScript/02_Upfront_Encapsulated_Code_With_No_Dependencies/TestObjectIsAnyTypeOfNumber.vbs

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
Function TestObjectIsAnyTypeOfNumber(ByRef objToTest)
2-
'region FunctionMetadata ####################################################
3-
' Safely determines if the specified object is a number (of any kind). In other words, this
4-
' function checks to see if the specified object is an integer or floating point number
1+
Function TestObjectIsAnyTypeOfNumber(ByVal objToTest)
2+
'region FunctionMetadata #######################################################
3+
' Safely determines if the specified object is a number (of any kind). In other
4+
' words, this function checks to see if the specified object is an integer or
5+
' floating point number
56
'
6-
' Function takes one positional argument (objToTest), which is the object to be tested to
7-
' determine if it is an integer or floating point number
7+
' Function takes one positional argument (objToTest), which is the object to be
8+
' tested to determine if it is an integer or floating point number
89
'
9-
' The function returns boolean True if the specified object is an integer or floating point
10-
' number, boolean False otherwise
10+
' The function returns boolean True if the specified object is an integer or
11+
' floating point number, boolean False otherwise
1112
'
1213
' Example 1:
1314
' objToTest = "12345"
@@ -34,37 +35,38 @@ Function TestObjectIsAnyTypeOfNumber(ByRef objToTest)
3435
' boolResult = TestObjectIsAnyTypeOfNumber(objToTest)
3536
' ' boolResult is equal to False
3637
'
37-
' Version: 1.0.20210724.0
38-
'endregion FunctionMetadata ####################################################
38+
' Version: 1.1.20230422.0
39+
'endregion FunctionMetadata #######################################################
3940

40-
'region License ####################################################
41-
' Copyright 2021 Frank Lesniak
41+
'region License ################################################################
42+
' Copyright 2023 Frank Lesniak
4243
'
43-
' Permission is hereby granted, free of charge, to any person obtaining a copy of this
44-
' software and associated documentation files (the "Software"), to deal in the Software
45-
' without restriction, including without limitation the rights to use, copy, modify, merge,
46-
' publish, distribute, sublicense, and/or sell copies of the Software, and to permit
47-
' persons to whom the Software is furnished to do so, subject to the following conditions:
44+
' Permission is hereby granted, free of charge, to any person obtaining a copy of
45+
' this software and associated documentation files (the "Software"), to deal in the
46+
' Software without restriction, including without limitation the rights to use,
47+
' copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
48+
' Software, and to permit persons to whom the Software is furnished to do so,
49+
' subject to the following conditions:
4850
'
49-
' The above copyright notice and this permission notice shall be included in all copies or
50-
' substantial portions of the Software.
51+
' The above copyright notice and this permission notice shall be included in all
52+
' copies or substantial portions of the Software.
5153
'
52-
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
53-
' INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
54-
' PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
55-
' FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
56-
' OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
57-
' DEALINGS IN THE SOFTWARE.
58-
'endregion License ####################################################
54+
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55+
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
56+
' FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
57+
' COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
58+
' AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
59+
' WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
60+
'endregion License ################################################################
5961

60-
'region DownloadLocationNotice ####################################################
61-
' The most up-to-date version of this script can be found on the author's GitHub repository
62-
' at https://github.com/franklesniak/sysadmin-accelerator
63-
'endregion DownloadLocationNotice ####################################################
62+
'region DownloadLocationNotice #################################################
63+
' The most up-to-date version of this script can be found on the author's GitHub
64+
' repository at https://github.com/franklesniak/sysadmin-accelerator
65+
'endregion DownloadLocationNotice #################################################
6466

65-
'region DependsOn ####################################################
67+
'region DependsOn ##############################################################
6668
' TestObjectForData()
67-
'endregion DependsOn ####################################################
69+
'endregion DependsOn ##############################################################
6870

6971
Dim boolFunctionReturn
7072
Dim boolTest
@@ -89,10 +91,14 @@ Function TestObjectIsAnyTypeOfNumber(ByRef objToTest)
8991
Else
9092
On Error Goto 0
9193
If boolTest = True Then
92-
' VarType(objToTest) <> 2 And VarType(objToTest) <> 3 And VarType(objToTest) <> 4 And VarType(objToTest) <> 5 And VarType(objToTest) <> 17 And VarType(objToTest) <> 20
94+
' VarType(objToTest) <> 2 And VarType(objToTest) <> 3
95+
' And VarType(objToTest) <> 4 And VarType(objToTest) <> 5
96+
' And VarType(objToTest) <> 17 And VarType(objToTest) <> 20
9397
boolFunctionReturn = False
9498
Else
95-
' VarType(objToTest) = 2 Or VarType(objToTest) = 3 Or VarType(objToTest) = 4 Or VarType(objToTest) = 5 Or VarType(objToTest) = 17 Or VarType(objToTest) = 20
99+
' VarType(objToTest) = 2 Or VarType(objToTest) = 3
100+
' Or VarType(objToTest) = 4 Or VarType(objToTest) = 5
101+
' Or VarType(objToTest) = 17 Or VarType(objToTest) = 20
96102
boolFunctionReturn = True
97103
End If
98104
End If

VBScript/02_Upfront_Encapsulated_Code_With_No_Dependencies/TestObjectIsDateTimeContainingData.vbs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
Function TestObjectIsDateTimeContainingData(ByRef objToTest)
2-
'region FunctionMetadata ####################################################
3-
' Safely determines whether the specified object is a VBScript-native datetime object
4-
' (i.e., VT_DATETIME) that contains a date and time
1+
Function TestObjectIsDateTimeContainingData(ByVal objToTest)
2+
'region FunctionMetadata #######################################################
3+
' Safely determines whether the specified object is a VBScript-native datetime
4+
' object (i.e., VT_DATETIME) that contains a date and time
55
'
6-
' Function takes one positional argument (objToTest), which is the object to be tested to
7-
' determine if it is a VBScript-native datetime (VT_DATETIME)
6+
' Function takes one positional argument (objToTest), which is the object to be
7+
' tested to determine if it is a VBScript-native datetime (VT_DATETIME)
88
'
9-
' The function returns boolean True if the specified object is a VBScript-native datetime
10-
' object (VT_DATETIME) that contains data, boolean False otherwise
9+
' The function returns boolean True if the specified object is a VBScript-native
10+
' datetime object (VT_DATETIME) that contains data, boolean False otherwise
1111
'
1212
' Example 1:
1313
' objToTest = DateSerial(2021, 7, 8)
@@ -24,37 +24,38 @@ Function TestObjectIsDateTimeContainingData(ByRef objToTest)
2424
' boolResult = TestObjectIsDateTimeContainingData(objToTest)
2525
' ' boolResult is equal to False
2626
'
27-
' Version: 1.0.20210708.0
28-
'endregion FunctionMetadata ####################################################
27+
' Version: 1.0.20230422.0
28+
'endregion FunctionMetadata #######################################################
2929

30-
'region License ####################################################
31-
' Copyright 2021 Frank Lesniak
30+
'region License ################################################################
31+
' Copyright 2023 Frank Lesniak
3232
'
33-
' Permission is hereby granted, free of charge, to any person obtaining a copy of this
34-
' software and associated documentation files (the "Software"), to deal in the Software
35-
' without restriction, including without limitation the rights to use, copy, modify, merge,
36-
' publish, distribute, sublicense, and/or sell copies of the Software, and to permit
37-
' persons to whom the Software is furnished to do so, subject to the following conditions:
33+
' Permission is hereby granted, free of charge, to any person obtaining a copy of
34+
' this software and associated documentation files (the "Software"), to deal in the
35+
' Software without restriction, including without limitation the rights to use,
36+
' copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
37+
' Software, and to permit persons to whom the Software is furnished to do so,
38+
' subject to the following conditions:
3839
'
39-
' The above copyright notice and this permission notice shall be included in all copies or
40-
' substantial portions of the Software.
40+
' The above copyright notice and this permission notice shall be included in all
41+
' copies or substantial portions of the Software.
4142
'
42-
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
43-
' INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
44-
' PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
45-
' FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
46-
' OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
47-
' DEALINGS IN THE SOFTWARE.
48-
'endregion License ####################################################
43+
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44+
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
45+
' FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
46+
' COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
47+
' AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
48+
' WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49+
'endregion License ################################################################
4950

50-
'region DownloadLocationNotice ####################################################
51-
' The most up-to-date version of this script can be found on the author's GitHub repository
52-
' at https://github.com/franklesniak/sysadmin-accelerator
53-
'endregion DownloadLocationNotice ####################################################
51+
'region DownloadLocationNotice #################################################
52+
' The most up-to-date version of this script can be found on the author's GitHub
53+
' repository at https://github.com/franklesniak/sysadmin-accelerator
54+
'endregion DownloadLocationNotice #################################################
5455

55-
'region DependsOn ####################################################
56+
'region DependsOn ##############################################################
5657
' TestObjectForData()
57-
'endregion DependsOn ####################################################
58+
'endregion DependsOn ##############################################################
5859

5960
Dim boolFunctionReturn
6061
Dim boolTest

0 commit comments

Comments
 (0)