-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMiscMethods.rbbas
More file actions
155 lines (129 loc) · 3.89 KB
/
MiscMethods.rbbas
File metadata and controls
155 lines (129 loc) · 3.89 KB
1
#tag ModuleProtected Module MiscMethods #tag Method, Flags = &h1 Protected Function CurrentGroup(paramGroupCheck as string) As Boolean // Set up variables for idle time // Shell result Dim mCurrentGroups As String // Shell exit code Dim mErrCode As Integer // Set up shell Dim s As Shell s=New Shell s.Mode = 0 // Check idle time //s.Execute code to check idle time from USB input devices s.Execute "/bin/echo -n `/usr/bin/groups`" // Set results to mIdleResult mCurrentGroups = s.Result // Set error code to mIdleError mErrCode = s.ErrorCode // Log mIdleResult for debugging // System.Log(System.LogLevelError, "Method: " + midleSecs) // LogToFile("mIdleSeconds: " + str(mIdleSecs)) Dim groupArray(-1) as String Dim compareResult as Integer groupArray=Split(mCurrentGroups) for each g as String in groupArray If g = paramGroupCheck then return true end if next // we didn't find the group in our array, quitting. return false End Function #tag EndMethod #tag Method, Flags = &h1 Protected Function CurrentUsername(paramUsernameCheck as string) As Boolean // Set up variables for idle time // Shell result Dim mCurrentUsername As String // Shell exit code Dim mErrCode As Integer // Set up shell Dim s As Shell s=New Shell s.Mode = 0 // Check idle time //s.Execute code to check idle time from USB input devices s.Execute "/bin/echo -n `whoami`" // Set results to mIdleResult mCurrentUsername = s.Result // Set error code to mIdleError mErrCode = s.ErrorCode // Log mIdleResult for debugging // System.Log(System.LogLevelError, "Method: " + midleSecs) // LogToFile("mIdleSeconds: " + str(mIdleSecs)) if ( InStr(paramUsernameCheck, mCurrentUsername) > 0 ) then return true else return false end if End Function #tag EndMethod #tag Method, Flags = &h1 Protected Function PadData(PadChar as string, EndLength as integer, StrToPad as string, paramLogToFile as Boolean) As string dim paddedStr as string dim loopVar as integer dim NumPadChars as integer if (paramLogToFile = Globals.kLogToFileEnable) then LogToFile(CurrentMethodName + ": ---->") LogToFile(CurrentMethodName + ": String received: " + "--->" + StrToPad + "<---") LogToFile(CurrentMethodName + ": PadChar received: " + "--->" + PadChar + "<---") LogToFile(CurrentMethodName + ": EndLength received: " + "--->" + str(EndLength) + "<---") end if if (len(StrToPad) >= EndLength) then if (paramLogToFile = Globals.kLogToFileEnable) then LogToFile(CurrentMethodName + ": No padding necessary. Exiting.") LogToFile(CurrentMethodName + ": <----") end if return StrToPad end if paddedStr = StrToPad NumPadChars = EndLength - len(StrToPad) for loopVar = 1 to NumPadChars paddedStr = PadChar + paddedStr next if (paramLogToFile = Globals.kLogToFileEnable) then LogToFile(CurrentMethodName + ": <----") end if return paddedStr End Function #tag EndMethod #tag ViewBehavior #tag ViewProperty Name="Index" Visible=true Group="ID" InitialValue="-2147483648" Type="Integer" #tag EndViewProperty #tag ViewProperty Name="Left" Visible=true Group="Position" InitialValue="0" Type="Integer" #tag EndViewProperty #tag ViewProperty Name="Name" Visible=true Group="ID" Type="String" #tag EndViewProperty #tag ViewProperty Name="Super" Visible=true Group="ID" Type="String" #tag EndViewProperty #tag ViewProperty Name="Top" Visible=true Group="Position" InitialValue="0" Type="Integer" #tag EndViewProperty #tag EndViewBehaviorEnd Module#tag EndModule