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'
variables and interpolated literals
- martin
- Official Nisus Person
- Posts: 5227
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: variables and interpolated literals
There is a way, use the "&=" operator to append a string to an existing variable, eg:credneb wrote: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?
Code: Select all
$text = $prefix & $firstStep
$text &= "\t\n"
Code: Select all
$text = "$prefix$firstStep\t\n"
Code: Select all
$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', '110'
If $lastStep <= $firstStep
Die 'Sorry, the numbers are invalid.'
else
$fullText = "START\n"
While $firstStep <= $lastStep
$fullText &= "$prefix$firstStep"
$fullText &= "\t\n"
$firstStep = $firstStep + 1
end
$fullText &= "END\n"
Insert Text $fullText
end
Re: variables and interpolated literals
Thank you very much for the help, AND for the unsolicited advice. It helps the learning process and I like fast...
Your revised version is much more elegant, and as an example it answers several questions.
Thanks again.
Your revised version is much more elegant, and as an example it answers several questions.
Thanks again.
- martin
- Official Nisus Person
- Posts: 5227
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: variables and interpolated literals
Glad to help- happy macro writing!