KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Store MultiStyle text in 4D Text
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: September 7, 2018

When Variable text object is set to Multi-style, the span tags can be output as an example:

TEST 4D


Display in text as:

<span style="font-size:10.5pt;color:#4BB51E;font-weight:bold">TEST 4D</span>


The text above cannot be stored in 4D text due to the quotes. The following utility method will take care of this:

// -----------------------------------------------------------------
// Name: convertMultiStyleTo4DText
// Description: Method will take the Multi-Style text and convert
// to a 4D text containing escaped quotes characters
//
// Input Parameters:
// $1 (TEXT) - Multi-Style text that contains quotes character
// Output:
// $0 (TEXT) - Multi-Sytle text that escapes the quotes character
// ------------------------------------------------------------------
C_TEXT($1;$inputText)
C_TEXT($0;$outputText)

If (Count parameters=1)
  $inputText:=$1
  
  $outputText:=Replace string($inputText;"\\\"";"\"")
  $0:=$outputText
End if


Here is example of using the method:

C_TEXT($mStyleText;$mStyleTextConverted)

$mStyleTextConverted:=convertMultiStyleTo4DText($mStyleText)


<span style=\"font-size:10.5pt;color:#4BB51E;font-weight:bold\">TEST 4D</span>