Jump to content
Macro Express Forums

Clipboard with 'null' contents?


Recommended Posts

Can someone please clarify various points about the clipboard with null contents please?

 

1. Does 'null' mean 'nothing' and is that always the same as 'empty'?

 

2. If not, what are familiar examples of each, to drive the distinction home?

 

3. Is an empty line of text null? IOW, suppose I have a text file with groups of lines, with each group separated by an empty line. When I copy that to the clipboard why does it still contain the previous value, instead of nothing?

 

4. How could I therefore test for such an empty line? For example, while using Text File Begin Process?

 

5. How do you get null as the contents of the clipboard, apart from using Clipboard Empty?

 

Of course, if all of this is documented somewhere I haven't yet found, I'd appreciate a pointer please.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

1. Does 'null' mean 'nothing' and is that always the same as 'empty'?

 

Yes.

 

3. Is an empty line of text null? IOW, suppose I have a text file with groups of lines, with each group separated by an empty line. When I copy that to the clipboard why does it still contain the previous value, instead of nothing?

 

No. A blank line of text does contains something, even if only a line break, which counts as text.

 

4. How could I therefore test for such an empty line? For example, while using Text File Begin Process?

 

It depends on what those empty lines -- which are not actually empty -- consist of. The first task is to figure out what exactly is on those lines: spaces, tabs, hard line breaks, soft line breaks, optional hyphens, and so on. In a Word document, there are more invisible "characters" possible than in, say a plain text file.

 

5. How do you get null as the contents of the clipboard, apart from using Clipboard Empty?

 

That is the most convenient way that I know of. It may be possible to set a text variable to null, e.g., T1 = "", and then make the clipboard = T1. I'm not sure if Macro Express lets you do this, though.

Link to comment
Share on other sites

[Clipboard Empty is] the most convenient way that I know of. It may be possible to set a text variable to null, e.g., T1 = "", and then make the clipboard = T1. I'm not sure if Macro Express lets you do this, though.

Yes, Macro Express does allow text variables to be set to null values (historically a convenient way to use Restore All Variables and then

make sure any values you may not realize were set during a previous macro get cleared before using them in a new macro - not as much

of a problem in ME Pro, thanks to the ability to name variables).

Link to comment
Share on other sites

Using the Clipboard Empty command turns out to be very much slower than setting T1=, then writing T1 to the clipboard.

 

Thanks all, appreciate those helpful replies. It's becoming clearer now but the main thing I'm still hung up on (and which really prompted my post) is #3. Within aText Begin Process loop on a plain text file, I'm testing my empty line for CR, LF, CRLF and null, but don't get a hit with any of them.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

I see your problem. You see the Text File Process strips the CRLF off. So if the line is blank the test is simply %Var%="" is true to indicate a blank line. Another trick you can do is read the entire file into a variable and find the position of CR and if it's "1" then the first line is blank.

 

BTW I process text files all the time and often I choose to chew thru the file manually instead. I simply repeat until %File contents% = "" and find the position of LF, copy to another var, delete 1 to position and process then repeat. Sometimes one needs this for some logic flexibility File Process doesn't give one.

Link to comment
Share on other sites

I see your problem. You see the Text File Process strips the CRLF off. So if the line is blank the test is simply %Var%="" is true to indicate a blank line. Another trick you can do is read the entire file into a variable and find the position of CR and if it's "1" then the first line is blank.

 

BTW I process text files all the time and often I choose to chew thru the file manually instead. I simply repeat until %File contents% = "" and find the position of LF, copy to another var, delete 1 to position and process then repeat. Sometimes one needs this for some logic flexibility File Process doesn't give one.

 

Thanks Cory, that's another puzzle sorted! Had me stumped for half a day.

 

With that obstacle cleared, I've now been able to finish the macro we've been discussing in 'Filtering for "Called by Macro" List, Does such a feature exist?'. I'll post about it in that thread. when I've tidied up some loose ends.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Using the Clipboard Empty command turns out to be very much slower than setting T1=, then writing T1 to the clipboard.

 

I didn't get that result. I timed a loop of 100 reps of Clipboard Empty at 21 seconds. I timed setting T1="", then writing T1 to the clipboard in a 100 rep loop at 25 seconds.

Link to comment
Share on other sites

