Search code examples
autohotkey

Build a string with literals and variables


I am trying to build a string for a tool tip, but no matter how I try to build it, I get an error.

This is how I thought I could do it

tooltipMsg := "Last: " + %lastEmbedState%`n"Curr: " + %embedState%

But it is telling me Error: The following variable name contains an illegal character: "Last


Solution

  • Variable names within expressions should not be wrapped in %. Also `n represents a new line character and should be inside quotes.

    tooltipMsg := "Last: " . lastEmbedState . "`n" . "Curr: " . embedState