Skip to content

Commit 6102a60

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/issue-003'
2 parents 825450b + 6ce4fdf commit 6102a60

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

SingleTact Demo/GUI.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ public void AddData(double time, double[] measurements)
239239
graph_.AxisChange();
240240
}
241241

242+
/// <summary>
243+
/// Finds a character to separate exported values.
244+
/// </summary>
245+
/// <returns>A semi-colon for locales where comma is the decimal
246+
/// separator; otherwise a comma.</returns>
247+
private string safeSeparator()
248+
{
249+
double testValue = 3.14;
250+
string testText = testValue.ToString();
251+
252+
if (testText.IndexOf(',') < 0)
253+
return ",";
254+
255+
return ";";
256+
}
257+
242258
//Save data to CSV
243259
private void buttonSave_Click(object sender, EventArgs e)
244260
{
@@ -257,16 +273,19 @@ private void buttonSave_Click(object sender, EventArgs e)
257273

258274
if (saveDataDialog.ShowDialog() == DialogResult.OK)
259275
{
276+
// To fix Issue 3, separate exported values by semi-colon instead
277+
// of comma if current locale's decimal separator is comma.
278+
string separator = safeSeparator();
260279
string saveFileName = saveDataDialog.FileName;
261280
StreamWriter dataWriter = new StreamWriter(saveFileName, false, Encoding.Default);
262281

263282
//Write a header
264-
dataWriter.WriteLine("Time (s)" + "," + "Value (0 = 0 PSI 511 = Full Scale Range)");
283+
dataWriter.WriteLine("Time (s)" + separator + "Value (0 = 0 PSI 511 = Full Scale Range)");
265284

266285
//Just export first trace (we only support 1 sensor)
267286
for (int i = 0; i < dataBuffer_.data[0].Count; i++)
268287
{
269-
dataWriter.WriteLine(dataBuffer_.data[0][i].X + "," + dataBuffer_.data[0][i].Y);
288+
dataWriter.WriteLine(dataBuffer_.data[0][i].X + separator + dataBuffer_.data[0][i].Y);
270289
}
271290

272291
dataWriter.Close();

0 commit comments

Comments
 (0)