Jump to content
Macro Express Forums

Rich text in variable


Recommended Posts

In ME4 we can display a message using rich text, e.g. we can bold certain parts of our message.

And as in ME3, we can display variables, e.g. %T[1]%

Now, can we store rich text in a variable and display that?

 

So I want to display this message:

Welcome

Can I store this formatted string ("W" in bold, "elcome" in italic) in a variable and display it?

Link to comment
Share on other sites

Sure. If I understand you correctly. Let's say "Welcome" in your example could be any word and you

want the first letter bold and the remaining italicized. Simply parse the string into two strings, one for

the first character and the rest in the second. Then apply the formatting to the variables.

<VARIABLE SET STRING Option="\x00" Destination="Test1" Value="W"/>
<VARIABLE SET STRING Option="\x00" Destination="Test2" Value="elcome"/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\b\\f0\\fs16 %Test1%\\b0\\i %Test2%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

Another solution might be to dynamically create a file and use the Load Macro Text File.

Link to comment
Share on other sites

  • 3 years later...

Hi guys,

 

I realize this thread is rather old, but I'm looking for a method to do something that was mentioned in Paul's original post. I'm wanting to find a method to store rich text in a variable. The clipboard would probably work too, but I would prefer to find a way to just store rich text directly in a variable, to make it easier on the rest of the script.

 

The Text Box Display command doesn't suit my purposes. You kinda lost me when you suggested dynamically creating a file and loading a macro text file. Can ME4 save data to, and pull data from an .rtf file? Is that similar to what you were suggesting? I noticed that the Load Macro Text File command looks for .txt files and .mxe files. Are .mxe files rich text or plain?

Link to comment
Share on other sites

Rich text is a plain text format. IE the tags are normal characters like I'm writing now. EG to make the name Cory bold I write "{\b Cory}". Much in the same way we do with HTML. Open an RTF file created in WordPad in a text editor sometime. It's human readable. So the string in my example here of a bold Cory can be saved in a string variable.

 

But what is it you are trying to do? Please explain.

 

On a lark I'll guess you want to do something that's not immediately available and you might need to use Run Macron in Variable. See help file. It sounds intimidating but it's really not. Just realize that your normal view in the script editor is not how the commands are actually stored but rather a collection of nice dialog boxes to create and edit commands. Switch views to the direct editor and you will see the actual commands they build. All Run Macro in Variable does is literally execute whatever string is in the variable you choose as a macro command. This gives on the ability to modify things that would otherwise be difficult to change. EG you have a bit of string to display in a dialog box to have 4 different words colored 3 possible different ways. Without this command you would need a logic matrix of 12 Message Boxes plus the lines of logic. Often it is easier to modify the text of the command to accomplish this. Anyway just a shot in the dark.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...