1

I want to show a long message that going to differ every time and it's 3 lines or less. This message comes from Sim900. I cant show the whole sentence on my 4x20 lcd. how can I print it in several lines?

1 Answers1

1

See SPLIT.

You can use e.g. the SPLIT command to split the text in multiple lines (like 0-20 for the first line, 20-39 for the second line, 40-59 for the third line).

However, this is quite a 'crude' way because words will be split in the middle.

To improve this, some smarter algorithm is needed, e.g. checking position 19 if it is a space, if not, go backwards until a space is found, than print index 0 to that position (except the space) to the first line, and do the same for the other two lines. Also it might be there are no spaces at all, or the text will not fit on the three lines (like words of 10 characters each with spaces in between).

Michel Keijzers
  • 13,867
  • 18
  • 69
  • 139
  • Excuse me. Could you please give me an example for SPLIT function? I didn't understand Bascom help correctly. thanks. – Mohammad Reza Hasanpour Aug 18 '18 at 08:48
  • 1
    In the example Bcount = Split( "this is a test" , Ar(1) , " ") means that bcount will be 4: number of found elements, Ar(1) is the start, so Ar(1) will be "this", Ar(2) will be "is", Ar(3) will be "a" and Ar(4) will be "test" (if I understand BASCOM correctly never used it myself) – Michel Keijzers Aug 19 '18 at 19:55