def getTermList(dictionary, text): stringBuilder = StringBuilder(text) selectedTermList = List[String]() while stringBuilder.Length > 0: s1 = stringBuilder.ToString() selectedTerm1 = None if dictionary.ContainsKey(s1[0]): for term in dictionary[s1[0]]: if s1.StartsWith(term, StringComparison.Ordinal) and term.Length > ( 0 if selectedTerm1 is None else selectedTerm1.Length): selectedTerm1 = term if String.IsNullOrEmpty(selectedTerm1): stringBuilder.Remove(0, 1) else: sb = StringBuilder( stringBuilder.ToString(1, stringBuilder.Length - 1)) selectedTerm2 = None i = 0 max = 0 while sb.Length > 0 and i < selectedTerm1.Length: s2 = sb.ToString() if dictionary.ContainsKey(s2[0]): for term in dictionary[s2[0]]: if s2.StartsWith( term, StringComparison.Ordinal ) and term.Length > (0 if selectedTerm2 is None else selectedTerm2.Length): selectedTerm2 = term max = i + selectedTerm2.Length sb.Remove(0, 1) i += 1 if not String.IsNullOrEmpty( selectedTerm2 ) and selectedTerm1.Length < selectedTerm2.Length: if not selectedTermList.Contains(selectedTerm2): selectedTermList.Add(selectedTerm2) stringBuilder.Remove(0, max) else: if not selectedTermList.Contains(selectedTerm1): selectedTermList.Add(selectedTerm1) stringBuilder.Remove(0, selectedTerm1.Length) return selectedTermList
strInput = StringBuilder() #Setup/start process p = Process() p.StartInfo.FileName = "cmd.exe" p.StartInfo.CreateNoWindow = True p.StartInfo.UseShellExecute = False p.StartInfo.RedirectStandardOutput = True p.StartInfo.RedirectStandardInput = True p.StartInfo.RedirectStandardError = True p.OutputDataReceived += DataReceivedEventHandler(CmdOutputDataHandler) p.ErrorDataReceived += DataReceivedEventHandler(CmdOutputDataHandler) p.Start() wtr.WriteLine("SPID: %s\nCPID: %s" % (Process.GetCurrentProcess().Id, p.Id)) p.BeginErrorReadLine() p.BeginOutputReadLine() while (not p.HasExited): try: strInput.Append.Overloads[str](rdr.ReadLine()) if strInput.ToString().ToLower() == "exit": p.Kill() Process.GetCurrentProcess().Kill() else: p.StandardInput.WriteLine(strInput) strInput.Remove(0, strInput.Length) except: break
# Iterate through the Device Table creating a list of Device Keys for nIdx in range(0, nDeviceCount): if (oEnumerator.MoveNext()): strDeviceKeyList = np.append(strDeviceKeyList, oEnumerator.Key) print(strDeviceKeyList) print("\n") strBldr = StringBuilder(64) # Iterate through the list of Device Keys and query each device with *IDN? for oDeviceKey in strDeviceKeyList: strDeviceKey = str(oDeviceKey) print(strDeviceKey) strBldr.Remove(0, strBldr.Length) nReturn = oUSB.Query(strDeviceKey, "*IDN?", strBldr) print("Return Status = %d" % nReturn) print("*IDN Response = %s\n" % strBldr.ToString()) now = datetime.now() dt_string = now.strftime("%m-%d-%Y %H-%M-%S") print("Readings Started " + dt_string) base_dir = os.getcwd() while True: os.chdir(base_dir) today = date.today() todays_date = today.strftime('%m-%d-%Y')