With this code you can create multiple lines of text in InTouch using one input string.
The code is defined as a quick function, and can be called from within a code block, or on an animation event.
Simply pass in the text string to split, the number of characters per line, and which line you want to return.

Example

You have a text string that is 50 characters long, and you want to display it over 3 lines on a screen, but are limited to 20 characters per line.
Draw 3 lines of text on the screen.
Animate the text as follows:

  • Text 1: string input animation: Call SplitStringIntoLines(‘*YOUR STRING TAG*’, 20, 1)
  • Text 2: string input animation: Call SplitStringIntoLines(‘*YOUR STRING TAG*’, 20, 2)
  • Text 3: string input animation: Call SplitStringIntoLines(‘*YOUR STRING TAG*’, 20, 3)

Code

The following should be placed in a quick function called “SplitStringIntoLines”

{**********************************************************
*** Split the input string into a specified line
**
** adamrob.co.uk
** 5FEB2014 1428
**
** Inputs:
** sText = The text to split to multiple lines
** iLineLength = The amount of characters allowed per line
** iLineNumber = The line number to return
**
**********************************************************}
 
DIM initialString AS MESSAGE;
DIM finalString AS MESSAGE;
DIM nextString AS MESSAGE;
DIM currIndex AS INTEGER;
DIM lastIndex AS INTEGER;
DIM bDone AS INTEGER;
DIM iIndex AS INTEGER;
 
{** Set default next string value}
nextString = sText;
 
{**Check if the string is greater than max per line}
IF StringLen( sText ) > iLineLength THEN
 
	{** Loop around all lines}
	FOR iIndex=1 TO iLineNumber
 
		{** Check if its line 1}
		IF iIndex == 1 THEN
 
			{* Reset vars}
			currIndex=0;
			lastIndex=0;
			bDone=0;
 
			{** Loop through remaining text}
			FOR bDone = 0 TO iLineLength
 
				currIndex=currIndex+1;
				currIndex=StringInString(sText, " ", currIndex, 0);
 
				IF currIndex >= iLineLength THEN
					initialString=StringLeft(sText,lastIndex);
					EXIT FOR;
				ELSE
					lastIndex=currIndex;
				ENDIF;
			NEXT;
 
			{** Check for a value. StringInString will loop around the string.
			** So if there is no value assume we have reached the end of the string}
			IF (initialString == "") THEN
				initialString = sText;
			ENDIF;
 
		ELSE
 
			IF StringLen(nextString) - StringLen(initialString) > 0 THEN
				{** Build up the remaining string}
				nextString = StringRight(nextString,StringLen(nextString) - StringLen(initialString));
				initialString="";
				{* Reset vars}
				currIndex=0;
				lastIndex=0;
				bDone=0;
 
				{** Loop through remaining text}
				FOR bDone = 0 TO iLineLength
 
					currIndex=currIndex+1;
					currIndex=StringInString(nextString, " ", currIndex, 0);
 
					IF currIndex >= iLineLength THEN
						initialString=StringLeft(nextString,lastIndex);
						EXIT FOR;
					ELSE
						lastIndex=currIndex;
					ENDIF;
				NEXT;
 
				{** Check for a value. StringInString will loop around the string.
				** So if there is no value assume we have reached the end of the string}
				IF (initialString == "") THEN
					initialString = nextString;
				ENDIF;
 
			ELSE
				initialString="";
				EXIT FOR;
			ENDIF;
		ENDIF;
 
 
		{** Check if the current line is the line we need}
		IF iIndex == iLineNumber THEN
 
			finalString=initialString;
			EXIT FOR;
 
		ENDIF;
 
	NEXT;
 
ELSE
 
	IF iLineNumber == 1 THEN
		finalString=sText;
	ENDIF;
 
ENDIF;
 
RETURN finalString;
The arguments are:
  • sText as Message
  • iLineLength as Integer
  • iLineNumber as integer