variables and interpolated literals
Posted: 2009-03-12 13:59:28
Getting back to learning the new macro language, I succeeded in writing a simple macro that even works. For reference, it's pasted below.
It simply builds a block of lines each starting with a number followed by a tab and newline character.
Following the line
$text = $prefix & $firstStep
I tried variations of
$text += "\t + \n"
$text & "\t + \n"
$text += "\t & \n"
and others to assemble the text added to the clipboard first. Some got complaints, but none succeeded in adding a tab and newline to the text added to the clipboard. (The pasted text was a single line.)
To add a tab or newline to text on the clipboard, do they have to be explicitly appended? Is there no way to assemble a string variable containing them that can then be appended to a clipboard?
Thank you.
Cliff Bender
***********
#NisusMacroProperty Name: _FlowChart Numbers
$message = 'What is the prefix?'
$prefix = Prompt Input $message, '', 'OK', 'S'
$message = 'What is the first number?'
$firstStep = Prompt Input $message, '', 'OK', '100'
$message = 'What is the last number?'
$lastStep = Prompt Input $message, '', 'OK', '10'
If $lastStep <= $firstStep
Die 'Sorry, the numbers are invalid.'
else
New Clipboard 'flowclip'
Switch to Clipboard 'flowclip'
Write Clipboard 'START'
Append to Clipboard "\n"
While $firstStep <= $lastStep
$text = $prefix & $firstStep
Append to Clipboard $text
Append to Clipboard "\t\n"
$firstStep = $firstStep + 1
end
Append to Clipboard "END \n"
Paste
end
Delete Clipboard 'flowclip'
It simply builds a block of lines each starting with a number followed by a tab and newline character.
Following the line
$text = $prefix & $firstStep
I tried variations of
$text += "\t + \n"
$text & "\t + \n"
$text += "\t & \n"
and others to assemble the text added to the clipboard first. Some got complaints, but none succeeded in adding a tab and newline to the text added to the clipboard. (The pasted text was a single line.)
To add a tab or newline to text on the clipboard, do they have to be explicitly appended? Is there no way to assemble a string variable containing them that can then be appended to a clipboard?
Thank you.
Cliff Bender
***********
#NisusMacroProperty Name: _FlowChart Numbers
$message = 'What is the prefix?'
$prefix = Prompt Input $message, '', 'OK', 'S'
$message = 'What is the first number?'
$firstStep = Prompt Input $message, '', 'OK', '100'
$message = 'What is the last number?'
$lastStep = Prompt Input $message, '', 'OK', '10'
If $lastStep <= $firstStep
Die 'Sorry, the numbers are invalid.'
else
New Clipboard 'flowclip'
Switch to Clipboard 'flowclip'
Write Clipboard 'START'
Append to Clipboard "\n"
While $firstStep <= $lastStep
$text = $prefix & $firstStep
Append to Clipboard $text
Append to Clipboard "\t\n"
$firstStep = $firstStep + 1
end
Append to Clipboard "END \n"
Paste
end
Delete Clipboard 'flowclip'