I didn't get that result. I timed a loop of 100 reps of Clipboard Empty at 21 seconds. I timed setting T1="", then writing T1 to the clipboard in a 100 rep loop at 25 seconds.

 

I assume you mean with ME Pro? (I ask because there has been a lot of discussion about this in the ME 3 forum, in the thread http://pgmacros.invisionzone.com/index.php...c=3575&st=0 )

 

1) That does seem very slow. A quick test here on my quad core PC gave a barely measurable time. So I changed to 1,000 loops and that took 8 seconds. The alternative two-command method took 11 seconds. But obviously it will depend amongst other things on individual PC specs.

 

2) Paul originally made that assertion in the ME 3 thread, but has repeated it here. So I suppose it's fair to assume it is meant to apply to ME Pro? If so then my test above contradicts it, like yours does. In fact in my case the simple Clipboard Empty was about 30% faster (11s v 8s). Given its simplicity, I'll be using this method.

 

3) But any such tests need to specify other key settings. In particular, in ME Pro, that under Options > Preferences > Playback > milliseconds between failed clipboard commands. Mine was set to the default of 250 ms until I recently discovered what a major impact it has on these sort of tests. The times above of 8 and 11 seconds were with my new setting of 10 ms. Here are a fuller set of results, showing that it's roughly directly proportional:

 

ME Pro, Clipboard Empty Method, 1,000 loops:

250 ms (default) ==> 244 s

100 ms ==> 108 s

50 ms ==> 58 s

10 ms ==> 8 s

2 ms ==> 4.2 s

1 ms ==> 2.2 s

0 ms ==> less than 1 s

 

BTW, in ME 3 it's interesting that the setting doesn't include the word 'failed':

Options > Preferences > Delays > Delay (in milliseconds) after clipboard commands (Default = 250 ms; my current setting = 10 ms.)

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

I assume you mean with ME Pro? (I ask because there has been a lot of discussion about this in the ME 3 forum, in the thread http://pgmacros.invisionzone.com/index.php...c=3575&st=0 )

 

1) That does seem very slow. A quick test here on my quad core PC gave a barely measurable time. So I changed to 1,000 loops and that took 8 seconds. The alternative two-command method took 11 seconds. But obviously it will depend amongst other things on individual PC specs.

 

2) Paul originally made that assertion in the ME 3 thread, but has repeated it here. So I suppose it's fair to assume it is meant to apply to ME Pro? If so then my test above contradicts it, like yours does. In fact in my case the simple Clipboard Empty was about 30% faster (11s v 8s). Given its simplicity, I'll be using this method.

 

3) But any such tests need to specify other key settings. In particular, in ME Pro, that under Options > Preferences > Playback > milliseconds between failed clipboard commands. Mine was set to the default of 250 ms until I recently discovered what a major impact it has on these sort of tests. The times above of 8 and 11 seconds were with my new setting of 10 ms. Here are a fuller set of results, showing that it's roughly directly proportional:

 

ME Pro, Clipboard Empty Method, 1,000 loops:

250 ms (default) ==> 244 s

100 ms ==> 108 s

50 ms ==> 58 s

10 ms ==> 8 s

2 ms ==> 4.2 s

1 ms ==> 2.2 s

0 ms ==> less than 1 s

 

BTW, in ME 3 it's interesting that the setting doesn't include the word 'failed':

Options > Preferences > Delays > Delay (in milliseconds) after clipboard commands (Default = 250 ms; my current setting = 10 ms.)

 

--

Terry, East Grinstead, UK

 

Yes, I am using ME Pro.

 

Here are some quick results:

 

ME Pro, Clipboard Empty Method, 100 loops:

250 ms (default) ==> 21 s

10 ms ==> 1.5 s

0 ms ==> 15 ms

 

I would guess this is a very significant issue for many of us. At the least, developers should be made aware of it. More study seems to be called for. When do we really need delays? The price paid for using a 250 ms default delay, so as not to have to introduce delays on a case by case basis, seems rather high.

 

I have recently completed my "Toggle Text Case" macro (emulating Microsoft Word's Shift/F3 command). Using the default 250 ms, there is a noticeable delay in the execution of the macro. With the 0 ms setting, the macro is perceptually instantaneous. However, it also runs erratically, sometimes succeeding, sometimes failing.

Link to comment
Share on other sites

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...