Forum Discussion

BrandonH's avatar
BrandonH
Contributor
7 years ago

How to Retrieve an Integer from a StyledText object?

Hi,

 

     I have a few instances where an integer is stored in SWTObject(StyledText).  I don't seem to be able to read the integer from this object with the available methods.  Can someone provide a JavaScript example?

 

Thanks,

2 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi,

     

    Not sure how the control look likes, but you can try getString(), getName() function from your StyledText object.

     

    If above doesn't helps, Share some snapshots of Object and its properties and methods

  • pramoddn's avatar
    pramoddn
    Occasional Contributor

    if i understood correctly, then the question is on Type Casting, if so, get the text first SWTObject(StyledText), via getText() or object.ContetnText

     

     

    stringContent = object.contentText()

    intContent = parseint(stringContent)  //in Java script, if VB Script use cint(stringContent)

     

    intContent will contain the integer.

     

    If the requirement is to fetch partial text like "content_001" then we have to make use of substring and then type casting.