Good morning,
A runtime error occurs for CreoPlayer but is fine for the simulator ; computed property
get {
return _formatdate;
}
set {
_formatdate = value;
Console.write(value);
date.text = value[0...9];
}
TIA
Good morning,
A runtime error occurs for CreoPlayer but is fine for the simulator ; computed property
get {
return _formatdate;
}
set {
_formatdate = value;
Console.write(value);
date.text = value[0...9];
}
TIA
What is value?
What are you trying to do with date.text = value[0...9];
?
Formatting the string - 2019-12-03 00:00:00
So I don't understand what you are trying to achieve with date.text = value[0...9];
.
Please tell me what is the desired result.
2019-12-03
You are receiving that error because some times value is not a String but it is something else.
Please try to Console.write(value.class);
to better understand why/when this happens
Ok will do that but in my testing I forced a string with String(value) and had the same results
test <Console.write(value.class)> shows String, repeatable
Of course I can only use this test with the simulator not CreoPlayer where the runtime error occurs.
Forced a string for value (2019-12-03 00:00:00)
var d = String(value)
date.text = d[0...9];
and ok for simulator, but a differant runtime error for CreoPlayer Also works for CreoPlayer in loading a list for initial record but not the second, which generates an error.
Hi @Joel_Eisenstat it seems that at some point in CreoPlayer a value different from a String is sent to that method. var d = String(value)
could not be sufficient if value cannot be converted to a String.
What you can try to do is to add a check for a class type before the String transformation.
I would write something like:
if (value is String) { date.text = value[0...9]; }
OK, under what conditions would a value cannot be converted to a string ?
Well, there are a lot of cases... for example from the first error message that you posted it seems that value was a CustomView. How can a CustomView object be converted to a String? This is not possibile.
Ok I see that all objects cannot use String() but still cannot see why in CreoPlayer the CustomView45 doesn't follow through and use the computed property , whose value is a string .
Anyways shut in for a few weeks, though not as strict as you have , so plenty of time to figure it out.
Console.write(value.class); -----> anonymous closure , this gives the error
Runtime Error
Out of bounds error: second_index 9 beyond bounds 0...3
What is anonymous closure ?
It seems to be associated with a date value and not being able to be converted to a string by CreoPlayer thus creating an error for value [0...9]. Ok for the simulator if that helps you
BTW - Hope all is well with the Creo team , all ok here but headed to lockdown shortly.