Skip to content

Commit

Permalink
Fix ConvertEnumLine on empty string (#14)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben <[email protected]>
  • Loading branch information
bhoogter and Ben authored Feb 10, 2022
1 parent 9540d74 commit 90e9804
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 2 additions & 0 deletions modQuickConvert.bas
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ End Function
Public Function ConvertEnumLine(ByVal L As String) As String
Dim Name As String, Value As String
Dim Parts() As String

If Trim(L) = "" Then Exit Function
Parts = Split(L, " = ")
Name = Trim(Parts(0))
If UBound(Parts) >= 1 Then Value = Trim(Parts(1)) Else Value = ""
Expand Down
1 change: 1 addition & 0 deletions modShell.bas
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Enum enSW
enSW_NORMAL = 1
enSW_MAXIMIZE = 3
enSW_MINIMIZE = 6
'' try with comment ' and a second comment
End Enum

Type STARTUPINFO
Expand Down
10 changes: 5 additions & 5 deletions prj.vbw
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
frm = 26, 26, 990, 342, , 0, 0, 964, 316, C
frm = 26, 26, 990, 342, C, 0, 0, 964, 316, C
modProjectFiles = 52, 52, 1016, 368, C
modTextFiles = 104, 104, 1068, 420, C
modRegEx = 78, 78, 1042, 394, C
frmTest = 104, 104, 1068, 420, C
frmTest = 104, 104, 1068, 420,
modConvertForm = 78, 78, 1042, 394, C
modSubTracking = 52, 52, 1016, 388, C
modUsingEverything = 130, 130, 1068, 459, C
Expand All @@ -15,13 +15,13 @@ frmConfig = 78, 78, 1477, 574, C, 52, 52, 1451, 548, C
modINI = 208, 208, 1647, 732, C
modGit = 104, 104, 1376, 580, C
modDirStack = 130, 130, 1402, 606, C
modShell = 156, 156, 1428, 632, C
modShell = 156, 156, 1428, 632,
modTestCases = 52, 52, 1364, 576, C
modQuickLint = 52, 52, 1364, 576, C
frmLinter = 78, 78, 1131, 555, C, 104, 104, 1157, 581, C
modConvert = 52, 52, 1016, 368, C
modVB6ToCS = 0, 0, 938, 329, C
modRefScan = 156, 156, 922, 484, C
modUtils = 22, 30, 986, 609, C
modQuickConvert = 25, 98, 1078, 575, Z
modOrigConvert = 0, 0, 1309, 524, C
modVB6ToCS = 0, 0, 938, 329, C
modQuickConvert = 25, 98, 1078, 575, Z
16 changes: 8 additions & 8 deletions quick/Modules/modShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum enSW
, enSW_NORMAL = 1
, enSW_MAXIMIZE = 3
, enSW_MINIMIZE = 6
// ' try with comment ' and a second comment
}
public class STARTUPINFO
{
Expand Down Expand Up @@ -74,13 +75,12 @@ public class PROCESS_INFORMATION
// Run a given command and return stdout as a string.
public static string RunCmdToOutput(string Cmd, out string ErrStr, bool AsAdmin = false)
{
ErrStr = "";
string _RunCmdToOutput = "";
// TODO: (NOT SUPPORTED): On Error GoTo RunError
string A = "";
string B = "";
string C = "";
int tLen = 0;
long tLen = 0;
int Iter = 0;
A = TempFile();
B = TempFile();
Expand All @@ -92,13 +92,13 @@ public static string RunCmdToOutput(string Cmd, out string ErrStr, bool AsAdmin
{
C = TempFile(".bat");
WriteFile(C, Cmd + " 1> " + A + " 2> " + B, true);
RunFileAsAdmin(C, 0, enSW.enSW_HIDE.Value());
RunFileAsAdmin(C, 0, enSW.enSW_HIDE.Value<int>());
}
Iter = 0;
int MaxIter = 10;
while (true)
{
tLen = (int)FileLen(A);
tLen = FileLen(A);
Sleep(800);
if (Iter > MaxIter || FileLen(A) == tLen) break;
Iter = Iter + 1;
Expand All @@ -124,15 +124,15 @@ public static void ShellAndWait(string AppToRun, enSW SW = enSW.enSW_NORMAL)
NameStart.Cb = Len(NameStart);
if (SW == enSW.enSW_HIDE)
{
RC = CreateProcessA(0, AppToRun, 0, 0, SW.Value(), CREATE_NO_WINDOW, 0, 0, ref NameStart, ref NameOfProc);
RC = CreateProcessA(0, AppToRun, 0, 0, CInt(SW), CREATE_NO_WINDOW, 0, 0, ref NameStart, ref NameOfProc);
}
else
{
RC = CreateProcessA(0, AppToRun, 0, 0, SW.Value(), NORMAL_PRIORITY_CLASS, 0, 0, ref NameStart, ref NameOfProc);
RC = CreateProcessA(0, AppToRun, 0, 0, CInt(SW), NORMAL_PRIORITY_CLASS, 0, 0, ref NameStart, ref NameOfProc);
}
LastProcessID = NameOfProc.dwProcessId;
RC = WaitForSingleObject(NameOfProc.hProcess, INFINITE);
CloseHandle(ref NameOfProc.hProcess);
RC = CloseHandle(ref NameOfProc.hProcess) ? 1 : 0;
ErrorRoutineResume:;
return;
ErrorRoutineErr:;
Expand All @@ -148,7 +148,7 @@ public static string TempFile(string UseFolder = "", string UsePrefix = "tmp_",
if (UseFolder != "" && !DirExists(UseFolder)) UseFolder = "";
if (UseFolder == "") UseFolder = AppContext.BaseDirectory + DIRSEP;
if (Right(UseFolder, 1) != DIRSEP) UseFolder = UseFolder + DIRSEP;
FN = Replace(UsePrefix + CDbl(DateTime.Now) + "_" + System.Threading.Thread.CurrentThread + "_" + Random(999999), ".", "_");
FN = Replace(UsePrefix + CDbl(DateTime.Now) + "_" + AppDomain.GetCurrentThreadId() + "_" + Random(999999), ".", "_");
while (FileExists(UseFolder + FN + ".tmp"))
{
FN = FN + Chr(Random(25) + Asc("a"));
Expand Down

0 comments on commit 90e9804

Please sign in to comment.