I want Return 35 character of text

I used the SEGMENT function to show only 35 characters of the course name. But when the discipline is not 35 characters (MATH), gives error. How do I do ?

You have to check first if the text is longer than 35 characters. Something like:

if length_of(text) > 35:
  return segment(text, start=1, end=35)
else:
  return text
1 Like

Yes, I thought about that, but the string is the JSON return and is inside a look up pairs key.lookuppairs

what about using the inline if then else block?
http://appinventor.mit.edu/explore/ai2/support/blocks/control#choose

Taifun

As @Vishwas said have you tried it?

Check this

blocks (2)

1 Like

I didn’t use If else because I thought the Segment function did that, because in other languages ​​they do. I will try to use IF Then Else inside Look up Pairs. Topic resolved.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.