I'm using clipboards instead of variables for large strings (= large blocks, entire file) for following reasons:
- Writing a large string (in range of some MB) to a file with UltraEdit.activeDocument.write takes extremly long time while using UltraEdit.activeDocument.paste just needs a few milliseconds even for a string with dozens of MB.
I reported this to IDM by email with 2 scripts which demonstrate the difference on speed writing the same very large string into a file. I have not analyzed up to now what is the limit for fast write versus slow write depending on string length. I'm quite sure that a string with up to 64 KB is written fast also with the write command.
- I found out with a special test script creating a string with characters in range from decimal 33 to decimal 255 (Windows 1252 code page) in a table style that some characters (for example euro symbol with code value 128) and some special 2 char sequences are not written into the file as stored in memory when using command write while using the clipboard and pasting the string produces the correct result in the file. This is a mixed problem of code page and UltraEdit's own code. In "normal" text files such characters respectively 2 char sequences do not exist.
- And last there is a memory management problem on using UltraEdit.activeDocument.selection as the selected string in memory is not removed by UltraEdit from memory if the selection in the document is canceled. The memory needed for every selected string and accessed from within the script using UltraEdit.activeDocument.selection is released on script termination. This memory management issue with UltraEdit.activeDocument.selection is no problem on working with small files of some KB, but is a big problem on working on a file with hundreds of MB and making selections of very large blocks as the script during execution occupies more and more RAM up to the 2 GB limit of a 32-bit application.
In other words for approximately 99.5% of all UltraEdit scripts usage of a clipboard instead of a string variable does not make a difference. But for the small rest of all scripts or when not knowing on which files (size, encoding) a script is designed for, it makes a difference. The scripts published by me in this forum are mainly written using a clipboard as I don't know the size of the file or the character encoding used in the files of the questioner or any other person reading the forum topic and also using the script.