geebs
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2012
01:19 PM
Data Type Conversion for TargetRect values
There's something simple that I'm not understanding about data type conversions. Need a little help.
Trying to set the width and height of a text rectangle. Harcoding the numbers works, however, now I need to set the width and height from variables.
According to the docs (and testing) I have to first convert my variables to integer type. I tried appending a "%" to my variables but still get Data Type Conversion errors.
I get a value from my xml file...
rectWidth = xml.text_rectW.getText()
rectWidth is now 500
however, its still a string data type
how do I convert this to an integer so I can set my textbox rectangle width? Becuse this does not work...
rectWidth% = xml.text_rectW.getText()
rectHeight% = xml.text_rectH.getText()
mytext = []
mytext.Push({
Text: "some text to help make you boogie all night long with all the ladies"
TargetRect: { x:10, y:10, w: rectWidth%, h: rectHeight% }
})
the text displays fine but the text rectangle is the whole width and height of the screen.
Trying to set the width and height of a text rectangle. Harcoding the numbers works, however, now I need to set the width and height from variables.
According to the docs (and testing) I have to first convert my variables to integer type. I tried appending a "%" to my variables but still get Data Type Conversion errors.
I get a value from my xml file...
rectWidth = xml.text_rectW.getText()
rectWidth is now 500
however, its still a string data type
how do I convert this to an integer so I can set my textbox rectangle width? Becuse this does not work...
rectWidth% = xml.text_rectW.getText()
rectHeight% = xml.text_rectH.getText()
mytext = []
mytext.Push({
Text: "some text to help make you boogie all night long with all the ladies"
TargetRect: { x:10, y:10, w: rectWidth%, h: rectHeight% }
})
the text displays fine but the text rectangle is the whole width and height of the screen.
2 REPLIES 2


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2012
01:27 PM
Re: Data Type Conversion for TargetRect values
You can convert a string to an int with ToInt() http://sdkdocs.roku.com/display/RokuSDK ... ToIntAsInt
or StrToI() http://sdkdocs.roku.com/display/RokuSDK ... gAsDynamic
or StrToI() http://sdkdocs.roku.com/display/RokuSDK ... gAsDynamic
BrightScript Debugger> ? type("5".ToInt())
Integer
BrightScript Debugger> ? type(StrToI("5"))
Integer
geebs
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2012
01:52 PM
Re: Data Type Conversion for TargetRect values
Awsome, thanks!
strtoi() worked for me. My example:
rectW = xml.text_rectWidth.getText()
rectW = strtoi(rectW)
Now I can set my text rectangle width, height and also XY coords. Thanks again. 😄
strtoi() worked for me. My example:
rectW = xml.text_rectWidth.getText()
rectW = strtoi(rectW)
Now I can set my text rectangle width, height and also XY coords. Thanks again. 😄