The line of code with the issue:
memory.WriteFloat(tp_x, this.X)
this.X is fine and works with no issues. For the value tp_x, it is a STRING. I am taking this from a text file and parsing it to an exact value. I have tried several times to convert this string to Int32/64, float, long, etc. But the memory.WriteFloat() is not taking it without an error. Picture of code
I have tried to use
memory.ReadFloat(tp_X)
But I get the same error. Cannot convert from 'string' to 'long'. I have tried so much different codes to convert it and use it, but nothing has worked or changed so I am asking a question here. I wouldn't be asking if I had no idea. Thank you, please let me know!
EDITED for pm100 Here is my new code: Picture 1 Where I get my error Picture 2 So using your code @pm100 as seen in the pictures, I get no problems and I can compile perfectly. Although, when I execute this I get error
I get the error System.FormatException: Input string was not in a correct format. at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type) at System.Number.ParseInt64(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info) at System.Int64.Parse(String s)
My code: int counter = 0; // location is the selected index of the combobox that the user selected
foreach (string line in System.IO.File.ReadLines(@"path"))
{
if (counter == location)
{
string[] words = line.Split(",");
int tempcounter = 1;
string tp_x = "";
string tp_y = "";
string tp_z = "";
foreach (var word in words)
{
if (tempcounter == 1)
{
tp_x += word;
}
if (tempcounter == 2)
{
tp_y += word;
}
if (tempcounter == 3)
{
tp_z += word;
}
tempcounter += 1;
//everytime works perfect above, now below
long l = System.Int64.Parse(tp_x);
long l2 = System.Int64.Parse(tp_y);
long l3 = System.Int64.Parse(tp_z);
tp_xx = l;
tp_yy = l2;
tp_zz = l3;
for (int i = 0; i < address.vz.Length; i++)
{
mem.WriteFloat(tp_xx, this.X);
mem.WriteFloat(tp_yy, this.Y);
mem.WriteFloat(tp_zz, this.Z);
}
}
return false;
}
counter += 1;
}