Is there a way to limit the number of characters shown in the display text function?

AppulocityAppulocity Member, PRO Posts: 46

For example if the integer attribute is '123456789', but I only want it to display '1234' how would I do that?

Thanks in advance.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited October 2015

    Use the textSubStr() function. From the Cookbook:

    textSubStr (Function): This returns a text which is the substring of attribute, text, starting from index startIndex and ending at index endIndex.Usage: Given a text attribute with the value “the quick sly fox jumped over the lazy dog.”

    textSubStr(self.Text ,5,8) returns the value “quic”. You can also use this to extract a random set of numbers from a string and use that as a way to choose a unique question via table row number.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    floor((NUMBER/(pow(10,(textLength(NUMBER)-4)))))

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276
    edited October 2015

    @tatiang i think that only works if the attribute is a text attribute.

    Adding prec() to the TextSubStr() works. This is because prec() will return as text.

    File attached
    (The example file shows the first 6 numbers of an integer attribute that has a value of 1234567890).

    Mental Donkey Games
    Website - Facebook - Twitter

Sign In or Register to comment.