Hi Guys,
I have some code below which keeps triggering an error, I have done a debug using tenscripting and it did not report any error, I initially though the error might have been related to the fact that I was using arrays but this does not appear to be the case either.
I know it is hard without the appropiate file (which if needed I can send) but can anyone take a glance over the code I have been working on and let me know if anything stands out which might be causing the error below?
Thanks!
*ERROR*
*** CODE ***
I have some code below which keeps triggering an error, I have done a debug using tenscripting and it did not report any error, I initially though the error might have been related to the fact that I was using arrays but this does not appear to be the case either.
I know it is hard without the appropiate file (which if needed I can send) but can anyone take a glance over the code I have been working on and let me know if anything stands out which might be causing the error below?
Thanks!
*ERROR*
PHP Code:
Scripting runtime error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --- System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.Parameter name: length at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) at System.String.Substring(Int32 startIndex, Int32 length) at scriptcode52.scriptcode52.ApplianceLookup(String Appliances) at scriptcode52.scriptcode52.Main(Object Parms) --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Scheduler.VsaScriptHost.Invoke(String ModuleName, String MethodName, Object[] Arguments)
*** CODE ***
Code:
Imports System.IO Public Sub Main(Byval Parms as Object) hs.Writelog("Appliance Test",ApplianceLookup("HOPUT1 NAWET1")) End Sub Public Function ApplianceLookup(ByVal Appliances As String) Dim SplitStr() As String Dim ResultToReturn As String SplitStr = Split(Appliances," ") Dim s As StreamReader = New StreamReader("C:\Homeseer HSPRO\html\CFA_Paging\pager.csv") Dim ApplianceAbbreviation As String Dim brigade As String Dim BrigadeAbbrevition As String Dim Filename As String Dim ApplianceType As String Dim MyData As String Dim i As Integer for each ApplianceListed as String in SplitStr ApplianceAbbreviation = ApplianceListed.Substring(3, 5) BrigadeAbbrevition = ApplianceAbbreviation = ApplianceListed.Substring(0, 3) hs.WriteLog("Appliances - Brigade", BrigadeAbbrevition) hs.WriteLog("Appliances", ApplianceAbbreviation) Do MyData = s.ReadLine() If MyData.Contains(BrigadeAbbrevition) Then brigade = hs.StringItem(MyData, 2, ",").Replace(Chr(34), "") Select Case ApplianceAbbreviation Case "AP" ApplianceType = "Aerial Pumper" Case "AC" ApplianceType = "Aircraft" Case "BF" ApplianceType = "Big Fill" Case "V" ApplianceType = "Boat / Vessel" Case "BA" ApplianceType = "Breathing Apparatus" Case "BS" ApplianceType = "Bus" Case "CR" ApplianceType = "Car" Case "CR2" ApplianceType = "Car 2" Case "CR3" ApplianceType = "Car 3" Case "DMO" ApplianceType = "DMO" Case "FC" ApplianceType = "Field Command Vehicle" Case "F2" ApplianceType = "Field Command Vehicle 2" Case "F3" ApplianceType = "Field Command Vehicle 3" Case "FO" ApplianceType = "Field Operations Vehicle" Case "HM" ApplianceType = "Hazmat" Case "HD" ApplianceType = "Hazmat Detection" Case "HL" ApplianceType = "Hose Layer" Case "LP" ApplianceType = "Ladder Platform" Case "LT" ApplianceType = "Lighting" Case "CV" ApplianceType = "Mobile Communications Vehicle" Case "PE" ApplianceType = "Protective Equipment" Case "P1" ApplianceType = "Pumper" Case "P2" ApplianceType = "Pumper 2" Case "P3" ApplianceType = "Pumper 3" Case "PT" ApplianceType = "Pumper/Tanker" Case "QF" ApplianceType = "Quick Fill" Case "R" ApplianceType = "Rescue" Case "SV" ApplianceType = "Salvage" Case "S1" ApplianceType = "Slip On" Case "S2" ApplianceType = "Slip On 2" Case "S3" ApplianceType = "Slip On 3" Case "S4" ApplianceType = "Slip On 4" Case "SM" ApplianceType = "Snow Mobile" Case "SP" ApplianceType = "Spare Vehicle" Case "ST" ApplianceType = "Staging Resource" Case "SU" ApplianceType = "Support" Case "T1" ApplianceType = "Tanker" Case "T2" ApplianceType = "Tanker 2" Case "T3" ApplianceType = "Tanker 3" Case "T4" ApplianceType = "Tanker 4" Case "TB" ApplianceType = "Teleboom" Case "U1" ApplianceType = "Ultra Light" Case "U2" ApplianceType = "Ultra Light 2" Case "U3" ApplianceType = "Ultra Light 3" Case "U4" ApplianceType = "Ultra Light 4" Case Else ApplianceType = "Unknown " & "(" & ApplianceAbbreviation & ")" End Select Exit Do End If Loop Until MyData Is Nothing s.Close() If brigade <> "" Then ResultToReturn = ResultToReturn & brigade & " " & ApplianceType & ", " Else hs.WriteLog("Pager Messages", "Brigade Not Found") End If Next Return ResultToReturn End Function
Comment