03-28-2019 06:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-28-2019 06:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm developing a clockface where I pass a property to the index.gui from index.js.
If I pass a numeric value I have no problem, however if I'm attempting to pass a % value the SDK gives me an error as it expect a numeric value while it is a string.
An example of such code is
rectHandle.y = startingPoint;
if startingPoint is numeric no problem, if it's for example "20%" it gives me the following error
Unhandled exception: TypeError: Cannot set property to '20%': Unexpected type. Expected a Number
Thanks!
Answered! Go to the Best Answer.

Accepted Solutions
03-28-2019 11:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-28-2019 11:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Sorry, the percentage values aren't currently supported, but you can calculate the pixel value from the device screen dimensions.
import { me as device } from "device";
if (!device.screen) device.screen = { width: 348, height: 250 };
let percent = 40;
let pixels = percent / 100 * device.screen.width;
myVar.x = pixels;
03-28-2019 11:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-28-2019 11:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Sorry, the percentage values aren't currently supported, but you can calculate the pixel value from the device screen dimensions.
import { me as device } from "device";
if (!device.screen) device.screen = { width: 348, height: 250 };
let percent = 40;
let pixels = percent / 100 * device.screen.width;
myVar.x = pixels;
